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

Function TestRunCustomRootfs

cmd/nerdctl/container/container_run_linux_test.go:49–68  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

47)
48
49func TestRunCustomRootfs(t *testing.T) {
50 testutil.DockerIncompatible(t)
51 // FIXME: root issue is undiagnosed and this is very likely a containerd bug
52 // It appears that in certain conditions, the proxy content store info method will fail on the layer of the image
53 // Search for func (pcs *proxyContentStore) ReaderAt(ctx context.Context, desc ocispec.Descriptor) (content.ReaderAt, error) {
54 // Note that:
55 // - the problem is still here with containerd and nerdctl v2
56 // - it seems to affect images that are tagged multiple times, or that share a layer with another image
57 // - this test is not parallelized - but the fact that namespacing it solves the problem suggest that something
58 // happening in the default namespace BEFORE this test is run is SOMETIMES setting conditions that will make this fail
59 // Possible suspects would be concurrent pulls somehow effing things up w. namespaces.
60 base := testutil.NewBaseWithNamespace(t, testutil.Identifier(t))
61 rootfs := prepareCustomRootfs(base, testutil.AlpineImage)
62 t.Cleanup(func() {
63 base.Cmd("namespace", "remove", testutil.Identifier(t)).Run()
64 })
65 defer os.RemoveAll(rootfs)
66 base.Cmd("run", "--rm", "--rootfs", rootfs, "/bin/cat", "/proc/self/environ").AssertOutContains("PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin")
67 base.Cmd("run", "--rm", "--entrypoint", "/bin/echo", "--rootfs", rootfs, "echo", "foo").AssertOutExactly("echo foo\n")
68}
69
70func prepareCustomRootfs(base *testutil.Base, imageName string) string {
71 base.Cmd("pull", "--quiet", imageName).AssertOK()

Callers

nothing calls this directly

Calls 8

DockerIncompatibleFunction · 0.92
NewBaseWithNamespaceFunction · 0.92
IdentifierFunction · 0.92
prepareCustomRootfsFunction · 0.85
AssertOutContainsMethod · 0.80
AssertOutExactlyMethod · 0.80
RunMethod · 0.65
CmdMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…