From 136fb76222753082c702479b8942176ebfa618fb Mon Sep 17 00:00:00 2001 From: Xuewei Niu Date: Sat, 7 Oct 2023 16:58:20 +0800 Subject: [PATCH] tests: Add a integrated test for device cgroup `TestDeviceCgroup` is added to cri-containerd's integration tests. The test launches two containers. Each container has a block device. It checks the validity of device cgroup. Signed-off-by: Xuewei Niu --- .../cri-containerd/integration-tests.sh | 138 ++++++++++++++++++ 1 file changed, 138 insertions(+) diff --git a/tests/integration/cri-containerd/integration-tests.sh b/tests/integration/cri-containerd/integration-tests.sh index 13caac55f7..58d28dcb71 100755 --- a/tests/integration/cri-containerd/integration-tests.sh +++ b/tests/integration/cri-containerd/integration-tests.sh @@ -430,6 +430,143 @@ function stop_containerd() { sudo systemctl stop containerd } +function mountLoopDevice() { + local loop_file="$1" + if [ -e "$loop_file" ]; then + sudo rm -f $loop_file + info "$loop_file was removed" + fi + + sudo dd if=/dev/zero of=$loop_file bs=100M count=2 + sudo mkfs.ext4 $loop_file + sudo losetup -fP $loop_file + local loinfo=$(sudo losetup -a | grep $loop_file) + local device=$(echo "$loinfo" | awk -F'[: ]' '{print $1}') + echo $device +} + +function startDeviceCgroupContainers() { + local pod_yaml=${REPORT_DIR}/device-cgroup-pod.yaml + local container1_yaml=${REPORT_DIR}/device-cgroup-container1.yaml + local container2_yaml=${REPORT_DIR}/device-cgroup-container2.yaml + local image="busybox:latest" + + cat > "$pod_yaml" < "$container1_yaml" < "$container2_yaml" <