MCPcopy
hub / github.com/containerd/containerd / TestOOMEventMonitor

Function TestOOMEventMonitor

integration/oom_linux_test.go:35–139  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

33)
34
35func TestOOMEventMonitor(t *testing.T) {
36 workDir := t.TempDir()
37
38 rawCfg := fmt.Sprintf(`
39version = 3
40
41[plugins.'io.containerd.cri.v1.runtime'.containerd.runtimes.runc]
42 runtime_type = "io.containerd.runc.v2"
43 runtime_path = "%s/containerd-shim-runc-v2"
44`, *buildDir)
45
46 err := os.WriteFile(
47 filepath.Join(workDir, "config.toml"),
48 []byte(rawCfg),
49 0600,
50 )
51 require.NoError(t, err, "failed to create config")
52
53 ctrd := newCtrdProc(t, filepath.Join(*buildDir, "containerd"), workDir, []string{})
54
55 logPath := ctrd.logPath()
56 t.Cleanup(func() {
57 if t.Failed() {
58 dumpFileContent(t, logPath)
59 }
60 })
61 require.NoError(t, ctrd.isReady())
62
63 var busyboxImage = images.Get(images.BusyBox)
64 pullImagesByCRI(t, ctrd.criImageService(t), busyboxImage)
65
66 n := 8
67 podCtxs := []*podTCtx{}
68
69 defer func() {
70 for _, p := range podCtxs {
71 p.stop(true)
72 }
73
74 assert.NoError(t, ctrd.kill(syscall.SIGTERM))
75 assert.NoError(t, ctrd.wait(5*time.Minute))
76 }()
77
78 t.Logf("Creating %d pod sandboxes", n)
79 for i := range n {
80 podCtx := newPodTCtx(t,
81 ctrd.criRuntimeService(t),
82 fmt.Sprintf("test-oom-event-%d", i),
83 "sandbox",
84 WithHostNetwork)
85 podCtxs = append(podCtxs, podCtx)
86 }
87
88 for round := range 10 {
89 if t.Failed() {
90 break
91 }
92

Callers

nothing calls this directly

Calls 15

GetFunction · 0.92
newCtrdProcFunction · 0.85
dumpFileContentFunction · 0.85
pullImagesByCRIFunction · 0.85
newPodTCtxFunction · 0.85
WithCommandFunction · 0.85
EventuallyFunction · 0.85
logPathMethod · 0.80
isReadyMethod · 0.80
criImageServiceMethod · 0.80
criRuntimeServiceMethod · 0.80
WithResourcesFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…