From patchwork Wed Nov 20 13:39:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Havelange X-Patchwork-Id: 1198167 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=essensium.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=essensium-com.20150623.gappssmtp.com header.i=@essensium-com.20150623.gappssmtp.com header.b="yUvMOuyO"; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47J3tk4rqdz9sPV for ; Thu, 21 Nov 2019 00:48:28 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id CC2D98575A; Wed, 20 Nov 2019 13:48:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Zm-w5iXyeg0o; Wed, 20 Nov 2019 13:48:25 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id 0D07B85BC9; Wed, 20 Nov 2019 13:48:25 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id EEF7F1BF379 for ; Wed, 20 Nov 2019 13:48:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id D8F1C85816 for ; Wed, 20 Nov 2019 13:48:23 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CI4sQgUBATME for ; Wed, 20 Nov 2019 13:48:23 +0000 (UTC) X-Greylist: delayed 00:08:14 by SQLgrey-1.7.6 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by fraxinus.osuosl.org (Postfix) with ESMTPS id C72A98578C for ; Wed, 20 Nov 2019 13:48:22 +0000 (UTC) Received: by mail-wr1-f51.google.com with SMTP id w9so28247807wrr.0 for ; Wed, 20 Nov 2019 05:48:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=essensium-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=yEc1XnmFvIQ3OYGaKA6Ec6BcTAnYFtzujNfS50I9wJI=; b=yUvMOuyOOcdJ4jtDQEada9ubDW2YTl808/fz48SG6shLwh6sDM07Kul33/RsLaufVq DZjV0pziqKDbTcyTq+/pqrzS69rOv/23IHGRP47k4Trq7wpTBpvYUPRuEf0o9uVK/HgO e8rCNYpzR5rQpP1iGruPthchlHHqnkxSbCAburclNcSsexmD7/RQ8S79YKww3kKOA0zB fItgXU2SX6kWg1Z2eNGhGbeHLMTGoXfRF/H3Jo1Gp3UdqDYkaLxylRoJ05lyWNLsBBlc 9ZFvdiYshyVV2L4vPiVka4nerRDl0UUpICmrRX4bOR1H90poQeJyET8/JdxvRa2ttVSv vcNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=yEc1XnmFvIQ3OYGaKA6Ec6BcTAnYFtzujNfS50I9wJI=; b=UKfTiQmvjVYbhgdzYWOHacV42xZOVRWxFt1SyNruzkBHQqXLfc32xnhOALjtcUfyFi AFeqHP64csoWnWo34s3TW68siGhYxHZ/ajN14SFcByP5MMLdfzmpnWE8In+lh9mX8hxc 8S+zNxP1UoxxtE4FW1s3xnhel8XNfwggTfIZ8oprjkD/5wdc+wUnosbcSnZhtb+CYBVf BBqDsM/ZA5vnbrhY/Js/RdOq6B1PrxPiOVNfCDcpq1PtjXAo/uDofRQjkMeOr9RVT/MT lZYC8PnIi05Y7mseT343k6Exvgy/XzE/ozN+vlMCBbnR4QAQpwgUw+rZxmh+095XSfRr gXYA== X-Gm-Message-State: APjAAAXV8dYJLeROnJEn6lSucteQDjgIkHtNGpTf9JWLr7SHZAQz6xNs bG1VcH7B8TXLRXcB0n4DQVuUgWg4a3A= X-Google-Smtp-Source: APXvYqyzgn0QPCbKbRtUOP6s2hu14eqMjyhptEqC3lucnjsbkzLCsZto1EFLKdjUick1wtfikyXAfQ== X-Received: by 2002:a5d:4609:: with SMTP id t9mr3475615wrq.178.1574257206287; Wed, 20 Nov 2019 05:40:06 -0800 (PST) Received: from ph-ThinkPad-E560.local.ess-mail.com (ip-188-118-3-185.reverse.destiny.be. [188.118.3.185]) by smtp.gmail.com with ESMTPSA id v9sm30579090wrs.95.2019.11.20.05.40.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Nov 2019 05:40:05 -0800 (PST) From: Patrick Havelange To: buildroot@buildroot.org Date: Wed, 20 Nov 2019 14:39:52 +0100 Message-Id: <20191120133952.22978-2-patrick.havelange@essensium.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191120133952.22978-1-patrick.havelange@essensium.com> References: <20191120133952.22978-1-patrick.havelange@essensium.com> MIME-Version: 1.0 Subject: [Buildroot] [PATCH v2 2/2] support/testing: add lxc test X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Patrick Havelange , Ricardo Martincoski Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" The test starts a simple container with an iperf3 server. The container is using the tini init system, with a shared rootfs. An iperf3 client is started from the host to check that the container is really up and running. Signed-off-by: Patrick Havelange --- Changes v1 -> v2 [Thomas - Moved the assertRunOk function to the BRTest class --- .gitlab-ci.yml | 1 + support/testing/tests/package/test_lxc.py | 56 +++++++++++++++++++ .../tests/package/test_lxc/kernel_config_frag | 20 +++++++ .../test_lxc_rootfs_overlay/usr/bin/iperf3.sh | 2 + .../usr/share/lxc/config/minimal-iperf3.conf | 4 ++ .../usr/share/lxc/config/minimal.conf | 6 ++ 6 files changed, 89 insertions(+) create mode 100644 support/testing/tests/package/test_lxc.py create mode 100644 support/testing/tests/package/test_lxc/kernel_config_frag create mode 100755 support/testing/tests/package/test_lxc/test_lxc_rootfs_overlay/usr/bin/iperf3.sh create mode 100644 support/testing/tests/package/test_lxc/test_lxc_rootfs_overlay/usr/share/lxc/config/minimal-iperf3.conf create mode 100644 support/testing/tests/package/test_lxc/test_lxc_rootfs_overlay/usr/share/lxc/config/minimal.conf diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 1d71257a20..9ef93130a1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -410,6 +410,7 @@ tests.package.test_luasocket.TestLuajitLuaSocket: { extends: .runtime_test } tests.package.test_luasyslog.TestLuaLuasyslog: { extends: .runtime_test } tests.package.test_luasyslog.TestLuajitLuasyslog: { extends: .runtime_test } tests.package.test_luvi.TestLuvi: { extends: .runtime_test } +tests.package.test_lxc.TestLxc: { extends: .runtime_test } tests.package.test_lzlib.TestLuaLzlib: { extends: .runtime_test } tests.package.test_openjdk.TestOpenJdk: { extends: .runtime_test } tests.package.test_perl.TestPerl: { extends: .runtime_test } diff --git a/support/testing/tests/package/test_lxc.py b/support/testing/tests/package/test_lxc.py new file mode 100644 index 0000000000..2447f5c4e3 --- /dev/null +++ b/support/testing/tests/package/test_lxc.py @@ -0,0 +1,56 @@ +import os + +import infra.basetest +import pexpect + +class TestLxc(infra.basetest.BRTest): + config = \ + """ + BR2_arm=y + BR2_TOOLCHAIN_EXTERNAL=y + BR2_LINUX_KERNEL=y + BR2_LINUX_KERNEL_CUSTOM_VERSION=y + BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.19.79" + BR2_LINUX_KERNEL_DEFCONFIG="vexpress" + BR2_LINUX_KERNEL_DTS_SUPPORT=y + BR2_LINUX_KERNEL_INTREE_DTS_NAME="vexpress-v2p-ca9" + BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{}" + BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0" + BR2_INIT_SYSTEMD=y + BR2_PACKAGE_LXC=y + BR2_PACKAGE_TINI=y + BR2_PACKAGE_IPERF3=y + BR2_ROOTFS_OVERLAY="{}" + BR2_TARGET_ROOTFS_CPIO=y + """.format( + infra.filepath("tests/package/test_lxc/kernel_config_frag"), + infra.filepath("tests/package/test_lxc/test_lxc_rootfs_overlay")) + + def run_ok(self, cmd): + self.assertRunOk(cmd, 120) + + def wait_boot(self): + #the complete boot with systemd takes more time than what the default multipler permits + self.emulator.timeout_multiplier *= 10 + self.emulator.login() + + def setup_run_test_container(self): + self.run_ok("lxc-create -n lxc_iperf3 -t none -f /usr/share/lxc/config/minimal-iperf3.conf") + self.run_ok("lxc-start -l trace -n lxc_iperf3 -o /tmp/lxc.log -L /tmp/lxc.console.log") + #need to wait for the container to be fully started + self.run_ok("sleep 2") + self.run_ok("iperf3 -c 192.168.1.2 -t 2") + #if the test fails, just cat /tmp/*.log + + def test_run(self): + cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio") + kernel_file = os.path.join(self.builddir, "images", "zImage") + dtb_file = os.path.join(self.builddir, "images", "vexpress-v2p-ca9.dtb") + self.emulator.boot(arch="armv7", kernel=kernel_file, + kernel_cmdline=[ + "console=ttyAMA0,115200"], + options=["-initrd", cpio_file, + "-dtb", dtb_file, + "-M", "vexpress-a9"]) + self.wait_boot() + self.setup_run_test_container() diff --git a/support/testing/tests/package/test_lxc/kernel_config_frag b/support/testing/tests/package/test_lxc/kernel_config_frag new file mode 100644 index 0000000000..32f8bdd65e --- /dev/null +++ b/support/testing/tests/package/test_lxc/kernel_config_frag @@ -0,0 +1,20 @@ +CONFIG_FIX_EARLYCON_MEM=y +CONFIG_BLK_CGROUP=y +CONFIG_CGROUP_SCHED=y +CONFIG_CGROUP_PIDS=y +CONFIG_CGROUP_FREEZER=y +CONFIG_CGROUP_DEVICE=y +CONFIG_CGROUP_CPUACCT=y +CONFIG_CGROUP_DEBUG=y +CONFIG_NETFILTER_XT_MATCH_CGROUP=y +CONFIG_SOCK_CGROUP_DATA=y +CONFIG_CGROUP_NET_PRIO=y +CONFIG_CGROUP_NET_CLASSID=y +CONFIG_NAMESPACES=y +CONFIG_IPC_NS=y +CONFIG_PID_NS=y +CONFIG_UTS_NS=y +CONFIG_USER_NS=y +CONFIG_NET_NS=y +CONFIG_BRIDGE=y +CONFIG_VETH=y diff --git a/support/testing/tests/package/test_lxc/test_lxc_rootfs_overlay/usr/bin/iperf3.sh b/support/testing/tests/package/test_lxc/test_lxc_rootfs_overlay/usr/bin/iperf3.sh new file mode 100755 index 0000000000..7045ca4806 --- /dev/null +++ b/support/testing/tests/package/test_lxc/test_lxc_rootfs_overlay/usr/bin/iperf3.sh @@ -0,0 +1,2 @@ +#!/bin/sh +iperf3 -s -1 > /tmp/iperf3.serv.log 2>&1 diff --git a/support/testing/tests/package/test_lxc/test_lxc_rootfs_overlay/usr/share/lxc/config/minimal-iperf3.conf b/support/testing/tests/package/test_lxc/test_lxc_rootfs_overlay/usr/share/lxc/config/minimal-iperf3.conf new file mode 100644 index 0000000000..41cc5311d6 --- /dev/null +++ b/support/testing/tests/package/test_lxc/test_lxc_rootfs_overlay/usr/share/lxc/config/minimal-iperf3.conf @@ -0,0 +1,4 @@ +lxc.include = /usr/share/lxc/config/minimal.conf +lxc.hook.version = 1 +lxc.hook.start-host = ip a add 192.168.1.1/24 dev lxc0 +lxc.init.cmd = tini -g iperf3.sh diff --git a/support/testing/tests/package/test_lxc/test_lxc_rootfs_overlay/usr/share/lxc/config/minimal.conf b/support/testing/tests/package/test_lxc/test_lxc_rootfs_overlay/usr/share/lxc/config/minimal.conf new file mode 100644 index 0000000000..7319821506 --- /dev/null +++ b/support/testing/tests/package/test_lxc/test_lxc_rootfs_overlay/usr/share/lxc/config/minimal.conf @@ -0,0 +1,6 @@ +lxc.autodev = 0 +lxc.net.0.type = veth +lxc.net.0.veth.pair = lxc0 +lxc.net.0.name = eth0 +lxc.net.0.flags = up +lxc.net.0.ipv4.address = 192.168.1.2/24