diff --git a/pkg/kubelet/stats/cadvisor_stats_provider_test.go b/pkg/kubelet/stats/cadvisor_stats_provider_test.go index ed7c7f7e4e1..32cba277e0f 100644 --- a/pkg/kubelet/stats/cadvisor_stats_provider_test.go +++ b/pkg/kubelet/stats/cadvisor_stats_provider_test.go @@ -467,6 +467,7 @@ func TestCadvisorListPodCPUAndMemoryStats(t *testing.T) { assert.EqualValues(t, testTime(creationTime, seedPod0Container0).Unix(), con.StartTime.Time.Unix()) checkCPUStats(t, "Pod0Container0", seedPod0Container0, con.CPU) checkMemoryStats(t, "Pod0Conainer0", seedPod0Container0, infos["/pod0-c0"], con.Memory) + checkSwapStats(t, "Pod0Conainer0", seedPod0Container0, infos["/pod0-c0"], con.Swap) assert.Nil(t, con.Rootfs) assert.Nil(t, con.Logs) assert.Nil(t, con.Accelerators) @@ -476,6 +477,7 @@ func TestCadvisorListPodCPUAndMemoryStats(t *testing.T) { assert.EqualValues(t, testTime(creationTime, seedPod0Container1).Unix(), con.StartTime.Time.Unix()) checkCPUStats(t, "Pod0Container1", seedPod0Container1, con.CPU) checkMemoryStats(t, "Pod0Container1", seedPod0Container1, infos["/pod0-c1"], con.Memory) + checkSwapStats(t, "Pod0Container1", seedPod0Container1, infos["/pod0-c1"], con.Swap) assert.Nil(t, con.Rootfs) assert.Nil(t, con.Logs) assert.Nil(t, con.Accelerators) @@ -491,6 +493,9 @@ func TestCadvisorListPodCPUAndMemoryStats(t *testing.T) { if ps.Memory != nil { checkMemoryStats(t, "Pod0", seedPod0Infra, infos["/pod0-i"], ps.Memory) } + if ps.Swap != nil { + checkSwapStats(t, "Pod0", seedPod0Infra, infos["/pod0-i"], ps.Swap) + } // Validate Pod1 Results ps, found = indexPods[prf1] @@ -500,6 +505,7 @@ func TestCadvisorListPodCPUAndMemoryStats(t *testing.T) { assert.Equal(t, cName10, con.Name) checkCPUStats(t, "Pod1Container0", seedPod1Container, con.CPU) checkMemoryStats(t, "Pod1Container0", seedPod1Container, infos["/pod1-c0"], con.Memory) + checkSwapStats(t, "Pod1Container0", seedPod1Container, infos["/pod1-c0"], con.Swap) assert.Nil(t, ps.EphemeralStorage) assert.Nil(t, ps.VolumeStats) assert.Nil(t, ps.Network) @@ -512,6 +518,7 @@ func TestCadvisorListPodCPUAndMemoryStats(t *testing.T) { assert.Equal(t, cName20, con.Name) checkCPUStats(t, "Pod2Container0", seedPod2Container, con.CPU) checkMemoryStats(t, "Pod2Container0", seedPod2Container, infos["/pod2-c0"], con.Memory) + checkSwapStats(t, "Pod2Container0", seedPod2Container, infos["/pod2-c0"], con.Swap) assert.Nil(t, ps.EphemeralStorage) assert.Nil(t, ps.VolumeStats) assert.Nil(t, ps.Network)