public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
* [PATCH v2] ci: Add test cases for container fetching and loading
@ 2024-08-06 15:16 Uladzimir Bely
  2024-08-06 15:33 ` 'Jan Kiszka' via isar-users
  0 siblings, 1 reply; 2+ messages in thread
From: Uladzimir Bely @ 2024-08-06 15:16 UTC (permalink / raw)
  To: isar-users

From: Jan Kiszka <jan.kiszka@siemens.com>

This plugs the two example recipes for loading container images into
VM-based testing. The test consists of running 'true' in the installed
alpine images.

Rather than enabling the ci user to do password-less sudo, this uses su
with the piped-in password. Another trick needed is to poll for the
images because loading is performed asynchronously.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
---
 meta-test/recipes-core/images/isar-image-ci.bb |  2 ++
 testsuite/citest.py                            | 10 ++++++++++
 testsuite/scripts/test_prebuilt_containers.sh  | 16 ++++++++++++++++
 3 files changed, 28 insertions(+)
 create mode 100755 testsuite/scripts/test_prebuilt_containers.sh

This is a drop-in replacement of patch 4 from "[PATCH v4 0/5] Introduce
container fetcher and pre-loader" series:
- Fixed syntax errors (incorrectly escaped '\$')
- Fixed long lines in order to pass flake8

Changes since v1:
- Switched from running command to script for better readability.

diff --git a/meta-test/recipes-core/images/isar-image-ci.bb b/meta-test/recipes-core/images/isar-image-ci.bb
index e5d51e6e..9133da74 100644
--- a/meta-test/recipes-core/images/isar-image-ci.bb
+++ b/meta-test/recipes-core/images/isar-image-ci.bb
@@ -16,6 +16,7 @@ IMAGE_INSTALL += "sshd-regen-keys"
 
 # qemuamd64-bookworm
 WKS_FILE:qemuamd64:debian-bookworm ?= "multipart-efi.wks"
+IMAGE_INSTALL:append:qemuamd64:debian-bookworm = " prebuilt-docker-img prebuilt-podman-img"
 
 # qemuamd64-bullseye
 IMAGE_FSTYPES:append:qemuamd64:debian-bullseye ?= " cpio.gz tar.gz"
@@ -51,3 +52,4 @@ IMAGER_INSTALL:append:qemuarm:debian-bookworm ?= " ${SYSTEMD_BOOTLOADER_INSTALL}
 # qemuarm64-bookworm
 IMAGE_FSTYPES:append:qemuarm64:debian-bookworm ?= " wic.xz"
 IMAGER_INSTALL:append:qemuarm64:debian-bookworm ?= " ${GRUB_BOOTLOADER_INSTALL}"
+IMAGE_INSTALL:append:qemuarm64:debian-bookworm = " prebuilt-docker-img prebuilt-podman-img"
diff --git a/testsuite/citest.py b/testsuite/citest.py
index 7064c1e4..87f34846 100755
--- a/testsuite/citest.py
+++ b/testsuite/citest.py
@@ -609,3 +609,13 @@ class VmBootTestFull(CIBaseTest):
             image='isar-image-ci',
             script='test_kernel_module.sh example_module',
         )
+
+    def test_amd64_bookworm_prebuilt_containers(self):
+        self.init()
+        self.vm_start('amd64', 'bookworm', image='isar-image-ci',
+                      script='test_prebuilt_containers.sh')
+
+    def test_arm64_bookworm_prebuilt_containers(self):
+        self.init()
+        self.vm_start('arm64', 'bookworm', image='isar-image-ci',
+                      script='test_prebuilt_containers.sh')
diff --git a/testsuite/scripts/test_prebuilt_containers.sh b/testsuite/scripts/test_prebuilt_containers.sh
new file mode 100755
index 00000000..1700e653
--- /dev/null
+++ b/testsuite/scripts/test_prebuilt_containers.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+echo root | su -c '\
+    set -e
+    export PATH=$PATH:/usr/sbin
+    for n in $(seq 30); do
+        docker images | grep -q alpine && break
+        sleep 10
+    done
+    docker run --rm quay.io/libpod/alpine:3.10.2 true
+    for n in $(seq 30); do
+        podman images | grep -q alpine && break
+        sleep 10
+    done
+    podman run --rm quay.io/libpod/alpine:latest true
+'
-- 
2.44.2

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/isar-users/20240806151947.27113-1-ubely%40ilbers.de.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] ci: Add test cases for container fetching and loading
  2024-08-06 15:16 [PATCH v2] ci: Add test cases for container fetching and loading Uladzimir Bely
@ 2024-08-06 15:33 ` 'Jan Kiszka' via isar-users
  0 siblings, 0 replies; 2+ messages in thread
From: 'Jan Kiszka' via isar-users @ 2024-08-06 15:33 UTC (permalink / raw)
  To: Uladzimir Bely, isar-users

On 06.08.24 17:16, Uladzimir Bely wrote:
> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> This plugs the two example recipes for loading container images into
> VM-based testing. The test consists of running 'true' in the installed
> alpine images.
> 
> Rather than enabling the ci user to do password-less sudo, this uses su
> with the piped-in password. Another trick needed is to poll for the
> images because loading is performed asynchronously.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> Signed-off-by: Uladzimir Bely <ubely@ilbers.de>
> ---
>  meta-test/recipes-core/images/isar-image-ci.bb |  2 ++
>  testsuite/citest.py                            | 10 ++++++++++
>  testsuite/scripts/test_prebuilt_containers.sh  | 16 ++++++++++++++++
>  3 files changed, 28 insertions(+)
>  create mode 100755 testsuite/scripts/test_prebuilt_containers.sh
> 
> This is a drop-in replacement of patch 4 from "[PATCH v4 0/5] Introduce
> container fetcher and pre-loader" series:
> - Fixed syntax errors (incorrectly escaped '\$')
> - Fixed long lines in order to pass flake8
> 
> Changes since v1:
> - Switched from running command to script for better readability.
> 
> diff --git a/meta-test/recipes-core/images/isar-image-ci.bb b/meta-test/recipes-core/images/isar-image-ci.bb
> index e5d51e6e..9133da74 100644
> --- a/meta-test/recipes-core/images/isar-image-ci.bb
> +++ b/meta-test/recipes-core/images/isar-image-ci.bb
> @@ -16,6 +16,7 @@ IMAGE_INSTALL += "sshd-regen-keys"
>  
>  # qemuamd64-bookworm
>  WKS_FILE:qemuamd64:debian-bookworm ?= "multipart-efi.wks"
> +IMAGE_INSTALL:append:qemuamd64:debian-bookworm = " prebuilt-docker-img prebuilt-podman-img"
>  
>  # qemuamd64-bullseye
>  IMAGE_FSTYPES:append:qemuamd64:debian-bullseye ?= " cpio.gz tar.gz"
> @@ -51,3 +52,4 @@ IMAGER_INSTALL:append:qemuarm:debian-bookworm ?= " ${SYSTEMD_BOOTLOADER_INSTALL}
>  # qemuarm64-bookworm
>  IMAGE_FSTYPES:append:qemuarm64:debian-bookworm ?= " wic.xz"
>  IMAGER_INSTALL:append:qemuarm64:debian-bookworm ?= " ${GRUB_BOOTLOADER_INSTALL}"
> +IMAGE_INSTALL:append:qemuarm64:debian-bookworm = " prebuilt-docker-img prebuilt-podman-img"
> diff --git a/testsuite/citest.py b/testsuite/citest.py
> index 7064c1e4..87f34846 100755
> --- a/testsuite/citest.py
> +++ b/testsuite/citest.py
> @@ -609,3 +609,13 @@ class VmBootTestFull(CIBaseTest):
>              image='isar-image-ci',
>              script='test_kernel_module.sh example_module',
>          )
> +
> +    def test_amd64_bookworm_prebuilt_containers(self):
> +        self.init()
> +        self.vm_start('amd64', 'bookworm', image='isar-image-ci',
> +                      script='test_prebuilt_containers.sh')
> +
> +    def test_arm64_bookworm_prebuilt_containers(self):
> +        self.init()
> +        self.vm_start('arm64', 'bookworm', image='isar-image-ci',
> +                      script='test_prebuilt_containers.sh')
> diff --git a/testsuite/scripts/test_prebuilt_containers.sh b/testsuite/scripts/test_prebuilt_containers.sh
> new file mode 100755
> index 00000000..1700e653
> --- /dev/null
> +++ b/testsuite/scripts/test_prebuilt_containers.sh
> @@ -0,0 +1,16 @@
> +#!/bin/sh
> +
> +echo root | su -c '\
> +    set -e
> +    export PATH=$PATH:/usr/sbin
> +    for n in $(seq 30); do
> +        docker images | grep -q alpine && break
> +        sleep 10
> +    done
> +    docker run --rm quay.io/libpod/alpine:3.10.2 true
> +    for n in $(seq 30); do
> +        podman images | grep -q alpine && break
> +        sleep 10
> +    done
> +    podman run --rm quay.io/libpod/alpine:latest true
> +'

Nice!

Reviewed-by: Jan Kiszka <jan.kiszka@siemens.com>

Thanks,
Jan

-- 
Siemens AG, Technology
Linux Expert Center

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/isar-users/05bee3f7-c934-49d7-bd93-b7edc930bd08%40siemens.com.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-08-06 15:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-06 15:16 [PATCH v2] ci: Add test cases for container fetching and loading Uladzimir Bely
2024-08-06 15:33 ` 'Jan Kiszka' via isar-users

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox