Resolve test conflicts on #167.
Docker-DCO-1.1-Signed-off-by: Rohit Jnagal <jnagal@google.com> (github: rjnagal)
This commit is contained in:
parent
10d631be6d
commit
24a5a6aa82
@ -62,6 +62,14 @@ const (
|
|||||||
colCpuInstantUsage string = "cpu_instant_usage"
|
colCpuInstantUsage string = "cpu_instant_usage"
|
||||||
// Optional: Instant per core usage
|
// Optional: Instant per core usage
|
||||||
colPerCoreInstantUsagePrefix string = "per_core_instant_usage_core_"
|
colPerCoreInstantUsagePrefix string = "per_core_instant_usage_core_"
|
||||||
|
// Cumulative count of bytes received.
|
||||||
|
colRxBytes string = "rx_bytes"
|
||||||
|
// Cumulative count of receive errors encountered.
|
||||||
|
colRxErrors string = "rx_errors"
|
||||||
|
// Cumulative count of bytes transmitted.
|
||||||
|
colTxBytes string = "tx_bytes"
|
||||||
|
// Cumulative count of transmit errors encountered.
|
||||||
|
colTxErrors string = "tx_errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (self *influxdbStorage) containerStatsToValues(
|
func (self *influxdbStorage) containerStatsToValues(
|
||||||
@ -79,7 +87,11 @@ func (self *influxdbStorage) containerStatsToValues(
|
|||||||
|
|
||||||
// Container name
|
// Container name
|
||||||
columns = append(columns, colContainerName)
|
columns = append(columns, colContainerName)
|
||||||
|
if len(ref.Aliases) > 0 {
|
||||||
|
values = append(values, ref.Aliases[0])
|
||||||
|
} else {
|
||||||
values = append(values, ref.Name)
|
values = append(values, ref.Name)
|
||||||
|
}
|
||||||
|
|
||||||
// Cumulative Cpu Usage
|
// Cumulative Cpu Usage
|
||||||
columns = append(columns, colCpuCumulativeUsage)
|
columns = append(columns, colCpuCumulativeUsage)
|
||||||
@ -117,6 +129,21 @@ func (self *influxdbStorage) containerStatsToValues(
|
|||||||
columns = append(columns, colMemoryHierarchicalPgmajfault)
|
columns = append(columns, colMemoryHierarchicalPgmajfault)
|
||||||
values = append(values, stats.Memory.HierarchicalData.Pgmajfault)
|
values = append(values, stats.Memory.HierarchicalData.Pgmajfault)
|
||||||
|
|
||||||
|
// Optional: Network stats.
|
||||||
|
if stats.Network != nil {
|
||||||
|
columns = append(columns, colRxBytes)
|
||||||
|
values = append(values, stats.Network.RxBytes)
|
||||||
|
|
||||||
|
columns = append(columns, colRxErrors)
|
||||||
|
values = append(values, stats.Network.RxErrors)
|
||||||
|
|
||||||
|
columns = append(columns, colTxBytes)
|
||||||
|
values = append(values, stats.Network.TxBytes)
|
||||||
|
|
||||||
|
columns = append(columns, colTxErrors)
|
||||||
|
values = append(values, stats.Network.TxErrors)
|
||||||
|
}
|
||||||
|
|
||||||
// per cpu cumulative usage
|
// per cpu cumulative usage
|
||||||
for i, u := range stats.Cpu.Usage.PerCpu {
|
for i, u := range stats.Cpu.Usage.PerCpu {
|
||||||
columns = append(columns, fmt.Sprintf("%v%v", colPerCoreCumulativeUsagePrefix, i))
|
columns = append(columns, fmt.Sprintf("%v%v", colPerCoreCumulativeUsagePrefix, i))
|
||||||
@ -127,6 +154,7 @@ func (self *influxdbStorage) containerStatsToValues(
|
|||||||
if err != nil || sample == nil {
|
if err != nil || sample == nil {
|
||||||
return columns, values
|
return columns, values
|
||||||
}
|
}
|
||||||
|
// DO NOT ADD ANY STATS BELOW THAT ARE NOT PART OF SAMPLING
|
||||||
|
|
||||||
// Optional: sample duration. Unit: Nanosecond.
|
// Optional: sample duration. Unit: Nanosecond.
|
||||||
columns = append(columns, colSampleDuration)
|
columns = append(columns, colSampleDuration)
|
||||||
@ -182,6 +210,7 @@ func (self *influxdbStorage) valuesToContainerStats(columns []string, values []i
|
|||||||
stats := &info.ContainerStats{
|
stats := &info.ContainerStats{
|
||||||
Cpu: &info.CpuStats{},
|
Cpu: &info.CpuStats{},
|
||||||
Memory: &info.MemoryStats{},
|
Memory: &info.MemoryStats{},
|
||||||
|
Network: &info.NetworkStats{},
|
||||||
}
|
}
|
||||||
perCoreUsage := make(map[int]uint64, 32)
|
perCoreUsage := make(map[int]uint64, 32)
|
||||||
var err error
|
var err error
|
||||||
@ -227,6 +256,14 @@ func (self *influxdbStorage) valuesToContainerStats(columns []string, values []i
|
|||||||
// hierarchical major page fault
|
// hierarchical major page fault
|
||||||
case col == colMemoryHierarchicalPgmajfault:
|
case col == colMemoryHierarchicalPgmajfault:
|
||||||
stats.Memory.HierarchicalData.Pgmajfault, err = convertToUint64(v)
|
stats.Memory.HierarchicalData.Pgmajfault, err = convertToUint64(v)
|
||||||
|
case col == colRxBytes:
|
||||||
|
stats.Network.RxBytes, err = convertToUint64(v)
|
||||||
|
case col == colRxErrors:
|
||||||
|
stats.Network.RxErrors, err = convertToUint64(v)
|
||||||
|
case col == colTxBytes:
|
||||||
|
stats.Network.TxBytes, err = convertToUint64(v)
|
||||||
|
case col == colTxErrors:
|
||||||
|
stats.Network.TxErrors, err = convertToUint64(v)
|
||||||
case strings.HasPrefix(col, colPerCoreCumulativeUsagePrefix):
|
case strings.HasPrefix(col, colPerCoreCumulativeUsagePrefix):
|
||||||
idxStr := col[len(colPerCoreCumulativeUsagePrefix):]
|
idxStr := col[len(colPerCoreCumulativeUsagePrefix):]
|
||||||
idx, err := strconv.Atoi(idxStr)
|
idx, err := strconv.Atoi(idxStr)
|
||||||
@ -310,7 +347,6 @@ func (self *influxdbStorage) AddStats(ref info.ContainerReference, stats *info.C
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
series.Columns, series.Points[0] = self.containerStatsToValues(ref, stats)
|
series.Columns, series.Points[0] = self.containerStatsToValues(ref, stats)
|
||||||
|
|
||||||
self.prevStats = stats.Copy(self.prevStats)
|
self.prevStats = stats.Copy(self.prevStats)
|
||||||
err := self.client.WriteSeries([]*influxdb.Series{series})
|
err := self.client.WriteSeries([]*influxdb.Series{series})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -53,6 +53,11 @@ func buildTrace(cpu, mem []uint64, duration time.Duration) []*info.ContainerStat
|
|||||||
|
|
||||||
stats.Memory.Usage = mem[i]
|
stats.Memory.Usage = mem[i]
|
||||||
|
|
||||||
|
stats.Network = new(info.NetworkStats)
|
||||||
|
stats.Network.RxBytes = uint64(rand.Intn(10000))
|
||||||
|
stats.Network.RxErrors = uint64(rand.Intn(1000))
|
||||||
|
stats.Network.TxBytes = uint64(rand.Intn(100000))
|
||||||
|
stats.Network.TxErrors = uint64(rand.Intn(1000))
|
||||||
ret[i] = stats
|
ret[i] = stats
|
||||||
}
|
}
|
||||||
return ret
|
return ret
|
||||||
@ -98,6 +103,9 @@ func DefaultStatsEq(a, b *info.ContainerStats) bool {
|
|||||||
if !reflect.DeepEqual(a.Memory, b.Memory) {
|
if !reflect.DeepEqual(a.Memory, b.Memory) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if !reflect.DeepEqual(a.Network, b.Network) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,11 +441,11 @@ func StorageDriverTestRetrieveAllRecentStats(driver TestStorageDriver, t *testin
|
|||||||
if len(recentStats) == 0 {
|
if len(recentStats) == 0 {
|
||||||
t.Fatal("should at least store one stats")
|
t.Fatal("should at least store one stats")
|
||||||
}
|
}
|
||||||
if len(recentStats) > N {
|
if len(recentStats) != N {
|
||||||
t.Fatalf("returned %v stats, not 100.", len(recentStats))
|
t.Fatalf("returned %v stats, not %d.", len(recentStats), N)
|
||||||
}
|
}
|
||||||
|
|
||||||
actualRecentStats := trace[len(trace)-len(recentStats):]
|
actualRecentStats := trace //len(trace)-len(recentStats):]
|
||||||
|
|
||||||
// The returned stats should be sorted in time increasing order
|
// The returned stats should be sorted in time increasing order
|
||||||
for i, s := range actualRecentStats {
|
for i, s := range actualRecentStats {
|
||||||
|
Loading…
Reference in New Issue
Block a user