From bb704fee12967358c6ecf476ed860747f43ef905 Mon Sep 17 00:00:00 2001 From: Denis Pynkin <denis.pynkin@collabora.com> Date: Mon, 25 Feb 2019 12:26:25 +0300 Subject: [PATCH] Add mapping tests for tiny containers Add following tests: - folder mapping - device mapping Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com> --- test-cases/check-tiny-system-container.yaml | 14 +++++++++++++- test-cases/check-tiny-user-container.yaml | 17 ++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/test-cases/check-tiny-system-container.yaml b/test-cases/check-tiny-system-container.yaml index 8e810ac..5da7f31 100644 --- a/test-cases/check-tiny-system-container.yaml +++ b/test-cases/check-tiny-system-container.yaml @@ -29,9 +29,21 @@ run: steps: - "# Enter test directory:" - cd tiny-image-recipes - - "# Execute the following commands:" + - "# Setup the AppArmor profile for container:" - sed s/__NAMESPACE_PLACEHOLDER__/lxc-apertis-tiny-system/g lxc/lxc-tiny-connectivity-profile-template | apparmor_parser -qr + - "# Check the basic fnctionality of container:" - lavatests/check-tiny-containers -a "$ARCH" -r "$RELEASE" -d "$IMAGE_DATE" -t lxc/lxc-tiny-connectivity --aa-namespace "lxc-apertis-tiny-system" + - "# Check that files created in a configured shared folder on the host can be read in the container and vice-versa:" + - lavatests/test-folder-sharing -a "$ARCH" -r "$RELEASE" -d "$IMAGE_DATE" -t lxc/lxc-tiny-connectivity --aa-namespace "lxc-apertis-tiny-system" + - "# Ensure we have loop device:" + - modprobe loop + - "# Create the random file and map it to loop0 device on host:" + - dd if=/dev/urandom of=/var/test.img bs=1M count=1 + - losetup /dev/loop0 /var/test.img + - "# Check that a simple loop device created on the host can be shared with the container and accessed from inside it:" + - lavatests/test-device-sharing -a "$ARCH" -r "$RELEASE" -d "$IMAGE_DATE" -t lxc/lxc-tiny-connectivity --aa-namespace "lxc-apertis-tiny-system" + - "# Release the loop0 device on host after the test:" + - losetup -d /dev/loop0 parse: pattern: "(?P<test_case_id>.*-*):\\s+(?P<result>(pass|fail))" diff --git a/test-cases/check-tiny-user-container.yaml b/test-cases/check-tiny-user-container.yaml index 14954a2..78b64e6 100644 --- a/test-cases/check-tiny-user-container.yaml +++ b/test-cases/check-tiny-user-container.yaml @@ -29,10 +29,25 @@ run: steps: - "# Enter test directory:" - cd tiny-image-recipes - - "# Execute the following commands:" + - "# Ensure we allow user mapping:" - sysctl -w kernel.unprivileged_userns_clone=1 + - "# Setup the AppArmor profile for container:" - sed s/__NAMESPACE_PLACEHOLDER__/lxc-apertis-tiny-userns/g lxc/lxc-tiny-connectivity-profile-template | apparmor_parser -qr + - "# Check the basic fnctionality of container:" - sudo -u user -H lavatests/check-tiny-containers -a "$ARCH" -r "$RELEASE" -d "$IMAGE_DATE" -t lxc/lxc-tiny-connectivity --aa-namespace "lxc-apertis-tiny-userns" + - "# Check that files created in a configured shared folder on the host can be read in the container and vice-versa:" + - sudo -u user -H lavatests/test-folder-sharing -a "$ARCH" -r "$RELEASE" -d "$IMAGE_DATE" -t lxc/lxc-tiny-connectivity --aa-namespace "lxc-apertis-tiny-userns" + - "# Ensure we have loop device:" + - modprobe loop + - "# Create the random file and map it to loop0 device on host:" + - dd if=/dev/urandom of=/var/test.img bs=1M count=1 + - losetup /dev/loop0 /var/test.img + - "# Allow user to access the device on host:" + - chmod 666 /dev/loop0 + - "# Check that a simple loop device created on the host can be shared with the container and accessed from inside it:" + - sudo -u user -H lavatests/test-device-sharing -a "$ARCH" -r "$RELEASE" -d "$IMAGE_DATE" -t lxc/lxc-tiny-connectivity --aa-namespace "lxc-apertis-tiny-userns" + - "# Release the loop0 device on host after the test:" + - losetup -d /dev/loop0 parse: pattern: "(?P<test_case_id>.*-*):\\s+(?P<result>(pass|fail))" -- GitLab