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

Function TestDaemonRestart

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

Source from the content-addressed store, hash-verified

2213}
2214
2215func TestDaemonRestart(t *testing.T) {
2216 client, err := newClient(t, address)
2217 if err != nil {
2218 t.Fatal(err)
2219 }
2220 defer client.Close()
2221
2222 var (
2223 image Image
2224 ctx, cancel = testContext(t)
2225 id = t.Name()
2226 )
2227 defer cancel()
2228
2229 image, err = client.GetImage(ctx, testImage)
2230 if err != nil {
2231 t.Fatal(err)
2232 }
2233
2234 container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image), WithNewSpec(oci.WithImageConfig(image), longCommand))
2235 if err != nil {
2236 t.Fatal(err)
2237 }
2238 defer container.Delete(ctx, WithSnapshotCleanup)
2239
2240 task, err := container.NewTask(ctx, empty())
2241 if err != nil {
2242 t.Fatal(err)
2243 }
2244
2245 defer func() {
2246 if _, err := task.Delete(ctx, WithProcessKill); err != nil {
2247 t.Logf("failed to delete task: %v", err)
2248 }
2249 }()
2250
2251 statusC, err := task.Wait(ctx)
2252 if err != nil {
2253 t.Fatal(err)
2254 }
2255
2256 if err := task.Start(ctx); err != nil {
2257 t.Fatal(err)
2258 }
2259
2260 var exitStatus ExitStatus
2261 if err := ctrd.Restart(func() {
2262 exitStatus = <-statusC
2263 }); err != nil {
2264 t.Fatal(err)
2265 }
2266
2267 if exitStatus.Error() == nil {
2268 t.Errorf(`first task.Wait() should have failed with "transport is closing"`)
2269 }
2270
2271 // NOTE(gabriel-samfira): Windows needs a bit more time to restart.
2272 // Increase timeout from 2 seconds to 10 seconds to avoid deadline

Callers

nothing calls this directly

Calls 15

DeleteMethod · 0.95
NewTaskMethod · 0.95
ErrorMethod · 0.95
WithImageConfigFunction · 0.92
newClientFunction · 0.85
testContextFunction · 0.85
WithNewSpecFunction · 0.85
emptyFunction · 0.85
FatalMethod · 0.80
RestartMethod · 0.80
IsServingMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…