(t *testing.T)
| 38 | ) |
| 39 | |
| 40 | func 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", |
nothing calls this directly
no test coverage detected
searching dependent graphs…