From 3b9cc5e0da9d54a2c54d2fd01768b64b111d58e9 Mon Sep 17 00:00:00 2001
From: Denis Pynkin <denis.pynkin@collabora.com>
Date: Mon, 25 Feb 2019 15:56:26 +0300
Subject: [PATCH] Split check-tiny-*-container testcase

Split a single test case to several files per single test for
privileged and unprivileged containers.

Signed-off-by: Denis Pynkin <denis.pynkin@collabora.com>
---
 test-cases/tiny-container-system-basic.yaml   | 33 +++++++++++++++++
 ...tiny-container-system-device-sharing.yaml} | 10 ++----
 .../tiny-container-system-folder-sharing.yaml | 33 +++++++++++++++++
 test-cases/tiny-container-user-basic.yaml     | 35 +++++++++++++++++++
 ...> tiny-container-user-device-sharing.yaml} | 10 ++----
 .../tiny-container-user-folder-sharing.yaml   | 35 +++++++++++++++++++
 6 files changed, 142 insertions(+), 14 deletions(-)
 create mode 100644 test-cases/tiny-container-system-basic.yaml
 rename test-cases/{check-tiny-system-container.yaml => tiny-container-system-device-sharing.yaml} (68%)
 create mode 100644 test-cases/tiny-container-system-folder-sharing.yaml
 create mode 100644 test-cases/tiny-container-user-basic.yaml
 rename test-cases/{check-tiny-user-container.yaml => tiny-container-user-device-sharing.yaml} (70%)
 create mode 100644 test-cases/tiny-container-user-folder-sharing.yaml

diff --git a/test-cases/tiny-container-system-basic.yaml b/test-cases/tiny-container-system-basic.yaml
new file mode 100644
index 0000000..1338087
--- /dev/null
+++ b/test-cases/tiny-container-system-basic.yaml
@@ -0,0 +1,33 @@
+metadata:
+  name: tiny-container-system-basic
+  format: "Apertis Test Definition 1.0"
+  image-types:
+    tiny-lxc: [ armhf-internal, arm64, amd64 ]
+  image-deployment:
+    - APT
+  type: functional
+  exec-type: automated
+  priority: medium
+  maintainer: "Apertis Project"
+  description: "Test of Tiny system-wide privileged container using shared
+                networking with the host"
+
+  expected:
+    - "Test command should report \"pass\"."
+
+install:
+  git-repos:
+    - url: https://gitlab.apertis.org/infrastructure/tiny-image-recipes.git
+      branch: master
+
+run:
+  steps:
+    - "# Enter test directory:"
+    - cd tiny-image-recipes
+    - "# 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 functionality of container:"
+    - lavatests/check-tiny-containers -a "$ARCH" -r "$RELEASE" -d "$IMAGE_DATE" -t lxc/lxc-tiny-connectivity --aa-namespace "lxc-apertis-tiny-system"
+
+parse:
+  pattern: "(?P<test_case_id>.*-*):\\s+(?P<result>(pass|fail))"
diff --git a/test-cases/check-tiny-system-container.yaml b/test-cases/tiny-container-system-device-sharing.yaml
similarity index 68%
rename from test-cases/check-tiny-system-container.yaml
rename to test-cases/tiny-container-system-device-sharing.yaml
index 756c445..16b55db 100644
--- a/test-cases/check-tiny-system-container.yaml
+++ b/test-cases/tiny-container-system-device-sharing.yaml
@@ -1,5 +1,5 @@
 metadata:
-  name: check-tiny-system-container
+  name: tiny-container-system-device-sharing
   format: "Apertis Test Definition 1.0"
   image-types:
     tiny-lxc: [ armhf-internal, arm64, amd64 ]
@@ -9,8 +9,8 @@ metadata:
   exec-type: automated
   priority: medium
   maintainer: "Apertis Project"
-  description: "Test of Tiny system-wide privileged container using shared
-                networking with the host"
+  description: "Test of device sharing between host and Tiny system-wide 
+                privileged container"
 
   expected:
     - "Test command should report \"pass\"."
@@ -26,10 +26,6 @@ run:
     - cd tiny-image-recipes
     - "# 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:"
diff --git a/test-cases/tiny-container-system-folder-sharing.yaml b/test-cases/tiny-container-system-folder-sharing.yaml
new file mode 100644
index 0000000..6e51986
--- /dev/null
+++ b/test-cases/tiny-container-system-folder-sharing.yaml
@@ -0,0 +1,33 @@
+metadata:
+  name: tiny-container-system-folder-sharing
+  format: "Apertis Test Definition 1.0"
+  image-types:
+    tiny-lxc: [ armhf-internal, arm64, amd64 ]
+  image-deployment:
+    - APT
+  type: functional
+  exec-type: automated
+  priority: medium
+  maintainer: "Apertis Project"
+  description: "Test of folder sharing between host and Tiny system-wide
+                privileged container started as user"
+
+  expected:
+    - "Test command should report \"pass\"."
+
+install:
+  git-repos:
+    - url: https://gitlab.apertis.org/infrastructure/tiny-image-recipes.git
+      branch: master
+
+run:
+  steps:
+    - "# Enter test directory:"
+    - cd tiny-image-recipes
+    - "# 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 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"
+
+parse:
+  pattern: "(?P<test_case_id>.*-*):\\s+(?P<result>(pass|fail))"
diff --git a/test-cases/tiny-container-user-basic.yaml b/test-cases/tiny-container-user-basic.yaml
new file mode 100644
index 0000000..c555881
--- /dev/null
+++ b/test-cases/tiny-container-user-basic.yaml
@@ -0,0 +1,35 @@
+metadata:
+  name: tiny-container-user-basic
+  format: "Apertis Test Definition 1.0"
+  image-types:
+    tiny-lxc: [ armhf-internal, arm64, amd64 ]
+  image-deployment:
+    - APT
+  type: functional
+  exec-type: automated
+  priority: medium
+  maintainer: "Apertis Project"
+  description: "Test of Tiny unprivileged container without any networking
+                started as user"
+
+  expected:
+    - "Test command should report \"pass\"."
+
+install:
+  git-repos:
+    - url: https://gitlab.apertis.org/infrastructure/tiny-image-recipes.git
+      branch: master
+
+run:
+  steps:
+    - "# Enter test directory:"
+    - cd tiny-image-recipes
+    - "# 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 functionality 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"
+
+parse:
+  pattern: "(?P<test_case_id>.*-*):\\s+(?P<result>(pass|fail))"
diff --git a/test-cases/check-tiny-user-container.yaml b/test-cases/tiny-container-user-device-sharing.yaml
similarity index 70%
rename from test-cases/check-tiny-user-container.yaml
rename to test-cases/tiny-container-user-device-sharing.yaml
index 009f43b..27dcd54 100644
--- a/test-cases/check-tiny-user-container.yaml
+++ b/test-cases/tiny-container-user-device-sharing.yaml
@@ -1,5 +1,5 @@
 metadata:
-  name: check-tiny-user-container
+  name: tiny-container-user-device-sharing
   format: "Apertis Test Definition 1.0"
   image-types:
     tiny-lxc: [ armhf-internal, arm64, amd64 ]
@@ -9,8 +9,8 @@ metadata:
   exec-type: automated
   priority: medium
   maintainer: "Apertis Project"
-  description: "Test of Tiny unprivileged container without any networking
-                started as user"
+  description: "Test of device sharing between host and Tiny unprivileged
+                container started as user"
 
   expected:
     - "Test command should report \"pass\"."
@@ -28,10 +28,6 @@ run:
     - 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:"
diff --git a/test-cases/tiny-container-user-folder-sharing.yaml b/test-cases/tiny-container-user-folder-sharing.yaml
new file mode 100644
index 0000000..f67ff7c
--- /dev/null
+++ b/test-cases/tiny-container-user-folder-sharing.yaml
@@ -0,0 +1,35 @@
+metadata:
+  name: tiny-container-user-folder-sharing
+  format: "Apertis Test Definition 1.0"
+  image-types:
+    tiny-lxc: [ armhf-internal, arm64, amd64 ]
+  image-deployment:
+    - APT
+  type: functional
+  exec-type: automated
+  priority: medium
+  maintainer: "Apertis Project"
+  description: "Test of folder sharing between host and Tiny unprivileged
+                container started as user"
+
+  expected:
+    - "Test command should report \"pass\"."
+
+install:
+  git-repos:
+    - url: https://gitlab.apertis.org/infrastructure/tiny-image-recipes.git
+      branch: master
+
+run:
+  steps:
+    - "# Enter test directory:"
+    - cd tiny-image-recipes
+    - "# 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 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"
+
+parse:
+  pattern: "(?P<test_case_id>.*-*):\\s+(?P<result>(pass|fail))"
-- 
GitLab