MCPcopy
hub / github.com/containerd/containerd / TestProcessForceDelete

Function TestProcessForceDelete

integration/client/container_test.go:1251–1321  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1249}
1250
1251func TestProcessForceDelete(t *testing.T) {
1252 t.Parallel()
1253
1254 client, err := newClient(t, address)
1255 if err != nil {
1256 t.Fatal(err)
1257 }
1258 defer client.Close()
1259
1260 var (
1261 image Image
1262 ctx, cancel = testContext(t)
1263 id = t.Name()
1264 )
1265 defer cancel()
1266
1267 image, err = client.GetImage(ctx, testImage)
1268 if err != nil {
1269 t.Fatal(err)
1270 }
1271 container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image), WithNewSpec(oci.WithImageConfig(image), longCommand))
1272 if err != nil {
1273 t.Fatal(err)
1274 }
1275 defer container.Delete(ctx, WithSnapshotCleanup)
1276
1277 task, err := container.NewTask(ctx, empty())
1278 if err != nil {
1279 t.Fatal(err)
1280 }
1281 defer task.Delete(ctx)
1282
1283 statusC, err := task.Wait(ctx)
1284 if err != nil {
1285 t.Fatal(err)
1286 }
1287
1288 // task must be started on windows
1289 if err := task.Start(ctx); err != nil {
1290 t.Fatal(err)
1291 }
1292 spec, err := container.Spec(ctx)
1293 if err != nil {
1294 t.Fatal(err)
1295 }
1296
1297 processSpec := spec.Process
1298 if runtime.GOOS == "windows" {
1299 withExecArgs(processSpec, "cmd", "/c", "ping -t localhost")
1300 } else {
1301 withExecArgs(processSpec, "/bin/sh", "-c", "while true; do sleep 1; done")
1302 }
1303 execID := t.Name() + "_exec"
1304 process, err := task.Exec(ctx, execID, processSpec, empty())
1305 if err != nil {
1306 t.Fatal(err)
1307 }
1308 if err := process.Start(ctx); err != nil {

Callers

nothing calls this directly

Calls 15

DeleteMethod · 0.95
NewTaskMethod · 0.95
SpecMethod · 0.95
ExecMethod · 0.95
WithImageConfigFunction · 0.92
newClientFunction · 0.85
testContextFunction · 0.85
WithNewSpecFunction · 0.85
emptyFunction · 0.85
FatalMethod · 0.80
withExecArgsFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…