예제 #1
0
func (self *influxDbTestStorageDriver) StatsEq(a, b *info.ContainerStats) bool {
	if !test.TimeEq(a.Timestamp, b.Timestamp, 10*time.Millisecond) {
		return false
	}
	// Check only the stats populated in influxdb.
	if !reflect.DeepEqual(a.Cpu.Usage, b.Cpu.Usage) {
		return false
	}

	if a.Memory.Usage != b.Memory.Usage {
		return false
	}

	if a.Memory.WorkingSet != b.Memory.WorkingSet {
		return false
	}

	if !reflect.DeepEqual(a.Network, b.Network) {
		return false
	}

	if !reflect.DeepEqual(a.Filesystem, b.Filesystem) {
		return false
	}
	return true
}
예제 #2
0
func (self *influxDbTestStorageDriver) StatsEq(a, b *info.ContainerStats) bool {
	if !test.TimeEq(a.Timestamp, b.Timestamp, 10*time.Millisecond) {
		return false
	}
	// Check only the stats populated in influxdb.
	if a.Cpu.Usage.Total != b.Cpu.Usage.Total {
		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
	}

	if a.Memory.WorkingSet != b.Memory.WorkingSet {
		return false
	}

	if !reflect.DeepEqual(a.Network, b.Network) {
		return false
	}

	if !reflect.DeepEqual(a.Filesystem, b.Filesystem) {
		return false
	}
	return true
}
예제 #3
0
func StatsEq(a, b *info.ContainerStats) bool {
	if !test.TimeEq(a.Timestamp, b.Timestamp, 10*time.Millisecond) {
		return false
	}
	// Check only the stats populated in influxdb.
	if a.Cpu.Usage.Total != b.Cpu.Usage.Total {
		return false
	}

	if a.Memory.Usage != b.Memory.Usage {
		return false
	}

	if a.Memory.WorkingSet != b.Memory.WorkingSet {
		return false
	}

	if !reflect.DeepEqual(a.Network, b.Network) {
		return false
	}
	return true
}