MCPcopy
hub / github.com/containerd/containerd / TestImageVolumeBasic

Function TestImageVolumeBasic

integration/image_volume_linux_test.go:40–189  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

38)
39
40func TestImageVolumeBasic(t *testing.T) {
41 ctx := namespaces.WithNamespace(context.Background(), "k8s.io")
42
43 snSrv := containerdClient.SnapshotService("overlayfs")
44 for _, tc := range []struct {
45 name string
46 containerImage string
47 selinuxLevel string
48 imageVolumeImage, imageSubPath string
49 containerPath string
50
51 createContainerError string
52 execSyncCommands []string
53 execSyncError string
54 execSyncOutput string
55 }{
56 {
57 name: "should be readonly content",
58 containerImage: images.Get(images.Alpine),
59 imageVolumeImage: images.Get(images.Pause),
60 containerPath: "/image-mount",
61 execSyncCommands: []string{"rm", "/image-mount/pause"},
62 execSyncError: "can't remove '/image-mount/pause': Read-only file system",
63 },
64 {
65 name: "should apply selinux labels - s0:c4,c5",
66 containerImage: images.Get(images.ResourceConsumer),
67 selinuxLevel: "s0:c4,c5",
68 imageVolumeImage: images.Get(images.Pause),
69 containerPath: "/image-mount",
70 execSyncCommands: []string{"ls", "-Z", "/image-mount"},
71 execSyncOutput: "system_u:object_r:container_file_t:s0:c4,c5 pause",
72 },
73 {
74 name: "should apply selinux labels - s0:c200,c100",
75 containerImage: images.Get(images.ResourceConsumer),
76 selinuxLevel: "s0:c200,c100",
77 imageVolumeImage: images.Get(images.Pause),
78 containerPath: "/image-mount",
79 execSyncCommands: []string{"ls", "-Z", "/image-mount"},
80 execSyncOutput: "system_u:object_r:container_file_t:s0:c100,c200 pause",
81 },
82 {
83 name: "should only mount image subpath",
84 containerImage: images.Get(images.Alpine),
85 imageVolumeImage: images.Get(images.Alpine),
86 imageSubPath: "etc",
87 containerPath: "/image-mount",
88 execSyncCommands: []string{"ls", filepath.Join("/image-mount", "os-release")},
89 execSyncOutput: filepath.Join("/image-mount", "os-release"),
90 },
91 {
92 name: "fail to mount single file subpath",
93 containerImage: images.Get(images.Alpine),
94 imageVolumeImage: images.Get(images.Pause),
95 imageSubPath: "pause",
96 containerPath: "/image-mount",
97 createContainerError: "only directory subpath is supported",

Callers

nothing calls this directly

Calls 14

WithNamespaceFunction · 0.92
GetFunction · 0.92
imageVolumeDirMethod · 0.80
LogMethod · 0.80
SnapshotServiceMethod · 0.65
RunMethod · 0.65
GetImageMethod · 0.65
TargetMethod · 0.65
MountsMethod · 0.65
ErrorMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…