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

Function TestIssue9103

integration/client/container_linux_test.go:1528–1612  ·  view source on GitHub ↗

TestIssue9103 is used as regression case for issue 9103. The runc-fp will kill the init process so that the shim should return stopped status after container.NewTask. It's used to simulate that the runc-init might be killed by oom-kill.

(t *testing.T)

Source from the content-addressed store, hash-verified

1526// status after container.NewTask. It's used to simulate that the runc-init
1527// might be killed by oom-kill.
1528func TestIssue9103(t *testing.T) {
1529 if f := os.Getenv("RUNC_FLAVOR"); f != "" && f != "runc" {
1530 t.Skip("test requires runc")
1531 }
1532
1533 client, err := newClient(t, address)
1534 require.NoError(t, err)
1535 defer client.Close()
1536
1537 var (
1538 image Image
1539 ctx, cancel = testContext(t)
1540 id = t.Name()
1541 )
1542 defer cancel()
1543
1544 image, err = client.GetImage(ctx, testImage)
1545 require.NoError(t, err)
1546
1547 for idx, tc := range []struct {
1548 desc string
1549 cntrOpts []NewContainerOpts
1550 bakingFn func(ctx context.Context, t *testing.T, task Task)
1551 expectedStatus ProcessStatus
1552 }{
1553 {
1554 desc: "should be created status",
1555 cntrOpts: []NewContainerOpts{
1556 WithNewSpec(oci.WithImageConfig(image),
1557 withProcessArgs("sleep", "30"),
1558 ),
1559 },
1560 bakingFn: func(context.Context, *testing.T, Task) {},
1561 expectedStatus: Created,
1562 },
1563 {
1564 desc: "should be stopped status if init has been killed",
1565 cntrOpts: []NewContainerOpts{
1566 WithNewSpec(oci.WithImageConfig(image),
1567 withProcessArgs("sleep", "30"),
1568 oci.WithAnnotations(map[string]string{
1569 "oci.runc.failpoint.profile": "issue9103",
1570 }),
1571 ),
1572 WithRuntime(client.Runtime(), &options.Options{
1573 BinaryName: "runc-fp",
1574 }),
1575 },
1576 bakingFn: func(ctx context.Context, t *testing.T, task Task) {
1577 waitCh, err := task.Wait(ctx)
1578 require.NoError(t, err)
1579
1580 select {
1581 case <-time.After(30 * time.Second):
1582 t.Fatal("timeout")
1583 case e := <-waitCh:
1584 require.NoError(t, e.Error())
1585 }

Callers

nothing calls this directly

Calls 15

DeleteMethod · 0.95
NewTaskMethod · 0.95
WithImageConfigFunction · 0.92
WithAnnotationsFunction · 0.92
newClientFunction · 0.85
testContextFunction · 0.85
WithNewSpecFunction · 0.85
WithRuntimeFunction · 0.85
emptyFunction · 0.85
FatalMethod · 0.80
withProcessArgsFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…