Skip to content

Commit ceeba21

Browse files
committed
cadvisor_provider, unit test: Add swap stats to cadvisor CPU and Memory stats
Signed-off-by: Itamar Holder <[email protected]>
1 parent c111266 commit ceeba21

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pkg/kubelet/stats/cadvisor_stats_provider_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,7 @@ func TestCadvisorListPodCPUAndMemoryStats(t *testing.T) {
467467
assert.EqualValues(t, testTime(creationTime, seedPod0Container0).Unix(), con.StartTime.Time.Unix())
468468
checkCPUStats(t, "Pod0Container0", seedPod0Container0, con.CPU)
469469
checkMemoryStats(t, "Pod0Conainer0", seedPod0Container0, infos["/pod0-c0"], con.Memory)
470+
checkSwapStats(t, "Pod0Conainer0", seedPod0Container0, infos["/pod0-c0"], con.Swap)
470471
assert.Nil(t, con.Rootfs)
471472
assert.Nil(t, con.Logs)
472473
assert.Nil(t, con.Accelerators)
@@ -476,6 +477,7 @@ func TestCadvisorListPodCPUAndMemoryStats(t *testing.T) {
476477
assert.EqualValues(t, testTime(creationTime, seedPod0Container1).Unix(), con.StartTime.Time.Unix())
477478
checkCPUStats(t, "Pod0Container1", seedPod0Container1, con.CPU)
478479
checkMemoryStats(t, "Pod0Container1", seedPod0Container1, infos["/pod0-c1"], con.Memory)
480+
checkSwapStats(t, "Pod0Container1", seedPod0Container1, infos["/pod0-c1"], con.Swap)
479481
assert.Nil(t, con.Rootfs)
480482
assert.Nil(t, con.Logs)
481483
assert.Nil(t, con.Accelerators)
@@ -491,6 +493,9 @@ func TestCadvisorListPodCPUAndMemoryStats(t *testing.T) {
491493
if ps.Memory != nil {
492494
checkMemoryStats(t, "Pod0", seedPod0Infra, infos["/pod0-i"], ps.Memory)
493495
}
496+
if ps.Swap != nil {
497+
checkSwapStats(t, "Pod0", seedPod0Infra, infos["/pod0-i"], ps.Swap)
498+
}
494499

495500
// Validate Pod1 Results
496501
ps, found = indexPods[prf1]
@@ -500,6 +505,7 @@ func TestCadvisorListPodCPUAndMemoryStats(t *testing.T) {
500505
assert.Equal(t, cName10, con.Name)
501506
checkCPUStats(t, "Pod1Container0", seedPod1Container, con.CPU)
502507
checkMemoryStats(t, "Pod1Container0", seedPod1Container, infos["/pod1-c0"], con.Memory)
508+
checkSwapStats(t, "Pod1Container0", seedPod1Container, infos["/pod1-c0"], con.Swap)
503509
assert.Nil(t, ps.EphemeralStorage)
504510
assert.Nil(t, ps.VolumeStats)
505511
assert.Nil(t, ps.Network)
@@ -512,6 +518,7 @@ func TestCadvisorListPodCPUAndMemoryStats(t *testing.T) {
512518
assert.Equal(t, cName20, con.Name)
513519
checkCPUStats(t, "Pod2Container0", seedPod2Container, con.CPU)
514520
checkMemoryStats(t, "Pod2Container0", seedPod2Container, infos["/pod2-c0"], con.Memory)
521+
checkSwapStats(t, "Pod2Container0", seedPod2Container, infos["/pod2-c0"], con.Swap)
515522
assert.Nil(t, ps.EphemeralStorage)
516523
assert.Nil(t, ps.VolumeStats)
517524
assert.Nil(t, ps.Network)

0 commit comments

Comments
 (0)