MCPcopy
hub / github.com/containerd/containerd / TestWaitStoppedProcess

Function TestWaitStoppedProcess

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

Source from the content-addressed store, hash-verified

1120}
1121
1122func TestWaitStoppedProcess(t *testing.T) {
1123 t.Parallel()
1124
1125 client, err := newClient(t, address)
1126 if err != nil {
1127 t.Fatal(err)
1128 }
1129 defer client.Close()
1130
1131 var (
1132 image Image
1133 ctx, cancel = testContext(t)
1134 id = t.Name()
1135 )
1136 defer cancel()
1137
1138 image, err = client.GetImage(ctx, testImage)
1139 if err != nil {
1140 t.Fatal(err)
1141 }
1142
1143 container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image), WithNewSpec(oci.WithImageConfig(image), longCommand))
1144 if err != nil {
1145 t.Fatal(err)
1146 }
1147 defer container.Delete(ctx, WithSnapshotCleanup)
1148
1149 task, err := container.NewTask(ctx, empty())
1150 if err != nil {
1151 t.Fatal(err)
1152 }
1153 defer task.Delete(ctx)
1154
1155 finishedC, err := task.Wait(ctx)
1156 if err != nil {
1157 t.Error(err)
1158 }
1159
1160 if err := task.Start(ctx); err != nil {
1161 t.Fatal(err)
1162 }
1163 spec, err := container.Spec(ctx)
1164 if err != nil {
1165 t.Fatal(err)
1166 }
1167
1168 // start an exec process without running the original container process info
1169 processSpec := spec.Process
1170 withExecExitStatus(processSpec, 6)
1171 execID := t.Name() + "_exec"
1172 process, err := task.Exec(ctx, execID, processSpec, empty())
1173 if err != nil {
1174 t.Fatal(err)
1175 }
1176 defer process.Delete(ctx)
1177
1178 statusC, err := process.Wait(ctx)
1179 if 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
ResultMethod · 0.80
withExecExitStatusFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…