cadvisor/integration/tests/api/machine_test.go
Victor Marmol f6a90d7bac Adding integration test framework along with 3 tests.
These tests are similar to Go unit tests except that they're targetting
tesing of a running cAdvisor client. They do this by interacting with
the testing framework that is able to talk to the running cAdvisor. This
cAdvisor could be local or remote.
2014-11-19 13:02:24 -08:00

37 lines
1.0 KiB
Go

package api
import (
"testing"
"github.com/google/cadvisor/integration/framework"
)
func TestMachineInformationIsReturned(t *testing.T) {
fm := framework.New(t)
defer fm.Cleanup()
machineInfo, err := fm.Cadvisor().Client().MachineInfo()
if err != nil {
t.Fatal(err)
}
// Check for "sane" values. Note these can change with time.
if machineInfo.NumCores <= 0 || machineInfo.NumCores >= 1000000 {
t.Errorf("Machine info has unexpected number of cores: %v", machineInfo.NumCores)
}
if machineInfo.MemoryCapacity <= 0 || machineInfo.MemoryCapacity >= (1<<50 /* 1PB */) {
t.Errorf("Machine info has unexpected amount of memory: %v", machineInfo.MemoryCapacity)
}
if len(machineInfo.Filesystems) == 0 {
t.Errorf("Expected to have some filesystems, found none")
}
for _, fs := range machineInfo.Filesystems {
if fs.Device == "" {
t.Errorf("Expected a non-empty device name in: %+v", fs)
}
if fs.Capacity < 0 || fs.Capacity >= (1<<60 /* 1 EB*/) {
t.Errorf("Unexpected capacity in device %q: %v", fs.Device, fs.Capacity)
}
}
}