Skip to content

Commit cfa6d32

Browse files
cmainasurunc-bot[bot]
authored andcommitted
test(volumes): Add test for block volumes in Linux over Qemu and FC
Add nerdctl tests to check if block-based volumes that are passed in the container are properly mounted and unmounted inside the Linux VM. To simulate this, a dummy block device is created from the user with dd and mkfs. Then this device is mounted somewhere and this mountpoint is passed as a bind mount to the container. For that purpose, this commit: - Adds support for defining the volumes to bind mount inside the container through the test description. - Adds support for bind mounting volumes in ctr, nerdctl, crictl and docker. This functionality can be used for other tests too. - Adds a new test which executes cat /proc/self/mountinfo inside the VM, captures the output and checks if all defined volumes in the test description were properly mounted inside the VM. Furthermore, it checks if they were unmounted correctly too. It also changed the vm_test workflow to simulate the dummy block based mount. Moreover, the timeout was increased to 3 seconds for each test because the Linux VM shows a lot of logs, exceeding 2 secs. We should definitely change that in the future. PR: #329 Signed-off-by: Charalampos Mainas <cmainas@nubificus.co.uk> Reviewed-by: Anastassios Nanos <ananos@nubificus.co.uk> Approved-by: Anastassios Nanos <ananos@nubificus.co.uk>
1 parent 912b992 commit cfa6d32

8 files changed

Lines changed: 195 additions & 1 deletion

File tree

‎.github/workflows/vm_test.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,13 @@ jobs:
171171
EOT
172172
sudo systemctl restart containerd
173173
174+
- name: Setup block-based mountpoint
175+
run: |
176+
mkdir /tmp/test_mountpoint
177+
dd if=/dev/zero of=/tmp/fake_block bs=1M count=200
178+
mkfs.ext2 /tmp/fake_block
179+
sudo mount /tmp/fake_block /tmp/test_mountpoint
180+
174181
- name: Install CNI plugins
175182
env:
176183
CNI_VERSION: ${{ inputs.cni_version }}

‎docs/Sample-images.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,5 @@ We plan to create and maintain multi-platform images soon, as well as enrich thi
4848
- harbor.nbfc.io/nubificus/urunc/block-test-spt-mirage:latest
4949
- harbor.nbfc.io/nubificus/urunc/whoami-qemu-linux-initrd:latest
5050
- harbor.nbfc.io/nubificus/urunc/whoami-firecracker-linux-initrd:latest
51+
- harbor.nbfc.io/nubificus/urunc/busybox-qemu-linux-raw:latest
52+
- harbor.nbfc.io/nubificus/urunc/busybox-firecracker-linux-raw:latest

‎tests/e2e/common.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ func commonNewContainerCmd(a containerTestArgs) string {
6666
for _, groupID := range a.Groups {
6767
cmdBase += fmt.Sprintf("--group-add %d ", groupID)
6868
}
69+
for _, vol := range a.Volumes {
70+
cmdBase += fmt.Sprintf("--mount type=bind,src=%s,dst=%s ", vol.Source, vol.Dest)
71+
}
6972
cmdBase += "--name "
7073
cmdBase += a.Name + " "
7174
cmdBase += a.Image + " "

‎tests/e2e/crictl.go‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ func crictlNewContainerConfig(path string, a containerTestArgs) (string, error)
8484
} else {
8585
name = a.Name
8686
}
87+
var mounts []*criruntimeapi.Mount
88+
for _, vol := range a.Volumes {
89+
mounts = append(mounts, &criruntimeapi.Mount{
90+
ContainerPath: vol.Dest,
91+
HostPath: vol.Source,
92+
Readonly: false,
93+
})
94+
}
8795
containerConfig := criruntimeapi.ContainerConfig{
8896
Metadata: &criruntimeapi.ContainerMetadata{
8997
Name: name,
@@ -92,6 +100,7 @@ func crictlNewContainerConfig(path string, a containerTestArgs) (string, error)
92100
Image: a.Image,
93101
},
94102
Command: strings.Fields(a.Cli),
103+
Mounts: mounts,
95104
Linux: &criruntimeapi.LinuxContainerConfig{
96105
SecurityContext: &criruntimeapi.LinuxContainerSecurityContext{},
97106
Resources: &criruntimeapi.LinuxContainerResources{},

‎tests/e2e/ctr.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ func ctrNewContainerCmd(a containerTestArgs) string {
5050
if a.UID != 0 || a.GID != 0 {
5151
cmdBase += fmt.Sprintf("-u %d:%d ", a.UID, a.GID)
5252
}
53+
for _, vol := range a.Volumes {
54+
cmdBase += fmt.Sprintf("--mount type=bind,src=%s,dst=%s ", vol.Source, vol.Dest)
55+
}
5356
cmdBase += a.Image + " "
5457
cmdBase += a.Name + " "
5558
cmdBase += a.Cli

0 commit comments

Comments
 (0)