From cb2b74cfc90ffc1e626f13786960c6d6b6a7d7e7 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Mon, 15 May 2017 15:51:00 +0100 Subject: [PATCH 1/9] tests: Rename linuxkit.config to linuxkit.kernel Removed LTP tests and the stress test group as hey weren't run via rtf. Signed-off-by: Rolf Neugebauer --- test/cases/000_config/group.sh | 37 -------------- .../000_config}/test-kernel-config.yml | 0 .../000_config}/test.sh | 2 +- .../010_kmod/Dockerfile | 0 .../010_kmod/check.sh | 0 .../010_kmod/kmod.yml | 0 .../010_kmod/src/Makefile | 0 .../010_kmod/src/hello_world.c | 0 .../010_kmod/test.sh | 0 .../cases/{020_stress => 020_kernel}/group.sh | 8 +-- test/cases/020_stress/000_ltp/test-ltp.yml | 28 ----------- test/cases/020_stress/000_ltp/test.sh | 24 --------- .../010_virtsock/test-virtsock-server.yml | 49 ------------------- test/cases/020_stress/010_virtsock/test.sh | 4 -- 14 files changed, 2 insertions(+), 150 deletions(-) delete mode 100644 test/cases/000_config/group.sh rename test/cases/{000_config/000_kernel => 020_kernel/000_config}/test-kernel-config.yml (100%) rename test/cases/{000_config/000_kernel => 020_kernel/000_config}/test.sh (85%) rename test/cases/{000_config => 020_kernel}/010_kmod/Dockerfile (100%) rename test/cases/{000_config => 020_kernel}/010_kmod/check.sh (100%) rename test/cases/{000_config => 020_kernel}/010_kmod/kmod.yml (100%) rename test/cases/{000_config => 020_kernel}/010_kmod/src/Makefile (100%) rename test/cases/{000_config => 020_kernel}/010_kmod/src/hello_world.c (100%) rename test/cases/{000_config => 020_kernel}/010_kmod/test.sh (100%) rename test/cases/{020_stress => 020_kernel}/group.sh (61%) delete mode 100644 test/cases/020_stress/000_ltp/test-ltp.yml delete mode 100644 test/cases/020_stress/000_ltp/test.sh delete mode 100644 test/cases/020_stress/010_virtsock/test-virtsock-server.yml delete mode 100644 test/cases/020_stress/010_virtsock/test.sh diff --git a/test/cases/000_config/group.sh b/test/cases/000_config/group.sh deleted file mode 100644 index d9b73eb99..000000000 --- a/test/cases/000_config/group.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -# SUMMARY: LinuxKit configuration tests -# LABELS: -# For the top level group.sh also specify a 'NAME:' comment - -# Source libraries. Uncomment if needed/defined -#. "${RT_LIB}" -#. "${RT_PROJECT_ROOT}/_lib/lib.sh" - - -group_init() { - # Group initialisation code goes here - return 0 -} - -group_deinit() { - # Group de-initialisation code goes here - return 0 -} - -CMD=$1 -case $CMD in -init) - group_init - res=$? - ;; -deinit) - group_deinit - res=$? - ;; -*) - res=1 - ;; -esac - -exit $res - diff --git a/test/cases/000_config/000_kernel/test-kernel-config.yml b/test/cases/020_kernel/000_config/test-kernel-config.yml similarity index 100% rename from test/cases/000_config/000_kernel/test-kernel-config.yml rename to test/cases/020_kernel/000_config/test-kernel-config.yml diff --git a/test/cases/000_config/000_kernel/test.sh b/test/cases/020_kernel/000_config/test.sh similarity index 85% rename from test/cases/000_config/000_kernel/test.sh rename to test/cases/020_kernel/000_config/test.sh index 4a407455e..7883df33b 100644 --- a/test/cases/000_config/000_kernel/test.sh +++ b/test/cases/020_kernel/000_config/test.sh @@ -1,5 +1,5 @@ #!/bin/sh -# SUMMARY: Test the kernel configuration is suitable for running Docker +# SUMMARY: Sanity check on the kernel config file # LABELS: # REPEAT: # AUTHOR: Dave Tucker diff --git a/test/cases/000_config/010_kmod/Dockerfile b/test/cases/020_kernel/010_kmod/Dockerfile similarity index 100% rename from test/cases/000_config/010_kmod/Dockerfile rename to test/cases/020_kernel/010_kmod/Dockerfile diff --git a/test/cases/000_config/010_kmod/check.sh b/test/cases/020_kernel/010_kmod/check.sh similarity index 100% rename from test/cases/000_config/010_kmod/check.sh rename to test/cases/020_kernel/010_kmod/check.sh diff --git a/test/cases/000_config/010_kmod/kmod.yml b/test/cases/020_kernel/010_kmod/kmod.yml similarity index 100% rename from test/cases/000_config/010_kmod/kmod.yml rename to test/cases/020_kernel/010_kmod/kmod.yml diff --git a/test/cases/000_config/010_kmod/src/Makefile b/test/cases/020_kernel/010_kmod/src/Makefile similarity index 100% rename from test/cases/000_config/010_kmod/src/Makefile rename to test/cases/020_kernel/010_kmod/src/Makefile diff --git a/test/cases/000_config/010_kmod/src/hello_world.c b/test/cases/020_kernel/010_kmod/src/hello_world.c similarity index 100% rename from test/cases/000_config/010_kmod/src/hello_world.c rename to test/cases/020_kernel/010_kmod/src/hello_world.c diff --git a/test/cases/000_config/010_kmod/test.sh b/test/cases/020_kernel/010_kmod/test.sh similarity index 100% rename from test/cases/000_config/010_kmod/test.sh rename to test/cases/020_kernel/010_kmod/test.sh diff --git a/test/cases/020_stress/group.sh b/test/cases/020_kernel/group.sh similarity index 61% rename from test/cases/020_stress/group.sh rename to test/cases/020_kernel/group.sh index 303b26465..7c0c3fd89 100644 --- a/test/cases/020_stress/group.sh +++ b/test/cases/020_kernel/group.sh @@ -1,12 +1,6 @@ #!/bin/sh -# SUMMARY: LinuxKit stress tests +# SUMMARY: Kernel tests # LABELS: -# For the top level group.sh also specify a 'NAME:' comment - -# Source libraries. Uncomment if needed/defined -#. "${RT_LIB}" -#. "${RT_PROJECT_ROOT}/_lib/lib.sh" - group_init() { # Group initialisation code goes here diff --git a/test/cases/020_stress/000_ltp/test-ltp.yml b/test/cases/020_stress/000_ltp/test-ltp.yml deleted file mode 100644 index c47555f88..000000000 --- a/test/cases/020_stress/000_ltp/test-ltp.yml +++ /dev/null @@ -1,28 +0,0 @@ -kernel: - image: "linuxkit/kernel:4.9.x" - cmdline: "console=ttyS0" -init: - - linuxkit/init:b3740303f3d1e5689a84c87b7dfb48fd2a40a192 - - linuxkit/runc:47b1c38d63468c0f3078f8b1b055d07965a1895d - - linuxkit/containerd:cf2614f5a96c569a0bd4bd54e054a65ba17d167f - - linuxkit/ca-certificates:3344cdca1bc59fdfa17bd7f0fcbf491b9dbaa288 -onboot: - - name: ltp - image: "linuxkit/test-ltp-20170116:81229df2d25065b06f0a3071faaace8d66c87e67" - net: host - pid: host - binds: - - /etc/ltp/baseline:/etc/ltp/baseline - capabilities: - - all - - name: poweroff - image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084" - pid: host - capabilities: - - CAP_SYS_BOOT - readonly: true -files: - - path: /etc/ltp/baseline - contents: "100" -outputs: - - format: gcp-img diff --git a/test/cases/020_stress/000_ltp/test.sh b/test/cases/020_stress/000_ltp/test.sh deleted file mode 100644 index 4516d75e1..000000000 --- a/test/cases/020_stress/000_ltp/test.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# SUMMARY: Run the Linux Testing Project tests -# LABELS: slow, gcp -# REPEAT: -# AUTHOR: Dave Tucker - -set -e - -# Source libraries. Uncomment if needed/defined -#. "${RT_LIB}" -. "${RT_PROJECT_ROOT}/_lib/lib.sh" - -clean_up() { - find . -iname "test-ltp*" -not -iname "*.yml" -exec rm -rf {} \; -} -trap clean_up EXIT - -# Test code goes here -moby build test-ltp -linuxkit push test-ltp.img.tar.gz -RESULT="$(linuxkit run gcp -skip-cleanup -machine n1-highcpu-4 test-ltp)" -echo "${RESULT}" | grep -q "suite has passed" - -exit 0 diff --git a/test/cases/020_stress/010_virtsock/test-virtsock-server.yml b/test/cases/020_stress/010_virtsock/test-virtsock-server.yml deleted file mode 100644 index 0f9df7e56..000000000 --- a/test/cases/020_stress/010_virtsock/test-virtsock-server.yml +++ /dev/null @@ -1,49 +0,0 @@ -kernel: - # Alternatively: - #image: "linuxkit/kernel:4.11.x" - # image: "linuxkit/kernel:4.10.x" - image: "linuxkit/kernel:4.9.x" - # image: "linuxkit/kernel:4.4.x" - cmdline: "console=ttyS0 page_poison=1" -init: - - linuxkit/init:b3740303f3d1e5689a84c87b7dfb48fd2a40a192 - - linuxkit/runc:47b1c38d63468c0f3078f8b1b055d07965a1895d - - linuxkit/containerd:cf2614f5a96c569a0bd4bd54e054a65ba17d167f - - linuxkit/ca-certificates:3344cdca1bc59fdfa17bd7f0fcbf491b9dbaa288 -onboot: - - name: sysctl - image: "linuxkit/sysctl:1f5ec5d5e6f7a7a1b3d2ff9dd9e36fd6fb14756a" - net: host - pid: host - ipc: host - capabilities: - - CAP_SYS_ADMIN - readonly: true -services: - - name: rngd - image: "linuxkit/rngd:61a07ced77a9747708223ca16a4aec621eacf518" - capabilities: - - CAP_SYS_ADMIN - oomScoreAdj: -800 - readonly: true - - name: dhcpcd - image: "linuxkit/dhcpcd:2def74ab3f9233b4c09ebb196ba47c27c08b0ed8" - binds: - - /var:/var - - /tmp:/etc - capabilities: - - CAP_NET_ADMIN - - CAP_NET_BIND_SERVICE - - CAP_NET_RAW - net: host - oomScoreAdj: -800 - - name: virtsock-server - image: "linuxkit/test-virtsock:a7dc8e477d99ea82f56eacd94579ca65985eb0b3" - readonly: true -trust: - image: - - linuxkit/kernel - - linuxkit/rngd -outputs: - - format: kernel+initrd - - format: iso-efi diff --git a/test/cases/020_stress/010_virtsock/test.sh b/test/cases/020_stress/010_virtsock/test.sh deleted file mode 100644 index f08447049..000000000 --- a/test/cases/020_stress/010_virtsock/test.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# LABELS: windows, skip - -# FIXME: Write this test!!! From 9eb710411a51da578ca361717b3e9ff4f79323b1 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Mon, 15 May 2017 16:20:24 +0100 Subject: [PATCH 2/9] tests: Add a linux.build group to test 'moby build' - Add a tests which generates all supported outputs - move the examples build tests to the new group Signed-off-by: Rolf Neugebauer --- test/cases/000_build/000_outputs/test.sh | 35 +++++++++++++++++++ test/cases/000_build/000_outputs/test.yml | 33 +++++++++++++++++ .../100_examples/000_minimal/test.sh | 0 .../100_examples/010_docker/test.sh | 0 .../100_examples/020_sshd/test.sh | 0 .../100_examples/030_redis/test.sh | 0 .../100_examples/040_swap/test.sh | 0 .../100_examples/050_node_exporter/test.sh | 0 test/cases/000_build/100_examples/group.sh | 31 ++++++++++++++++ test/cases/000_build/group.sh | 31 ++++++++++++++++ 10 files changed, 130 insertions(+) create mode 100644 test/cases/000_build/000_outputs/test.sh create mode 100644 test/cases/000_build/000_outputs/test.yml rename test/cases/{ => 000_build}/100_examples/000_minimal/test.sh (100%) rename test/cases/{ => 000_build}/100_examples/010_docker/test.sh (100%) rename test/cases/{ => 000_build}/100_examples/020_sshd/test.sh (100%) rename test/cases/{ => 000_build}/100_examples/030_redis/test.sh (100%) rename test/cases/{ => 000_build}/100_examples/040_swap/test.sh (100%) rename test/cases/{ => 000_build}/100_examples/050_node_exporter/test.sh (100%) create mode 100644 test/cases/000_build/100_examples/group.sh create mode 100644 test/cases/000_build/group.sh diff --git a/test/cases/000_build/000_outputs/test.sh b/test/cases/000_build/000_outputs/test.sh new file mode 100644 index 000000000..e0835cd5c --- /dev/null +++ b/test/cases/000_build/000_outputs/test.sh @@ -0,0 +1,35 @@ +#!/bin/sh +# SUMMARY: Check that all supported output formats are generated +# LABELS: +# AUTHOR: Rolf Neugebauer + +set -e + +# Source libraries. Uncomment if needed/defined +#. "${RT_LIB}" +. "${RT_PROJECT_ROOT}/_lib/lib.sh" + +NAME=check + +clean_up() { + # remove any images + find . -iname "${NAME}*" -exec rm {} \; +} + +trap clean_up EXIT + +moby build -name "${NAME}" test.yml + +[ -f "${NAME}.tar" ] || exit 1 +[ -f "${NAME}-kernel" ] || exit 1 +[ -f "${NAME}-initrd.img" ] || exit 1 +[ -f "${NAME}-cmdline" ] || exit 1 +[ -f "${NAME}.iso" ] || exit 1 +[ -f "${NAME}-efi.iso" ] || exit 1 +[ -f "${NAME}.img.gz" ] || exit 1 +[ -f "${NAME}.qcow2" ] || exit 1 +# VHD currently requires a lot of memory, disable for now +# [ -f "${NAME}.vhd" ] || exit 1 +[ -f "${NAME}.vmdk" ] || exit 1 + +exit 0 diff --git a/test/cases/000_build/000_outputs/test.yml b/test/cases/000_build/000_outputs/test.yml new file mode 100644 index 000000000..7c6387b5f --- /dev/null +++ b/test/cases/000_build/000_outputs/test.yml @@ -0,0 +1,33 @@ +kernel: + image: "linuxkit/kernel:4.9.x" + cmdline: "console=ttyS0 console=tty0 page_poison=1" +init: + - linuxkit/init:b3740303f3d1e5689a84c87b7dfb48fd2a40a192 + - linuxkit/runc:47b1c38d63468c0f3078f8b1b055d07965a1895d + - linuxkit/containerd:cf2614f5a96c569a0bd4bd54e054a65ba17d167f +onboot: + - name: dhcpcd + image: "linuxkit/dhcpcd:2def74ab3f9233b4c09ebb196ba47c27c08b0ed8" + binds: + - /var:/var + - /tmp/etc:/etc + capabilities: + - CAP_NET_ADMIN + - CAP_NET_BIND_SERVICE + - CAP_NET_RAW + net: host + command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"] +trust: + image: + - linuxkit/kernel +outputs: + - format: tar + - format: kernel+initrd + - format: iso-bios + - format: iso-efi + - format: img-gz + - format: gcp-img + - format: qcow2 +# Disable VHD for now. It requires a lot of memory, which our CI instance currently doesn't have +# - format: vhd + - format: vmdk diff --git a/test/cases/100_examples/000_minimal/test.sh b/test/cases/000_build/100_examples/000_minimal/test.sh similarity index 100% rename from test/cases/100_examples/000_minimal/test.sh rename to test/cases/000_build/100_examples/000_minimal/test.sh diff --git a/test/cases/100_examples/010_docker/test.sh b/test/cases/000_build/100_examples/010_docker/test.sh similarity index 100% rename from test/cases/100_examples/010_docker/test.sh rename to test/cases/000_build/100_examples/010_docker/test.sh diff --git a/test/cases/100_examples/020_sshd/test.sh b/test/cases/000_build/100_examples/020_sshd/test.sh similarity index 100% rename from test/cases/100_examples/020_sshd/test.sh rename to test/cases/000_build/100_examples/020_sshd/test.sh diff --git a/test/cases/100_examples/030_redis/test.sh b/test/cases/000_build/100_examples/030_redis/test.sh similarity index 100% rename from test/cases/100_examples/030_redis/test.sh rename to test/cases/000_build/100_examples/030_redis/test.sh diff --git a/test/cases/100_examples/040_swap/test.sh b/test/cases/000_build/100_examples/040_swap/test.sh similarity index 100% rename from test/cases/100_examples/040_swap/test.sh rename to test/cases/000_build/100_examples/040_swap/test.sh diff --git a/test/cases/100_examples/050_node_exporter/test.sh b/test/cases/000_build/100_examples/050_node_exporter/test.sh similarity index 100% rename from test/cases/100_examples/050_node_exporter/test.sh rename to test/cases/000_build/100_examples/050_node_exporter/test.sh diff --git a/test/cases/000_build/100_examples/group.sh b/test/cases/000_build/100_examples/group.sh new file mode 100644 index 000000000..0340e3bac --- /dev/null +++ b/test/cases/000_build/100_examples/group.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# SUMMARY: Check that the examples YAML files work +# LABELS: + +group_init() { + # Group initialisation code goes here + return 0 +} + +group_deinit() { + # Group de-initialisation code goes here + return 0 +} + +CMD=$1 +case $CMD in +init) + group_init + res=$? + ;; +deinit) + group_deinit + res=$? + ;; +*) + res=1 + ;; +esac + +exit $res + diff --git a/test/cases/000_build/group.sh b/test/cases/000_build/group.sh new file mode 100644 index 000000000..55db0da11 --- /dev/null +++ b/test/cases/000_build/group.sh @@ -0,0 +1,31 @@ +#!/bin/sh +# SUMMARY: LinuxKit tests for 'moby build' +# LABELS: + +group_init() { + # Group initialisation code goes here + return 0 +} + +group_deinit() { + # Group de-initialisation code goes here + return 0 +} + +CMD=$1 +case $CMD in +init) + group_init + res=$? + ;; +deinit) + group_deinit + res=$? + ;; +*) + res=1 + ;; +esac + +exit $res + From ddb4221c1fd5dee9211ed402c0f04c1d7693ad97 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Mon, 15 May 2017 16:53:55 +0100 Subject: [PATCH 3/9] tests: Consolidate platform tests There is no need to split the build from run as we have separate build tests Also shuffle the order around a little. Double digit numbers are for local hypervisor tests and tripple digit tests are for cloud. Removed GCP test as they weren't run. Signed-off-by: Rolf Neugebauer --- .../010_platforms/000_qemu/000_build/test.sh | 28 -------------- .../000_qemu/000_run_kernel/test.sh | 27 ++++++++++++++ .../{000_build => 000_run_kernel}/test.yml | 11 ------ .../010_platforms/000_qemu/001_run/test.sh | 24 ------------ .../000_qemu/010_build_iso/test.sh | 26 ------------- .../000_qemu/010_run_iso/test.sh | 24 ++++++++++++ .../{010_build_iso => 010_run_iso}/test.yml | 11 ------ .../000_qemu/011_run_iso/test.sh | 24 ------------ .../000_qemu/020_build_efi/test.sh | 25 ------------- .../{021_run_efi => 020_run_efi}/test.sh | 14 +++---- .../{020_build_efi => 020_run_efi}/test.yml | 11 ------ .../010_platforms/010_gcp/000_build/test.sh | 27 -------------- .../010_platforms/010_gcp/000_build/test.yml | 34 ----------------- .../010_platforms/010_gcp/001_run/test.sh | 24 ------------ .../{001_hyperkit => 010_hyperkit}/group.sh | 0 .../020_packet/000_build/test.sh | 27 -------------- .../020_packet/000_build/test.yml | 31 ---------------- test/cases/010_platforms/020_vmware/group.sh | 37 +++++++++++++++++++ .../030_vmware/000_build/test.sh | 27 -------------- .../030_vmware/000_build/test.yml | 31 ---------------- .../{020_packet => 100_packet}/group.sh | 2 +- .../{010_gcp => 110_gcp}/group.sh | 2 +- 22 files changed, 97 insertions(+), 370 deletions(-) delete mode 100644 test/cases/010_platforms/000_qemu/000_build/test.sh create mode 100644 test/cases/010_platforms/000_qemu/000_run_kernel/test.sh rename test/cases/010_platforms/000_qemu/{000_build => 000_run_kernel}/test.yml (64%) delete mode 100644 test/cases/010_platforms/000_qemu/001_run/test.sh delete mode 100644 test/cases/010_platforms/000_qemu/010_build_iso/test.sh create mode 100644 test/cases/010_platforms/000_qemu/010_run_iso/test.sh rename test/cases/010_platforms/000_qemu/{010_build_iso => 010_run_iso}/test.yml (64%) delete mode 100644 test/cases/010_platforms/000_qemu/011_run_iso/test.sh delete mode 100644 test/cases/010_platforms/000_qemu/020_build_efi/test.sh rename test/cases/010_platforms/000_qemu/{021_run_efi => 020_run_efi}/test.sh (53%) rename test/cases/010_platforms/000_qemu/{020_build_efi => 020_run_efi}/test.yml (64%) delete mode 100644 test/cases/010_platforms/010_gcp/000_build/test.sh delete mode 100644 test/cases/010_platforms/010_gcp/000_build/test.yml delete mode 100644 test/cases/010_platforms/010_gcp/001_run/test.sh rename test/cases/010_platforms/{001_hyperkit => 010_hyperkit}/group.sh (100%) delete mode 100644 test/cases/010_platforms/020_packet/000_build/test.sh delete mode 100644 test/cases/010_platforms/020_packet/000_build/test.yml create mode 100644 test/cases/010_platforms/020_vmware/group.sh delete mode 100644 test/cases/010_platforms/030_vmware/000_build/test.sh delete mode 100644 test/cases/010_platforms/030_vmware/000_build/test.yml rename test/cases/010_platforms/{020_packet => 100_packet}/group.sh (92%) rename test/cases/010_platforms/{010_gcp => 110_gcp}/group.sh (92%) diff --git a/test/cases/010_platforms/000_qemu/000_build/test.sh b/test/cases/010_platforms/000_qemu/000_build/test.sh deleted file mode 100644 index 1b8a42ebf..000000000 --- a/test/cases/010_platforms/000_qemu/000_build/test.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -# SUMMARY: Test building an image for qemu -# LABELS: build -# AUTHOR: Dave Tucker - -set -e - -# Source libraries. Uncomment if needed/defined -#. "${RT_LIB}" -. "${RT_PROJECT_ROOT}/_lib/lib.sh" - -IMAGE_NAME=test-qemu-build - -clean_up() { - # remove any files, containers, images etc - find . -iname "${IMAGE_NAME}*" -not -iname "*.yml" -exec rm {} \; -} - -trap clean_up EXIT - -# Test code goes here -moby build -name "${IMAGE_NAME}" test.yml -[ -f "${IMAGE_NAME}-kernel" ] || exit 1 -[ -f "${IMAGE_NAME}-initrd.img" ] || exit 1 -[ -f "${IMAGE_NAME}-cmdline" ]|| exit 1 - -find . -iname "${IMAGE_NAME}-*" -exec cp {} "${LINUXKIT_TMPDIR}/{}" \; -exit 0 diff --git a/test/cases/010_platforms/000_qemu/000_run_kernel/test.sh b/test/cases/010_platforms/000_qemu/000_run_kernel/test.sh new file mode 100644 index 000000000..f3f033164 --- /dev/null +++ b/test/cases/010_platforms/000_qemu/000_run_kernel/test.sh @@ -0,0 +1,27 @@ +#!/bin/sh +# SUMMARY: Check that the kernel+initrd image boots in qemu +# LABELS: +# AUTHOR: Dave Tucker +# AUTHOR: Rolf Neugebauer + +set -e + +# Source libraries. Uncomment if needed/defined +#. "${RT_LIB}" +. "${RT_PROJECT_ROOT}/_lib/lib.sh" + +NAME=qemu-kernel + +clean_up() { + # remove any files, containers, images etc + rm -rf "${NAME}*" || true +} + +trap clean_up EXIT + +moby build -name "${NAME}" test.yml +[ -f "${NAME}-kernel" ] || exit 1 +[ -f "${NAME}-initrd.img" ] || exit 1 +[ -f "${NAME}-cmdline" ]|| exit 1 +linuxkit run qemu "${NAME}" | grep -q "Welcome to LinuxKit" +exit 0 diff --git a/test/cases/010_platforms/000_qemu/000_build/test.yml b/test/cases/010_platforms/000_qemu/000_run_kernel/test.yml similarity index 64% rename from test/cases/010_platforms/000_qemu/000_build/test.yml rename to test/cases/010_platforms/000_qemu/000_run_kernel/test.yml index f3d1a822c..6f9b52459 100644 --- a/test/cases/010_platforms/000_qemu/000_build/test.yml +++ b/test/cases/010_platforms/000_qemu/000_run_kernel/test.yml @@ -6,17 +6,6 @@ init: - linuxkit/runc:b0fb122e10dbb7e4e45115177a61a3f8d68c19a9 - linuxkit/containerd:60e2486a74c665ba4df57e561729aec20758daed onboot: - - name: dhcpcd - image: "linuxkit/dhcpcd:8837289b78ecd80f59524883085424e115dd0b3a" - binds: - - /var:/var - - /tmp/etc:/etc - capabilities: - - CAP_NET_ADMIN - - CAP_NET_BIND_SERVICE - - CAP_NET_RAW - net: host - command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"] - name: poweroff image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084" pid: host diff --git a/test/cases/010_platforms/000_qemu/001_run/test.sh b/test/cases/010_platforms/000_qemu/001_run/test.sh deleted file mode 100644 index 4857046f4..000000000 --- a/test/cases/010_platforms/000_qemu/001_run/test.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# SUMMARY: Test running an image with qemu -# LABELS: -# AUTHOR: Dave Tucker - -set -e - -# Source libraries. Uncomment if needed/defined -#. "${RT_LIB}" -. "${RT_PROJECT_ROOT}/_lib/lib.sh" - -IMAGE_NAME=test-qemu-build - -clean_up() { - # remove any files, containers, images etc - rm -rf "${LINUXKIT_TMPDIR:?}/${IMAGE_NAME:?}*" || true -} - -trap clean_up EXIT - -# Test code goes here -[ -f "${LINUXKIT_TMPDIR}/${IMAGE_NAME}-kernel" ] || exit 1 -linuxkit run qemu "${LINUXKIT_TMPDIR}/${IMAGE_NAME}" | grep -q "Welcome to LinuxKit" -exit 0 diff --git a/test/cases/010_platforms/000_qemu/010_build_iso/test.sh b/test/cases/010_platforms/000_qemu/010_build_iso/test.sh deleted file mode 100644 index 8e7f0289b..000000000 --- a/test/cases/010_platforms/000_qemu/010_build_iso/test.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -# SUMMARY: Test building an ISO image for qemu -# LABELS: build -# AUTHOR: Dave Tucker - -set -e - -# Source libraries. Uncomment if needed/defined -#. "${RT_LIB}" -. "${RT_PROJECT_ROOT}/_lib/lib.sh" - -IMAGE_NAME=test-qemu-build - -clean_up() { - # remove any files, containers, images etc - find . -iname "${IMAGE_NAME}*" -not -iname "*.yml" -exec rm {} \; -} - -trap clean_up EXIT - -# Test code goes here -moby build -name "${IMAGE_NAME}" test.yml -[ -f "${IMAGE_NAME}.iso" ] || exit 1 - -cp "${IMAGE_NAME}.iso" "${LINUXKIT_TMPDIR}/" -exit 0 diff --git a/test/cases/010_platforms/000_qemu/010_run_iso/test.sh b/test/cases/010_platforms/000_qemu/010_run_iso/test.sh new file mode 100644 index 000000000..dae34b3d1 --- /dev/null +++ b/test/cases/010_platforms/000_qemu/010_run_iso/test.sh @@ -0,0 +1,24 @@ +#!/bin/sh +# SUMMARY: Check that legacy BIOS ISO boots in qemu +# LABELS: +# AUTHOR: Dave Tucker +# AUTHOR: Rolf Neugebauer + +set -e + +# Source libraries. Uncomment if needed/defined +#. "${RT_LIB}" +. "${RT_PROJECT_ROOT}/_lib/lib.sh" + +NAME=qemu-iso + +clean_up() { + rm -rf "${NAME}*" || true +} + +trap clean_up EXIT + +moby build -name "${NAME}" test.yml +[ -f "${NAME}.iso" ] || exit 1 +linuxkit run qemu -iso "${NAME}" | grep -q "Welcome to LinuxKit" +exit 0 diff --git a/test/cases/010_platforms/000_qemu/010_build_iso/test.yml b/test/cases/010_platforms/000_qemu/010_run_iso/test.yml similarity index 64% rename from test/cases/010_platforms/000_qemu/010_build_iso/test.yml rename to test/cases/010_platforms/000_qemu/010_run_iso/test.yml index 6bb6bdf4f..87c762462 100644 --- a/test/cases/010_platforms/000_qemu/010_build_iso/test.yml +++ b/test/cases/010_platforms/000_qemu/010_run_iso/test.yml @@ -6,17 +6,6 @@ init: - linuxkit/runc:b0fb122e10dbb7e4e45115177a61a3f8d68c19a9 - linuxkit/containerd:60e2486a74c665ba4df57e561729aec20758daed onboot: - - name: dhcpcd - image: "linuxkit/dhcpcd:8837289b78ecd80f59524883085424e115dd0b3a" - binds: - - /var:/var - - /tmp/etc:/etc - capabilities: - - CAP_NET_ADMIN - - CAP_NET_BIND_SERVICE - - CAP_NET_RAW - net: host - command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"] - name: poweroff image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084" pid: host diff --git a/test/cases/010_platforms/000_qemu/011_run_iso/test.sh b/test/cases/010_platforms/000_qemu/011_run_iso/test.sh deleted file mode 100644 index 571a47827..000000000 --- a/test/cases/010_platforms/000_qemu/011_run_iso/test.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# SUMMARY: Test running an ISO image with qemu -# LABELS: -# AUTHOR: Dave Tucker - -set -e - -# Source libraries. Uncomment if needed/defined -#. "${RT_LIB}" -. "${RT_PROJECT_ROOT}/_lib/lib.sh" - -IMAGE_NAME=test-qemu-build - -clean_up() { - # remove any files, containers, images etc - rm -rf "${LINUXKIT_TMPDIR:?}/${IMAGE_NAME:?}*" || true -} - -trap clean_up EXIT - -# Test code goes here -[ -f "${LINUXKIT_TMPDIR}/${IMAGE_NAME}.iso" ] || exit 1 -linuxkit run qemu -iso "${LINUXKIT_TMPDIR}/${IMAGE_NAME}" | grep -q "Welcome to LinuxKit" -exit 0 diff --git a/test/cases/010_platforms/000_qemu/020_build_efi/test.sh b/test/cases/010_platforms/000_qemu/020_build_efi/test.sh deleted file mode 100644 index 763090372..000000000 --- a/test/cases/010_platforms/000_qemu/020_build_efi/test.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# SUMMARY: Test building a UEFI image for qemu -# LABELS: build -# AUTHOR: Dave Tucker - -set -e - -# Source libraries. Uncomment if needed/defined -#. "${RT_LIB}" -. "${RT_PROJECT_ROOT}/_lib/lib.sh" - -IMAGE_NAME=test-qemu-build - -clean_up() { - # remove any files, containers, images etc - find . -iname "${IMAGE_NAME}*" -not -iname "*.yml" -exec rm {} \; -} - -trap clean_up EXIT - -# Test code goes here -moby build -name "${IMAGE_NAME}" test.yml -[ -f "${IMAGE_NAME}-efi.iso" ] || exit 1 -cp "${IMAGE_NAME}-efi.iso" "${LINUXKIT_TMPDIR}/" -exit 0 diff --git a/test/cases/010_platforms/000_qemu/021_run_efi/test.sh b/test/cases/010_platforms/000_qemu/020_run_efi/test.sh similarity index 53% rename from test/cases/010_platforms/000_qemu/021_run_efi/test.sh rename to test/cases/010_platforms/000_qemu/020_run_efi/test.sh index 6b02ce3e4..4bef989cd 100644 --- a/test/cases/010_platforms/000_qemu/021_run_efi/test.sh +++ b/test/cases/010_platforms/000_qemu/020_run_efi/test.sh @@ -1,7 +1,8 @@ #!/bin/sh -# SUMMARY: Test running a UEFI image with qemu +# SUMMARY: Check that legacy BIOS ISO boots in qemu # LABELS: # AUTHOR: Dave Tucker +# AUTHOR: Rolf Neugebauer set -e @@ -9,11 +10,11 @@ set -e #. "${RT_LIB}" . "${RT_PROJECT_ROOT}/_lib/lib.sh" -IMAGE_NAME=test-qemu-build +NAME=qemu-efi clean_up() { # remove any files, containers, images etc - rm -rf "${LINUXKIT_TMPDIR:?}/${IMAGE_NAME:?}*" || true + rm -rf "${NAME}*" || true } trap clean_up EXIT @@ -24,8 +25,7 @@ if command -v qemu; then fi fi - -# Test code goes here -[ -f "${LINUXKIT_TMPDIR}/${IMAGE_NAME}-efi.iso" ] || exit 1 -linuxkit run qemu -uefi "${LINUXKIT_TMPDIR}/${IMAGE_NAME}" | grep -q "Welcome to LinuxKit" +moby build -name "${NAME}" test.yml +[ -f "${NAME}-efi.iso" ] || exit 1 +linuxkit run qemu -uefi "${NAME}" | grep -q "Welcome to LinuxKit" exit 0 diff --git a/test/cases/010_platforms/000_qemu/020_build_efi/test.yml b/test/cases/010_platforms/000_qemu/020_run_efi/test.yml similarity index 64% rename from test/cases/010_platforms/000_qemu/020_build_efi/test.yml rename to test/cases/010_platforms/000_qemu/020_run_efi/test.yml index 5e6aecb10..8153330ba 100644 --- a/test/cases/010_platforms/000_qemu/020_build_efi/test.yml +++ b/test/cases/010_platforms/000_qemu/020_run_efi/test.yml @@ -6,17 +6,6 @@ init: - linuxkit/runc:b0fb122e10dbb7e4e45115177a61a3f8d68c19a9 - linuxkit/containerd:60e2486a74c665ba4df57e561729aec20758daed onboot: - - name: dhcpcd - image: "linuxkit/dhcpcd:8837289b78ecd80f59524883085424e115dd0b3a" - binds: - - /var:/var - - /tmp/etc:/etc - capabilities: - - CAP_NET_ADMIN - - CAP_NET_BIND_SERVICE - - CAP_NET_RAW - net: host - command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"] - name: poweroff image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084" pid: host diff --git a/test/cases/010_platforms/010_gcp/000_build/test.sh b/test/cases/010_platforms/010_gcp/000_build/test.sh deleted file mode 100644 index 9f847a26c..000000000 --- a/test/cases/010_platforms/010_gcp/000_build/test.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# SUMMARY: Test building an image for GCP -# LABELS: build -# AUTHOR: Dave Tucker - -set -e - -# Source libraries. Uncomment if needed/defined -#. "${RT_LIB}" -. "${RT_PROJECT_ROOT}/_lib/lib.sh" - -IMAGE_NAME=gcp - -clean_up() { - # remove any files, containers, images etc - rm -rf ${IMAGE_NAME}* -} - -trap clean_up EXIT - -# Test code goes here -moby build -name "${IMAGE_NAME}" test.yml -[ -f "${IMAGE_NAME}.img.tar.gz" ] || exit 1 -# As build and run on different machines, copy to the artifacts directory -cp -f "${IMAGE_NAME}.img.tar.gz" "${LINUXKIT_ARTIFACTS_DIR}/test.img.tar.gz" - -exit 0 diff --git a/test/cases/010_platforms/010_gcp/000_build/test.yml b/test/cases/010_platforms/010_gcp/000_build/test.yml deleted file mode 100644 index f807e78f4..000000000 --- a/test/cases/010_platforms/010_gcp/000_build/test.yml +++ /dev/null @@ -1,34 +0,0 @@ -# FIXME: This should use the minimal example -# We continue to use the kernel-config-test as CI is currently expecting to see a success message -kernel: - image: "linuxkit/kernel:4.9.x" - cmdline: "console=ttyS0" -init: - - linuxkit/init:deea956a9ab07bf262083e93a86930bdc610cc2f - - linuxkit/runc:2649198589ef0020d99f613adaeda45ce0093a38 - - linuxkit/containerd:cf2614f5a96c569a0bd4bd54e054a65ba17d167f - - linuxkit/ca-certificates:3344cdca1bc59fdfa17bd7f0fcbf491b9dbaa288 -onboot: - - name: dhcpcd - image: "linuxkit/dhcpcd:2def74ab3f9233b4c09ebb196ba47c27c08b0ed8" - binds: - - /var:/var - - /tmp:/etc - capabilities: - - CAP_NET_ADMIN - - CAP_NET_BIND_SERVICE - - CAP_NET_RAW - net: host - command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"] - - name: check-kernel-config - image: "linuxkit/test-kernel-config:ecff41279ccbc408079a3996a956432651c6eb9c" - readonly: true - - name: poweroff - image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084" - pid: host - command: ["/bin/sh", "/poweroff.sh", "3"] - capabilities: - - CAP_SYS_BOOT - readonly: true -outputs: - - format: gcp-img diff --git a/test/cases/010_platforms/010_gcp/001_run/test.sh b/test/cases/010_platforms/010_gcp/001_run/test.sh deleted file mode 100644 index 5779c0aee..000000000 --- a/test/cases/010_platforms/010_gcp/001_run/test.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -# SUMMARY: Test running an image with qemu -# LABELS: gcp -# AUTHOR: Dave Tucker - -set -e - -# Source libraries. Uncomment if needed/defined -#. "${RT_LIB}" -. "${RT_PROJECT_ROOT}/_lib/lib.sh" - -IMAGE_NAME=test - -clean_up() { - # remove any files, containers, images etc - echo "Nothing to cleanup..." -} - -trap clean_up EXIT - -# Test code goes here -[ -f "${LINUXKIT_ARTIFACTS_DIR}/${IMAGE_NAME}.img.tar.gz" ] || exit 1 -linuxkit run gcp "${LINUXKIT_ARTIFACTS_DIR}/${IMAGE_NAME}" | grep -q "Welcome to LinuxKit" -exit 0 diff --git a/test/cases/010_platforms/001_hyperkit/group.sh b/test/cases/010_platforms/010_hyperkit/group.sh similarity index 100% rename from test/cases/010_platforms/001_hyperkit/group.sh rename to test/cases/010_platforms/010_hyperkit/group.sh diff --git a/test/cases/010_platforms/020_packet/000_build/test.sh b/test/cases/010_platforms/020_packet/000_build/test.sh deleted file mode 100644 index 0fd2c1018..000000000 --- a/test/cases/010_platforms/020_packet/000_build/test.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# SUMMARY: Test building an image for packet.net -# LABELS: build -# AUTHOR: Dave Tucker - -set -e - -# Source libraries. Uncomment if needed/defined -#. "${RT_LIB}" -. "${RT_PROJECT_ROOT}/_lib/lib.sh" - -IMAGE_NAME=packet - -clean_up() { - # remove any files, containers, images etc - rm -rf ${IMAGE_NAME}* -} - -trap clean_up EXIT - -# Test code goes here -moby build --name "${IMAGE_NAME}" test.yml -[ -f "${IMAGE_NAME}-kernel" ] || exit 1 - -# As build and run on different machines, copy to the artifacts directory -find . -iname "${IMAGE_NAME}-*" -exec cp {} "${LINUXKIT_ARTFACTS_DIR}/{}" \; -exit 0 diff --git a/test/cases/010_platforms/020_packet/000_build/test.yml b/test/cases/010_platforms/020_packet/000_build/test.yml deleted file mode 100644 index f3d1a822c..000000000 --- a/test/cases/010_platforms/020_packet/000_build/test.yml +++ /dev/null @@ -1,31 +0,0 @@ -kernel: - image: "linuxkit/kernel:4.9.x" - cmdline: "console=ttyS0 console=tty0 page_poison=1" -init: - - linuxkit/init:f71c3b30ac1ba4ef16c160c89610fa4976f9752f - - linuxkit/runc:b0fb122e10dbb7e4e45115177a61a3f8d68c19a9 - - linuxkit/containerd:60e2486a74c665ba4df57e561729aec20758daed -onboot: - - name: dhcpcd - image: "linuxkit/dhcpcd:8837289b78ecd80f59524883085424e115dd0b3a" - binds: - - /var:/var - - /tmp/etc:/etc - capabilities: - - CAP_NET_ADMIN - - CAP_NET_BIND_SERVICE - - CAP_NET_RAW - net: host - command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"] - - name: poweroff - image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084" - pid: host - command: ["/bin/sh", "/poweroff.sh", "10"] - capabilities: - - CAP_SYS_BOOT - readonly: true -trust: - image: - - linuxkit/kernel -outputs: - - format: kernel+initrd diff --git a/test/cases/010_platforms/020_vmware/group.sh b/test/cases/010_platforms/020_vmware/group.sh new file mode 100644 index 000000000..47ce7b26e --- /dev/null +++ b/test/cases/010_platforms/020_vmware/group.sh @@ -0,0 +1,37 @@ +#!/bin/sh +# SUMMARY: LinuxKit VMware tests +# LABELS: darwin +# For the top level group.sh also specify a 'NAME:' comment + +# Source libraries. Uncomment if needed/defined +#. "${RT_LIB}" +#. "${RT_PROJECT_ROOT}/_lib/lib.sh" + + +group_init() { + # Group initialisation code goes here + return 0 +} + +group_deinit() { + # Group de-initialisation code goes here + return 0 +} + +CMD=$1 +case $CMD in +init) + group_init + res=$? + ;; +deinit) + group_deinit + res=$? + ;; +*) + res=1 + ;; +esac + +exit $res + diff --git a/test/cases/010_platforms/030_vmware/000_build/test.sh b/test/cases/010_platforms/030_vmware/000_build/test.sh deleted file mode 100644 index c3c66d854..000000000 --- a/test/cases/010_platforms/030_vmware/000_build/test.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# SUMMARY: Test building an image for VMware -# LABELS: build -# AUTHOR: Dave Tucker - -set -e - -# Source libraries. Uncomment if needed/defined -#. "${RT_LIB}" -. "${RT_PROJECT_ROOT}/_lib/lib.sh" - -IMAGE_NAME=vmware - -clean_up() { - # remove any files, containers, images etc - rm -rf ${IMAGE_NAME}* -} - -trap clean_up EXIT - -# Test code goes here -moby build --name "${IMAGE_NAME}" test.yml -[ -f "${IMAGE_NAME}.vmdk" ] || exit 1 -# As build and run on different machines, copy to the artifacts directory -cp "${IMAGE_NAME}.vmdk" "${LINUXKIT_ARTIFACTS_DIR}/" -exit 0 - diff --git a/test/cases/010_platforms/030_vmware/000_build/test.yml b/test/cases/010_platforms/030_vmware/000_build/test.yml deleted file mode 100644 index 008a49ddb..000000000 --- a/test/cases/010_platforms/030_vmware/000_build/test.yml +++ /dev/null @@ -1,31 +0,0 @@ -kernel: - image: "linuxkit/kernel:4.9.x" - cmdline: "console=ttyS0 console=tty0 page_poison=1" -init: - - linuxkit/init:f71c3b30ac1ba4ef16c160c89610fa4976f9752f - - linuxkit/runc:b0fb122e10dbb7e4e45115177a61a3f8d68c19a9 - - linuxkit/containerd:60e2486a74c665ba4df57e561729aec20758daed -onboot: - - name: dhcpcd - image: "linuxkit/dhcpcd:8837289b78ecd80f59524883085424e115dd0b3a" - binds: - - /var:/var - - /tmp/etc:/etc - capabilities: - - CAP_NET_ADMIN - - CAP_NET_BIND_SERVICE - - CAP_NET_RAW - net: host - command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"] - - name: poweroff - image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084" - pid: host - command: ["/bin/sh", "/poweroff.sh", "10"] - capabilities: - - CAP_SYS_BOOT - readonly: true -trust: - image: - - linuxkit/kernel -outputs: - - format: vmdk diff --git a/test/cases/010_platforms/020_packet/group.sh b/test/cases/010_platforms/100_packet/group.sh similarity index 92% rename from test/cases/010_platforms/020_packet/group.sh rename to test/cases/010_platforms/100_packet/group.sh index d9b73eb99..8270c115e 100644 --- a/test/cases/010_platforms/020_packet/group.sh +++ b/test/cases/010_platforms/100_packet/group.sh @@ -1,5 +1,5 @@ #!/bin/sh -# SUMMARY: LinuxKit configuration tests +# SUMMARY: LinuxKit packet.net tests # LABELS: # For the top level group.sh also specify a 'NAME:' comment diff --git a/test/cases/010_platforms/010_gcp/group.sh b/test/cases/010_platforms/110_gcp/group.sh similarity index 92% rename from test/cases/010_platforms/010_gcp/group.sh rename to test/cases/010_platforms/110_gcp/group.sh index d9b73eb99..0b90c45f3 100644 --- a/test/cases/010_platforms/010_gcp/group.sh +++ b/test/cases/010_platforms/110_gcp/group.sh @@ -1,5 +1,5 @@ #!/bin/sh -# SUMMARY: LinuxKit configuration tests +# SUMMARY: LinuxKit Google Cloud tests # LABELS: # For the top level group.sh also specify a 'NAME:' comment From 316a40f20a18413dcb141328d93264ded6e36762 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Tue, 16 May 2017 11:03:51 +0100 Subject: [PATCH 4/9] tests: Sanity check when we run GCP tests Signed-off-by: Rolf Neugebauer --- test/cases/group.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/cases/group.sh b/test/cases/group.sh index 6a22618f8..5dfdb80e0 100644 --- a/test/cases/group.sh +++ b/test/cases/group.sh @@ -1,7 +1,6 @@ #!/bin/sh # NAME: linuxkit # SUMMARY: LinuxKit Regression Tests -# LABELS: # Source libraries. Uncomment if needed/defined # . "${RT_LIB}" @@ -14,6 +13,15 @@ group_init() { [ -r "${LINUXKIT_ARTIFACTS_DIR}" ] && rm -rf "${LINUXKIT_ARTIFACTS_DIR}" mkdir "${LINUXKIT_ARTIFACTS_DIR}" echo "export LINUXKIT_EXAMPLES_DIR=${RT_PROJECT_ROOT}/../../examples" >> "${LINUXKIT_TMPDIR}/env.sh" + + if rt_label_set "gcp"; then + # If we run GCP tests, make sure it is configured + if [ -z "${CLOUDSDK_CORE_PROJECT}" ]; then + echo "GCP does not seem to be configured" + return 1 + fi + fi + return 0 } From 188ee6d226342b36ff101fa1a0acdd29f5bd8eba Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Tue, 16 May 2017 11:39:39 +0100 Subject: [PATCH 5/9] tests: Delete README.md. It contained mostly inaccurate information This should be replaced with more comprehensive documentation in ./doc/testing.md once the CI is fixed Signed-off-by: Rolf Neugebauer --- test/README.md | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 test/README.md diff --git a/test/README.md b/test/README.md deleted file mode 100644 index 48e48ce25..000000000 --- a/test/README.md +++ /dev/null @@ -1,19 +0,0 @@ -Linuxkit Tests Labels -===================== - -## Usage of Artifacts vs Temporary Directory - -As the Build Machines have no secrets they will not be able to test running the build output on any cloud providers. -In this instance, the build tests should copy their output to the `LINUXKIT_ARTIFACTS_DIRECTORY` - -## Labels - -The `gcp` label is applied when the system where the tests are being run meets the requirements for using Google Cloud Platform. - -These requirements are: -- The system has the necessary `CLOUDSDK_*` environment variables exported -- The system has either keys for a GCP service account or is able to use application default credentials - -The `packet.net` label is applied when a system is able to create machines on Packet.net - -The `vmware` label is used when the machine has VMware Workstation or Fusion installed From 509be016d20db246366bfcb3b1d0cdac7341faa4 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Tue, 16 May 2017 11:42:14 +0100 Subject: [PATCH 6/9] tests: Remove LINUXKIT_ARTIFACTS_DIR from tests This was a hack in the first place and will be replaced by another, more obvious hack in the next commit. Signed-off-by: Rolf Neugebauer --- test/cases/_lib/lib.sh | 1 - test/cases/group.sh | 2 -- 2 files changed, 3 deletions(-) diff --git a/test/cases/_lib/lib.sh b/test/cases/_lib/lib.sh index 500ace37d..cf9c34757 100644 --- a/test/cases/_lib/lib.sh +++ b/test/cases/_lib/lib.sh @@ -5,7 +5,6 @@ # Temporary directory for tests to use. LINUXKIT_TMPDIR="${RT_PROJECT_ROOT}/_tmp" -LINUXKIT_ARTIFACTS_DIR="${RT_PROJECT_ROOT}/../../artifacts" # The top-level group.sh of the project creates a env.sh file # containing environment variables for tests. Source it if present. diff --git a/test/cases/group.sh b/test/cases/group.sh index 5dfdb80e0..732805cec 100644 --- a/test/cases/group.sh +++ b/test/cases/group.sh @@ -10,8 +10,6 @@ group_init() { # Group initialisation code goes here [ -r "${LINUXKIT_TMPDIR}" ] && rm -rf "${LINUXKIT_TMPDIR}" mkdir "${LINUXKIT_TMPDIR}" - [ -r "${LINUXKIT_ARTIFACTS_DIR}" ] && rm -rf "${LINUXKIT_ARTIFACTS_DIR}" - mkdir "${LINUXKIT_ARTIFACTS_DIR}" echo "export LINUXKIT_EXAMPLES_DIR=${RT_PROJECT_ROOT}/../../examples" >> "${LINUXKIT_TMPDIR}/env.sh" if rt_label_set "gcp"; then From b03beb94efde18c749c2bcb888f6176ab657fd8c Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Tue, 16 May 2017 12:02:07 +0100 Subject: [PATCH 7/9] tests: Add back the hack for running tests on GCP These tests should be run via rtf but currently are run via linuxkit-ci. This is a hack and hopefully is now marked more clearly as such. Signed-off-by: Rolf Neugebauer --- test/Makefile | 20 +++++++++++++------- test/hack/test-ltp.yml | 28 ++++++++++++++++++++++++++++ test/hack/test.yml | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 7 deletions(-) create mode 100644 test/hack/test-ltp.yml create mode 100644 test/hack/test.yml diff --git a/test/Makefile b/test/Makefile index e8690bee7..e045f3e5b 100644 --- a/test/Makefile +++ b/test/Makefile @@ -2,7 +2,7 @@ default: check-deps test pr: check-deps test-pr -# TODO: all should point to test-all once ltp is no longer required +# TODO: should have a separate target all: check-deps test-pr ltp MOBY:=$(shell command -v moby 2> /dev/null) @@ -24,6 +24,15 @@ endif # TODO: Remove this section once we no longer depend on this in CI ### ------- +# Currently the linuxkit-ci runs GCP tests outside of rtf and expects some +# files in ../artifacts. This hacky target puts them there until +# the CI can use rtf for running GCP tests +gcp-hack: ../artifacts/test.img.tar.gz +../artifacts/test.img.tar.gz: + rm -rf ../artifacts + mkdir -p ../artifacts + $(MOBY) build --pull -name ../artifacts/test hack/test.yml + define check_test_log @cat $1 |grep -q 'test suite PASSED' endef @@ -31,17 +40,14 @@ endef .PHONY: ltp ltp: export CLOUDSDK_IMAGE_NAME?=test-ltp ltp: $(LINUXKIT) test-ltp.img.tar.gz - $(MOBY) build --pull cases/020_stress/000_ltp/test-ltp.yml + $(MOBY) build --pull hack/test-ltp.yml $(LINUXKIT) push gcp test-ltp.img.tar.gz $(LINUXKIT) run gcp -skip-cleanup -machine n1-highcpu-4 $(CLOUDSDK_IMAGE_NAME) | tee test-ltp.log $(call check_test_log, test-ltp.log) ### ------ -test: +test: gcp-hack @rtf -l build -x run -test-pr: +test-pr: gcp-hack @rtf -vvv -l build -x run - -test-all: - @rtf -vvv -x -l build,slow run diff --git a/test/hack/test-ltp.yml b/test/hack/test-ltp.yml new file mode 100644 index 000000000..c47555f88 --- /dev/null +++ b/test/hack/test-ltp.yml @@ -0,0 +1,28 @@ +kernel: + image: "linuxkit/kernel:4.9.x" + cmdline: "console=ttyS0" +init: + - linuxkit/init:b3740303f3d1e5689a84c87b7dfb48fd2a40a192 + - linuxkit/runc:47b1c38d63468c0f3078f8b1b055d07965a1895d + - linuxkit/containerd:cf2614f5a96c569a0bd4bd54e054a65ba17d167f + - linuxkit/ca-certificates:3344cdca1bc59fdfa17bd7f0fcbf491b9dbaa288 +onboot: + - name: ltp + image: "linuxkit/test-ltp-20170116:81229df2d25065b06f0a3071faaace8d66c87e67" + net: host + pid: host + binds: + - /etc/ltp/baseline:/etc/ltp/baseline + capabilities: + - all + - name: poweroff + image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084" + pid: host + capabilities: + - CAP_SYS_BOOT + readonly: true +files: + - path: /etc/ltp/baseline + contents: "100" +outputs: + - format: gcp-img diff --git a/test/hack/test.yml b/test/hack/test.yml new file mode 100644 index 000000000..f807e78f4 --- /dev/null +++ b/test/hack/test.yml @@ -0,0 +1,34 @@ +# FIXME: This should use the minimal example +# We continue to use the kernel-config-test as CI is currently expecting to see a success message +kernel: + image: "linuxkit/kernel:4.9.x" + cmdline: "console=ttyS0" +init: + - linuxkit/init:deea956a9ab07bf262083e93a86930bdc610cc2f + - linuxkit/runc:2649198589ef0020d99f613adaeda45ce0093a38 + - linuxkit/containerd:cf2614f5a96c569a0bd4bd54e054a65ba17d167f + - linuxkit/ca-certificates:3344cdca1bc59fdfa17bd7f0fcbf491b9dbaa288 +onboot: + - name: dhcpcd + image: "linuxkit/dhcpcd:2def74ab3f9233b4c09ebb196ba47c27c08b0ed8" + binds: + - /var:/var + - /tmp:/etc + capabilities: + - CAP_NET_ADMIN + - CAP_NET_BIND_SERVICE + - CAP_NET_RAW + net: host + command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"] + - name: check-kernel-config + image: "linuxkit/test-kernel-config:ecff41279ccbc408079a3996a956432651c6eb9c" + readonly: true + - name: poweroff + image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084" + pid: host + command: ["/bin/sh", "/poweroff.sh", "3"] + capabilities: + - CAP_SYS_BOOT + readonly: true +outputs: + - format: gcp-img From 6fbbb4d7561a4f9d0dea6c3ddf2a5602b5d33aeb Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Tue, 16 May 2017 12:19:31 +0100 Subject: [PATCH 8/9] test: Don't run 'rtf' in verbose mode The detailed logs should be gathered by linuxkit-ci and having the default output makes it easier to spot which test failed. Signed-off-by: Rolf Neugebauer --- test/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index e045f3e5b..b4943e997 100644 --- a/test/Makefile +++ b/test/Makefile @@ -50,4 +50,4 @@ test: gcp-hack @rtf -l build -x run test-pr: gcp-hack - @rtf -vvv -l build -x run + @rtf -l build -x run From cd354c2ab132139bb06fcb6c9b6bb7005f63e3f3 Mon Sep 17 00:00:00 2001 From: Rolf Neugebauer Date: Tue, 16 May 2017 15:52:08 +0100 Subject: [PATCH 9/9] docs: Improve testing.md - Add 'rtf list' - Add section about test logs - Fis a few typos Signed-off-by: Rolf Neugebauer --- docs/testing.md | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/docs/testing.md b/docs/testing.md index 5b5af62a6..5060a8ac0 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -24,10 +24,18 @@ To run add a label you may use: rtf -x -l slow run ``` -To run tests that match the pattern `linuxkit.examples` you would use the following command: +You can list the tests which will be run using: ``` -rtf -x run linuxkit.examples +rtf list +``` + +Some tests may be marked as `SKIP` and `LABELS` column will typically provide and indication as to why a test may be skipped. + +To run tests that match the pattern `linuxkit.build` you would use the following command: + +``` +rtf -x run linuxkit.build ``` ### Writing new tests @@ -41,7 +49,7 @@ If you feel that a new group is warranted you can create one by `mkdir 000_name` You must copy an existing `group.sh` in to this folder and adjust as required or you may use the [example](https://github.com/linuxkit/rtf/tree/master/etc/templates/group.sh) -To write your test, create a folder within the group using the `000_name` format as described aboce. +To write your test, create a folder within the group using the `000_name` format as described above. You should then copy an existing `test.sh` in to this directory and amdend it, or start from an [example](http://github.com/linuxkit/rtf/tree/master/etc/templates/test.sh) @@ -50,9 +58,13 @@ avoid it being run by default and document the use of the label in `tests/README ## Continuous Integration -The LiunxKit CI system uses [DatakitCI](https://github.com/moby/datakit/tree/master/ci) +*Note: This will hopefully change significantly soon* + +The LinuxKit CI system uses [DatakitCI](https://github.com/moby/datakit/tree/master/ci) The configuration can be found [here](https://github.com/linuxkit/linuxkit-ci) +The test logs are available via the `Details` link but also via this [website](https://linuxkit.datakit.ci). The raw test logs are also stored on [GitHub](https://github.com/linuxkit/linuxkit-logs) where each branch contains the results for a particular run. + ## PR Testing Each PR is tested on disposable VM's spawned in Google Cloud Platform @@ -61,9 +73,9 @@ This machine has no privileges or credentials to talk to GCP or other cloud plat TODO: Add instructions on how to build a base image for LinuxKit CI in GCP. LinuxKit CI runs `make ci-pr` in the VM. -This target runs the tests using `rtf` and the results directory is SCP'd back to the controller. +This target runs the tests using `rtf` and the results directory is `scp`'ed back to the controller. The test results will be stored in DataKit for additional access -Additionally a the `./artifacts` folder is SCP'd back to the controller. +Additionally, the `./artifacts` folder is `scp`'ed back to the controller. If the tests passed the next step is to check if the kernel config test image runs on GCP. The `./artifacts/test.img.tar.gz` file is used to create a GCP image by the Python scripts