address comments

This commit is contained in:
Angela Li
2019-07-22 10:53:15 -07:00
parent 99a7a0a53b
commit e6e8615db3
2 changed files with 20 additions and 7 deletions

View File

@@ -149,13 +149,25 @@ func TestConvertCPUValue(t *testing.T) {
}
func TestGetCPUUsageNanoCores(t *testing.T) {
p := perfCounterNodeStatsClient{}
p.cpuUsageCoreNanoSecondsCache = cpuUsageCoreNanoSecondsCache{
latestValue: uint64(5000000000),
previousValue: uint64(2000000000),
testCases := []struct {
latestValue uint64
previousValue uint64
expected uint64
}{
{latestValue: uint64(0), previousValue: uint64(0), expected: uint64(0)},
{latestValue: uint64(2000000000), previousValue: uint64(0), expected: uint64(200000000)},
{latestValue: uint64(5000000000), previousValue: uint64(2000000000), expected: uint64(300000000)},
}
for _, tc := range testCases {
p := perfCounterNodeStatsClient{}
p.cpuUsageCoreNanoSecondsCache = cpuUsageCoreNanoSecondsCache{
latestValue: tc.latestValue,
previousValue: tc.previousValue,
}
cpuUsageNanoCores := p.getCPUUsageNanoCores()
assert.Equal(t, cpuUsageNanoCores, tc.expected)
}
cpuUsageNanoCores := p.getCPUUsageNanoCores()
assert.Equal(t, cpuUsageNanoCores, uint64(300000000))
}
func getClient(t *testing.T) Client {