MCPcopy Index your code
hub / github.com/containerd/containerd / TestIssue7496

Function TestIssue7496

integration/issue7496_linux_test.go:45–108  ·  view source on GitHub ↗

TestIssue7496 is used to reproduce https://github.com/containerd/containerd/issues/7496 NOTE: https://github.com/containerd/containerd/issues/8931 is the same issue.

(t *testing.T)

Source from the content-addressed store, hash-verified

43//
44// NOTE: https://github.com/containerd/containerd/issues/8931 is the same issue.
45func TestIssue7496(t *testing.T) {
46 ctx := namespaces.WithNamespace(context.Background(), "k8s.io")
47
48 t.Logf("Create a pod config and run sandbox container")
49 sbConfig := PodSandboxConfig("sandbox", "issue7496")
50 sbID, err := runtimeService.RunPodSandbox(sbConfig, *runtimeHandler)
51 require.NoError(t, err)
52
53 shimCli := connectToShim(ctx, t, containerdEndpoint, 3, sbID)
54
55 delayInSec := 12
56 t.Logf("[shim pid: %d]: Injecting %d seconds delay to umount2 syscall",
57 shimPid(ctx, t, shimCli),
58 delayInSec)
59
60 doneCh := injectDelayToUmount2(ctx, t, shimCli, delayInSec /* CRI plugin uses 10 seconds to delete task */)
61
62 t.Logf("Create a container config and run container in a pod")
63 pauseImage := images.Get(images.Pause)
64 EnsureImageExists(t, pauseImage)
65
66 containerConfig := ContainerConfig("pausecontainer", pauseImage)
67 cnID, err := runtimeService.CreateContainer(sbID, containerConfig, sbConfig)
68 require.NoError(t, err)
69 require.NoError(t, runtimeService.StartContainer(cnID))
70
71 t.Logf("Start to StopPodSandbox and RemovePodSandbox")
72 ctx, cancelFn := context.WithTimeout(ctx, 3*time.Minute)
73 defer cancelFn()
74 for {
75 select {
76 case <-ctx.Done():
77 require.NoError(t, ctx.Err(), "The StopPodSandbox should be done in time")
78 default:
79 }
80
81 err := runtimeService.StopPodSandbox(sbID)
82 if err != nil {
83 t.Logf("Failed to StopPodSandbox: %v", err)
84 continue
85 }
86
87 err = runtimeService.RemovePodSandbox(sbID)
88 if err == nil {
89 break
90 }
91 t.Logf("Failed to RemovePodSandbox: %v", err)
92 time.Sleep(1 * time.Second)
93 }
94
95 t.Logf("PodSandbox %s has been deleted and start to wait for strace exit", sbID)
96 select {
97 case <-time.After(15 * time.Second):
98 resp, err := shimCli.Connect(ctx, &apitask.ConnectRequest{})
99 assert.Error(t, err, "should failed to call shim connect API")
100
101 t.Errorf("Strace doesn't exit in time")
102

Callers

nothing calls this directly

Calls 15

WithNamespaceFunction · 0.92
GetFunction · 0.92
PodSandboxConfigFunction · 0.85
connectToShimFunction · 0.85
shimPidFunction · 0.85
injectDelayToUmount2Function · 0.85
EnsureImageExistsFunction · 0.85
ContainerConfigFunction · 0.85
RunPodSandboxMethod · 0.65
CreateContainerMethod · 0.65
StartContainerMethod · 0.65
DoneMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…