MCPcopy
hub / github.com/containerd/containerd / TestUpdatePodSandboxWithRestart

Function TestUpdatePodSandboxWithRestart

integration/nri_test.go:576–612  ·  view source on GitHub ↗

Test pod sandbox resource updates persist across containerd restarts.

(t *testing.T)

Source from the content-addressed store, hash-verified

574
575// Test pod sandbox resource updates persist across containerd restarts.
576func TestUpdatePodSandboxWithRestart(t *testing.T) {
577 skipNriTestIfNecessary(t)
578
579 t.Log("Test that pod sandbox resource updates persist across containerd restarts.")
580
581 tc := &nriTest{
582 t: t,
583 }
584 tc.setup()
585
586 podID := tc.runPod("pod0")
587 _ = tc.startContainer(podID, "ctr0")
588
589 overhead := &runtime.LinuxContainerResources{MemoryLimitInBytes: 10}
590 res := &runtime.LinuxContainerResources{MemoryLimitInBytes: 5}
591 err := tc.runtime.UpdatePodSandboxResources(podID, overhead, res)
592 assert.NoError(tc.t, err, "update pod sandbox")
593
594 t.Logf("Verify sandbox resources are updated before restart")
595 _, info, err := SandboxInfo(podID)
596 require.NoError(t, err)
597 require.NotNil(t, info.Resources)
598 require.NotNil(t, info.Overhead)
599 assert.Equal(t, res.MemoryLimitInBytes, info.Resources.GetLinux().GetMemoryLimitInBytes())
600 assert.Equal(t, overhead.MemoryLimitInBytes, info.Overhead.GetLinux().GetMemoryLimitInBytes())
601
602 t.Logf("Restart containerd")
603 RestartContainerd(t, syscall.SIGTERM)
604
605 t.Logf("Verify sandbox resources are still updated after restart")
606 _, info, err = SandboxInfo(podID)
607 require.NoError(t, err)
608 require.NotNil(t, info.Resources)
609 require.NotNil(t, info.Overhead)
610 assert.Equal(t, res.MemoryLimitInBytes, info.Resources.GetLinux().GetMemoryLimitInBytes())
611 assert.Equal(t, overhead.MemoryLimitInBytes, info.Overhead.GetLinux().GetMemoryLimitInBytes())
612}
613
614// Test NRI vs. containerd restart.
615func TestNriPluginContainerdRestart(t *testing.T) {

Callers

nothing calls this directly

Calls 8

setupMethod · 0.95
runPodMethod · 0.95
startContainerMethod · 0.95
skipNriTestIfNecessaryFunction · 0.85
RestartContainerdFunction · 0.85
LogMethod · 0.80
SandboxInfoFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…