diff --git a/storage/influxdb/influxdb_test.go b/storage/influxdb/influxdb_test.go index 39433ae6..f25b12a6 100644 --- a/storage/influxdb/influxdb_test.go +++ b/storage/influxdb/influxdb_test.go @@ -61,31 +61,9 @@ func (self *influxDbTestStorageDriver) StatsEq(a, b *info.ContainerStats) bool { return false } // Check only the stats populated in influxdb. - if a.Cpu.Usage.Total != b.Cpu.Usage.Total { + if !reflect.DeepEqual(a.Cpu.Usage, b.Cpu.Usage) { return false } - if a.Cpu.Usage.System != b.Cpu.Usage.System { - return false - } - if a.Cpu.Usage.User != b.Cpu.Usage.User { - return false - } - - // TODO simpler way to check if arrays are equal? - if a.Cpu.Usage.PerCpu == nil && b.Cpu.Usage.PerCpu != nil { - return false - } - if a.Cpu.Usage.PerCpu != nil && b.Cpu.Usage.PerCpu == nil { - return false - } - if len(a.Cpu.Usage.PerCpu) != len(b.Cpu.Usage.PerCpu) { - return false - } - for i, usage := range a.Cpu.Usage.PerCpu { - if usage != b.Cpu.Usage.PerCpu[i] { - return false - } - } if a.Memory.Usage != b.Memory.Usage { return false @@ -107,6 +85,7 @@ func (self *influxDbTestStorageDriver) StatsEq(a, b *info.ContainerStats) bool { func runStorageTest(f func(test.TestStorageDriver, *testing.T), t *testing.T, bufferCount int) { machineName := "machineA" + table := "cadvisor_table" database := "cadvisor_test" username := "root" password := "root" @@ -131,7 +110,8 @@ func runStorageTest(f func(test.TestStorageDriver, *testing.T), t *testing.T, bu // Delete all data by the end of the call. //defer client.Query(influxdb.Query{Command: fmt.Sprintf("drop database \"%v\"", database)}) - driver, err := New(machineName, + driver, err := newStorage(machineName, + table, database, username, password, @@ -150,7 +130,8 @@ func runStorageTest(f func(test.TestStorageDriver, *testing.T), t *testing.T, bu test.StorageDriverFillRandomStatsFunc("containerOnSameMachine", 100, testDriver, t) // Generate another container's data on another machine. - driverForAnotherMachine, err := New("machineB", + driverForAnotherMachine, err := newStorage("machineB", + table, database, username, password, @@ -198,12 +179,14 @@ func TestContainerFileSystemStatsToPoints(t *testing.T) { assert := assert.New(t) machineName := "testMachine" + table := "cadvisor_table" database := "cadvisor_test" username := "root" password := "root" influxdbHost := "localhost:8086" - storage, err := New(machineName, + storage, err := newStorage(machineName, + table, database, username, password, @@ -267,12 +250,14 @@ func assertContainsPointWithValue(t *testing.T, points []*influxdb.Point, name s func createTestStorage() (*influxdbStorage, error) { machineName := "testMachine" + table := "cadvisor_table" database := "cadvisor_test" username := "root" password := "root" influxdbHost := "localhost:8086" - storage, err := New(machineName, + storage, err := newStorage(machineName, + table, database, username, password,