[Buildroot] [PATCH v3 3/3] support/testing/tests/fs: test OCI format

Arnout Vandecappelle arnout at mind.be
Fri Sep 10 19:16:17 UTC 2021



On 27/08/2021 22:54, Matthew Weber via buildroot wrote:
> This patch adds runtime testing of the OCI archive created by the
> sloci scripting. It launches a containerd instance, imports, and
> runs the OCI container.
> 
> The existing QEMU AARCH64 kernel config was extended to enable common
> options used by a container runtime (cgroup and overlayfs).
> 
> Signed-off-by: Matthew Weber <matthew.weber at collins.com>
> 
> ---
> The updating of the QEMU AARCH64 kernel config seemed like a better
> option then 1) adding to the docker compose test kernel fragment or
> 2) creating a new fragment for this test.

 I think a new fragment would have been better, but potato potato.

 Applied to master, thanks.

 Regards,
 Arnout

> ---
>  board/qemu/aarch64-virt/linux.config |  6 +++
>  support/testing/tests/fs/test_oci.py | 56 ++++++++++++++++++++++++++++
>  2 files changed, 62 insertions(+)
>  create mode 100644 support/testing/tests/fs/test_oci.py
> 
> diff --git a/board/qemu/aarch64-virt/linux.config b/board/qemu/aarch64-virt/linux.config
> index 02e0812ffd..e3a4a92913 100644
> --- a/board/qemu/aarch64-virt/linux.config
> +++ b/board/qemu/aarch64-virt/linux.config
> @@ -3,6 +3,11 @@ CONFIG_POSIX_MQUEUE=y
>  CONFIG_NO_HZ_IDLE=y
>  CONFIG_HIGH_RES_TIMERS=y
>  CONFIG_TASKSTATS=y
> +CONFIG_MEMCG=y
> +CONFIG_BLK_CGROUP=y
> +CONFIG_CPUSETS=y
> +CONFIG_CGROUP_DEVICE=y
> +CONFIG_CGROUP_CPUACCT=y
>  CONFIG_SCHED_AUTOGROUP=y
>  CONFIG_PROFILING=y
>  CONFIG_ARCH_VEXPRESS=y
> @@ -62,5 +67,6 @@ CONFIG_ARM_SMMU_V3=y
>  CONFIG_EXT4_FS=y
>  CONFIG_FUSE_FS=y
>  CONFIG_VIRTIO_FS=y
> +CONFIG_OVERLAY_FS=y
>  CONFIG_TMPFS=y
>  CONFIG_TMPFS_POSIX_ACL=y
> diff --git a/support/testing/tests/fs/test_oci.py b/support/testing/tests/fs/test_oci.py
> new file mode 100644
> index 0000000000..eb5548c510
> --- /dev/null
> +++ b/support/testing/tests/fs/test_oci.py
> @@ -0,0 +1,56 @@
> +import os
> +import shutil
> +import infra.basetest
> +
> +
> +class TestOci(infra.basetest.BRTest):
> +    config = \
> +        """
> +        BR2_aarch64=y
> +        BR2_TOOLCHAIN_EXTERNAL=y
> +        BR2_LINUX_KERNEL=y
> +        BR2_LINUX_KERNEL_CUSTOM_VERSION=y
> +        BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="5.10.61"
> +        BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
> +        BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
> +        BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
> +        BR2_PACKAGE_CGROUPFS_MOUNT=y
> +        BR2_PACKAGE_CONTAINERD=y
> +        BR2_TARGET_ROOTFS_EXT2=y
> +        BR2_TARGET_ROOTFS_EXT2_SIZE="600M"
> +        BR2_TARGET_ROOTFS_OCI=y
> +        BR2_TARGET_ROOTFS_OCI_ENTRYPOINT="df"
> +        BR2_TARGET_ROOTFS_OCI_ENTRYPOINT_ARGS="-h"
> +        BR2_TARGET_ROOTFS_OCI_ARCHIVE=y
> +        # BR2_TARGET_ROOTFS_TAR is not set
> +        """
> +
> +    def login(self):
> +        rootfs = os.path.join(self.builddir, "images", "rootfs.ext2")
> +        kern = os.path.join(self.builddir, "images", "Image")
> +        self.emulator.boot(arch="aarch64",
> +                           kernel=kern,
> +                           kernel_cmdline=["root=/dev/vda", "console=ttyAMA0"],
> +                           options=["-M", "virt",
> +                                    "-cpu", "cortex-a57",
> +                                    "-m", "512M",
> +                                    "-drive", "file={},format=raw,if=virtio".format(rootfs)])
> +        self.emulator.login()
> +
> +    def place_test_oci(self):
> +        shutil.copy(os.path.join(self.builddir, 'images', 'rootfs-oci-latest-aarch64-linux.oci-image.tar'),
> +                    os.path.join(self.builddir, 'target', 'oci.tar'))
> +        self.b.build()
> +
> +    def test_run(self):
> +        self.place_test_oci()
> +        self.login()
> +
> +        cmd = "containerd &"
> +        self.assertRunOk(cmd)
> +
> +        cmd = "ctr image import --base-name buildroot-test /oci.tar"
> +        self.assertRunOk(cmd, timeout=120)
> +
> +        cmd = "ctr run --rm --tty buildroot-test:latest v1"
> +        self.assertRunOk(cmd, timeout=120)
> 


More information about the buildroot mailing list