Skip to content

Commit 54500bf

Browse files
committed
cadvisor_provider, unit tests: ensure container-level metrics are collected
Signed-off-by: Itamar Holder <[email protected]>
1 parent ceeba21 commit 54500bf

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
@@ -313,6 +313,7 @@ func TestCadvisorListPodStats(t *testing.T) {
313313
}
314314
if ps.Swap != nil {
315315
checkSwapStats(t, "Pod0", seedPod0Infra, infos["/pod0-i"], ps.Swap)
316+
checkContainersSwapStats(t, ps, infos["/pod0-c0"], infos["/pod0-c1"])
316317
}
317318

318319
// Validate Pod1 Results
@@ -325,6 +326,7 @@ func TestCadvisorListPodStats(t *testing.T) {
325326
checkMemoryStats(t, "Pod1Container0", seedPod1Container, infos["/pod1-c0"], con.Memory)
326327
checkSwapStats(t, "Pod1Container0", seedPod1Container, infos["/pod1-c0"], con.Swap)
327328
checkNetworkStats(t, "Pod1", seedPod1Infra, ps.Network)
329+
checkContainersSwapStats(t, ps, infos["/pod1-c0"])
328330

329331
// Validate Pod2 Results
330332
ps, found = indexPods[prf2]
@@ -336,6 +338,7 @@ func TestCadvisorListPodStats(t *testing.T) {
336338
checkMemoryStats(t, "Pod2Container0", seedPod2Container, infos["/pod2-c0"], con.Memory)
337339
checkSwapStats(t, "Pod2Container0", seedPod2Container, infos["/pod2-c0"], con.Swap)
338340
checkNetworkStats(t, "Pod2", seedPod2Infra, ps.Network)
341+
checkContainersSwapStats(t, ps, infos["/pod2-c0"])
339342

340343
// Validate Pod3 Results
341344

@@ -352,6 +355,7 @@ func TestCadvisorListPodStats(t *testing.T) {
352355
checkCPUStats(t, "Pod3Container1", seedPod3Container1, con.CPU)
353356
checkMemoryStats(t, "Pod3Container1", seedPod3Container1, infos["/pod3-c1"], con.Memory)
354357
checkSwapStats(t, "Pod3Container1", seedPod3Container1, infos["/pod3-c1"], con.Swap)
358+
checkContainersSwapStats(t, ps, infos["/pod3-c1"])
355359
}
356360

357361
func TestCadvisorListPodCPUAndMemoryStats(t *testing.T) {
@@ -495,6 +499,7 @@ func TestCadvisorListPodCPUAndMemoryStats(t *testing.T) {
495499
}
496500
if ps.Swap != nil {
497501
checkSwapStats(t, "Pod0", seedPod0Infra, infos["/pod0-i"], ps.Swap)
502+
checkContainersSwapStats(t, ps, infos["/pod0-c0"], infos["/pod0-c1"])
498503
}
499504

500505
// Validate Pod1 Results
@@ -506,6 +511,7 @@ func TestCadvisorListPodCPUAndMemoryStats(t *testing.T) {
506511
checkCPUStats(t, "Pod1Container0", seedPod1Container, con.CPU)
507512
checkMemoryStats(t, "Pod1Container0", seedPod1Container, infos["/pod1-c0"], con.Memory)
508513
checkSwapStats(t, "Pod1Container0", seedPod1Container, infos["/pod1-c0"], con.Swap)
514+
checkContainersSwapStats(t, ps, infos["/pod1-c0"])
509515
assert.Nil(t, ps.EphemeralStorage)
510516
assert.Nil(t, ps.VolumeStats)
511517
assert.Nil(t, ps.Network)
@@ -519,6 +525,7 @@ func TestCadvisorListPodCPUAndMemoryStats(t *testing.T) {
519525
checkCPUStats(t, "Pod2Container0", seedPod2Container, con.CPU)
520526
checkMemoryStats(t, "Pod2Container0", seedPod2Container, infos["/pod2-c0"], con.Memory)
521527
checkSwapStats(t, "Pod2Container0", seedPod2Container, infos["/pod2-c0"], con.Swap)
528+
checkContainersSwapStats(t, ps, infos["/pod2-c0"])
522529
assert.Nil(t, ps.EphemeralStorage)
523530
assert.Nil(t, ps.VolumeStats)
524531
assert.Nil(t, ps.Network)

0 commit comments

Comments
 (0)