MCPcopy Create free account
hub / github.com/containerd/nerdctl / EnsureContainerExited

Method EnsureContainerExited

pkg/testutil/testutil.go:319–341  ·  view source on GitHub ↗
(con string, expectedExitCode int)

Source from the content-addressed store, hash-verified

317}
318
319func (b *Base) EnsureContainerExited(con string, expectedExitCode int) {
320 b.T.Helper()
321
322 const (
323 maxRetry = 5
324 sleep = time.Second
325 )
326 var c dockercompat.Container
327 for i := 0; i < maxRetry; i++ {
328 c = b.InspectContainer(con)
329 if c.State.Status == "exited" {
330 b.T.Logf("container %s have exited with status %d", con, c.State.ExitCode)
331 if c.State.ExitCode == expectedExitCode {
332 return
333 }
334 break
335 }
336 b.T.Logf("(retry=%d)", i+1)
337 time.Sleep(sleep)
338 }
339 b.T.Fatalf("expected conainer %s to have exited with code %d, got status %+v",
340 con, expectedExitCode, c.State)
341}
342
343type Cmd struct {
344 icmd.Cmd

Callers 1

preparePsTestContainerFunction · 0.95

Calls 2

InspectContainerMethod · 0.95
HelperMethod · 0.65

Tested by 1

preparePsTestContainerFunction · 0.76