(t *testing.T)
| 33 | ) |
| 34 | |
| 35 | func TestOOMEventMonitor(t *testing.T) { |
| 36 | workDir := t.TempDir() |
| 37 | |
| 38 | rawCfg := fmt.Sprintf(` |
| 39 | version = 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…