From 05767273f3ceb2be00da5f85b88033d8404f64ff Mon Sep 17 00:00:00 2001 From: Dave Tucker Date: Wed, 12 Apr 2017 11:20:11 +0100 Subject: [PATCH 1/4] tests: cleanup test directory - add a `pkg` directory for packages - add a `cases` directory for yml files Signed-off-by: Dave Tucker --- test/{docker-bench => cases}/test-docker-bench.yml | 0 test/{test.yml => cases/test-kernel-config.yml} | 4 ++-- test/{ltp => cases}/test-ltp.yml | 0 test/{virtsock => cases}/test-virtsock-server.yml | 0 test/{ => pkg}/docker-bench/Dockerfile | 0 test/{ => pkg}/docker-bench/Makefile | 0 test/{ => pkg}/docker-bench/bench_runner.sh | 0 test/{check => pkg/kernel-config}/Dockerfile | 0 test/{check => pkg/kernel-config}/Makefile | 2 +- test/{check => pkg/kernel-config}/check-kernel-config.sh | 0 test/{check => pkg/kernel-config}/check.sh | 0 test/{check => pkg/kernel-config}/etc/linuxkit | 0 test/{ => pkg}/ltp/.gitignore | 0 test/{ => pkg}/ltp/Dockerfile.build | 0 test/{ => pkg}/ltp/Dockerfile.pkg | 0 test/{ => pkg}/ltp/Makefile | 0 test/{ => pkg}/ltp/README.md | 0 test/{ => pkg}/ltp/check.sh | 0 test/{ => pkg}/poweroff/Dockerfile | 0 test/{ => pkg}/poweroff/Makefile | 0 test/{ => pkg}/poweroff/poweroff.sh | 0 test/{ => pkg}/virtsock/.gitignore | 0 test/{ => pkg}/virtsock/Dockerfile | 0 test/{ => pkg}/virtsock/Makefile | 0 test/{ => pkg}/virtsock/README.md | 4 ++-- 25 files changed, 5 insertions(+), 5 deletions(-) rename test/{docker-bench => cases}/test-docker-bench.yml (100%) rename test/{test.yml => cases/test-kernel-config.yml} (88%) rename test/{ltp => cases}/test-ltp.yml (100%) rename test/{virtsock => cases}/test-virtsock-server.yml (100%) rename test/{ => pkg}/docker-bench/Dockerfile (100%) rename test/{ => pkg}/docker-bench/Makefile (100%) rename test/{ => pkg}/docker-bench/bench_runner.sh (100%) rename test/{check => pkg/kernel-config}/Dockerfile (100%) rename test/{check => pkg/kernel-config}/Makefile (97%) rename test/{check => pkg/kernel-config}/check-kernel-config.sh (100%) rename test/{check => pkg/kernel-config}/check.sh (100%) rename test/{check => pkg/kernel-config}/etc/linuxkit (100%) rename test/{ => pkg}/ltp/.gitignore (100%) rename test/{ => pkg}/ltp/Dockerfile.build (100%) rename test/{ => pkg}/ltp/Dockerfile.pkg (100%) rename test/{ => pkg}/ltp/Makefile (100%) rename test/{ => pkg}/ltp/README.md (100%) rename test/{ => pkg}/ltp/check.sh (100%) rename test/{ => pkg}/poweroff/Dockerfile (100%) rename test/{ => pkg}/poweroff/Makefile (100%) rename test/{ => pkg}/poweroff/poweroff.sh (100%) rename test/{ => pkg}/virtsock/.gitignore (100%) rename test/{ => pkg}/virtsock/Dockerfile (100%) rename test/{ => pkg}/virtsock/Makefile (100%) rename test/{ => pkg}/virtsock/README.md (85%) diff --git a/test/docker-bench/test-docker-bench.yml b/test/cases/test-docker-bench.yml similarity index 100% rename from test/docker-bench/test-docker-bench.yml rename to test/cases/test-docker-bench.yml diff --git a/test/test.yml b/test/cases/test-kernel-config.yml similarity index 88% rename from test/test.yml rename to test/cases/test-kernel-config.yml index 4412a9302..24ef97b21 100644 --- a/test/test.yml +++ b/test/cases/test-kernel-config.yml @@ -18,8 +18,8 @@ onboot: - CAP_NET_RAW net: host command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"] - - name: check - image: "linuxkit/check:43c4147dda4e02d066ef158cd81718dbff8c8bd0" + - name: check-kernel-config + image: "mobylinux/kernel-config:c9e41ab96b3ea6a3ced97634751e20d12a5bf52f" pid: host capabilities: - CAP_SYS_BOOT diff --git a/test/ltp/test-ltp.yml b/test/cases/test-ltp.yml similarity index 100% rename from test/ltp/test-ltp.yml rename to test/cases/test-ltp.yml diff --git a/test/virtsock/test-virtsock-server.yml b/test/cases/test-virtsock-server.yml similarity index 100% rename from test/virtsock/test-virtsock-server.yml rename to test/cases/test-virtsock-server.yml diff --git a/test/docker-bench/Dockerfile b/test/pkg/docker-bench/Dockerfile similarity index 100% rename from test/docker-bench/Dockerfile rename to test/pkg/docker-bench/Dockerfile diff --git a/test/docker-bench/Makefile b/test/pkg/docker-bench/Makefile similarity index 100% rename from test/docker-bench/Makefile rename to test/pkg/docker-bench/Makefile diff --git a/test/docker-bench/bench_runner.sh b/test/pkg/docker-bench/bench_runner.sh similarity index 100% rename from test/docker-bench/bench_runner.sh rename to test/pkg/docker-bench/bench_runner.sh diff --git a/test/check/Dockerfile b/test/pkg/kernel-config/Dockerfile similarity index 100% rename from test/check/Dockerfile rename to test/pkg/kernel-config/Dockerfile diff --git a/test/check/Makefile b/test/pkg/kernel-config/Makefile similarity index 97% rename from test/check/Makefile rename to test/pkg/kernel-config/Makefile index de24bfc86..96d172c7a 100644 --- a/test/check/Makefile +++ b/test/pkg/kernel-config/Makefile @@ -1,7 +1,7 @@ .PHONY: tag push BASE=alpine:3.5 -IMAGE=check +IMAGE=kernel-config default: push diff --git a/test/check/check-kernel-config.sh b/test/pkg/kernel-config/check-kernel-config.sh similarity index 100% rename from test/check/check-kernel-config.sh rename to test/pkg/kernel-config/check-kernel-config.sh diff --git a/test/check/check.sh b/test/pkg/kernel-config/check.sh similarity index 100% rename from test/check/check.sh rename to test/pkg/kernel-config/check.sh diff --git a/test/check/etc/linuxkit b/test/pkg/kernel-config/etc/linuxkit similarity index 100% rename from test/check/etc/linuxkit rename to test/pkg/kernel-config/etc/linuxkit diff --git a/test/ltp/.gitignore b/test/pkg/ltp/.gitignore similarity index 100% rename from test/ltp/.gitignore rename to test/pkg/ltp/.gitignore diff --git a/test/ltp/Dockerfile.build b/test/pkg/ltp/Dockerfile.build similarity index 100% rename from test/ltp/Dockerfile.build rename to test/pkg/ltp/Dockerfile.build diff --git a/test/ltp/Dockerfile.pkg b/test/pkg/ltp/Dockerfile.pkg similarity index 100% rename from test/ltp/Dockerfile.pkg rename to test/pkg/ltp/Dockerfile.pkg diff --git a/test/ltp/Makefile b/test/pkg/ltp/Makefile similarity index 100% rename from test/ltp/Makefile rename to test/pkg/ltp/Makefile diff --git a/test/ltp/README.md b/test/pkg/ltp/README.md similarity index 100% rename from test/ltp/README.md rename to test/pkg/ltp/README.md diff --git a/test/ltp/check.sh b/test/pkg/ltp/check.sh similarity index 100% rename from test/ltp/check.sh rename to test/pkg/ltp/check.sh diff --git a/test/poweroff/Dockerfile b/test/pkg/poweroff/Dockerfile similarity index 100% rename from test/poweroff/Dockerfile rename to test/pkg/poweroff/Dockerfile diff --git a/test/poweroff/Makefile b/test/pkg/poweroff/Makefile similarity index 100% rename from test/poweroff/Makefile rename to test/pkg/poweroff/Makefile diff --git a/test/poweroff/poweroff.sh b/test/pkg/poweroff/poweroff.sh similarity index 100% rename from test/poweroff/poweroff.sh rename to test/pkg/poweroff/poweroff.sh diff --git a/test/virtsock/.gitignore b/test/pkg/virtsock/.gitignore similarity index 100% rename from test/virtsock/.gitignore rename to test/pkg/virtsock/.gitignore diff --git a/test/virtsock/Dockerfile b/test/pkg/virtsock/Dockerfile similarity index 100% rename from test/virtsock/Dockerfile rename to test/pkg/virtsock/Dockerfile diff --git a/test/virtsock/Makefile b/test/pkg/virtsock/Makefile similarity index 100% rename from test/virtsock/Makefile rename to test/pkg/virtsock/Makefile diff --git a/test/virtsock/README.md b/test/pkg/virtsock/README.md similarity index 85% rename from test/virtsock/README.md rename to test/pkg/virtsock/README.md index 9b132f87d..7d7f41297 100644 --- a/test/virtsock/README.md +++ b/test/pkg/virtsock/README.md @@ -1,11 +1,11 @@ This directory contains the files to build and run a container containing the -virtio and Hyper-V socket stress tests. `test-virtsock-server.yml` builds images which start the server inside the VM. +virtio and Hyper-V socket stress tests. `../../cases/test-virtsock-server.yml` builds images which start the server inside the VM. The client, to be run on the host as per this [README](https://github.com/rneugeba/virtsock/blob/master/examples/README.md), can be obtained compiled from [here](https://github.com/rneugeba/virtsock). ## How to use (on Windows) -- Build the images: `moby build test-virtsock-server` +- Build the images: `moby build tests/cases/test-virtsock-server.yml` - Copy the `test-virtsock-server.iso` to a Windows system - Create a Type 1 Hyper-V VM (called `virtsock`). - No Disk or network required From fb4d6218336fe7c2dfcbb8f52c9af331a02ab9a6 Mon Sep 17 00:00:00 2001 From: Dave Tucker Date: Wed, 12 Apr 2017 12:04:49 +0100 Subject: [PATCH 2/4] tests: use the poweroff pkg in test-kernel-config Signed-off-by: Dave Tucker --- test/cases/test-kernel-config.yml | 7 ++++++- test/pkg/kernel-config/check.sh | 3 --- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/test/cases/test-kernel-config.yml b/test/cases/test-kernel-config.yml index 24ef97b21..4622d3858 100644 --- a/test/cases/test-kernel-config.yml +++ b/test/cases/test-kernel-config.yml @@ -19,8 +19,13 @@ onboot: net: host command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"] - name: check-kernel-config - image: "mobylinux/kernel-config:c9e41ab96b3ea6a3ced97634751e20d12a5bf52f" + image: "linuxkit/kernel-config:ecff41279ccbc408079a3996a956432651c6eb9c" + readonly: true +services: + - name: poweroff + image: "linuxkit/poweroff:961412b8ef5c5285de0d40ec076701d955eaa084" pid: host + command: ["/bin/sh", "/poweroff.sh", "3"] capabilities: - CAP_SYS_BOOT readonly: true diff --git a/test/pkg/kernel-config/check.sh b/test/pkg/kernel-config/check.sh index b28311d9b..dd37b4239 100755 --- a/test/pkg/kernel-config/check.sh +++ b/test/pkg/kernel-config/check.sh @@ -2,7 +2,6 @@ function failed { printf "Kernel config test suite FAILED\n" - /sbin/poweroff -f } /check-kernel-config.sh || failed @@ -11,5 +10,3 @@ bash /check-config.sh || failed printf "Kernel config test suite PASSED\n" cat /etc/linuxkit - -/sbin/poweroff -f From e4d84cf30445e61c28841d2e24cb65fd67f7ae21 Mon Sep 17 00:00:00 2001 From: Dave Tucker Date: Wed, 12 Apr 2017 13:36:25 +0100 Subject: [PATCH 3/4] tests: add makefile for tests this removes all test targets from the top level makefile with the exception of `make test` that now calls `$(MAKE) -C test`. all tests now use `moby run` by instead of the older `./scripts`. this removes the need for dedicated qemu/hyperkit test targets. Signed-off-by: Dave Tucker --- Makefile | 66 +++++++------------------------------------------ test/Makefile | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 57 deletions(-) create mode 100644 test/Makefile diff --git a/Makefile b/Makefile index daac32daf..354c05519 100644 --- a/Makefile +++ b/Makefile @@ -31,62 +31,15 @@ bin/linuxkit: $(LINUXKIT_DEPS) | bin rm tmp_linuxkit_bin.tar touch $@ -test-initrd.img: $(MOBY) test/test.yml - $(MOBY) build --pull test/test.yml - -test-bzImage: test-initrd.img - -.PHONY: test-qemu-efi -test-qemu-efi: $(LINUXKIT) test-efi.iso - $(LINUXKIT) run qemu test | tee test-efi.log - $(call check_test_log, test-efi.log) - bin: mkdir -p $@ install: cp -R ./bin/* $(PREFIX)/bin -define check_test_log - @cat $1 |grep -q 'test suite PASSED' -endef - -.PHONY: test-hyperkit -test-hyperkit: $(LINUXKIT) test-initrd.img test-bzImage test-cmdline - rm -f disk.img - $(LINUXKIT) run hyperkit test | tee test.log - $(call check_test_log, test.log) - -.PHONY: test-gcp -test-gcp: export CLOUDSDK_IMAGE_NAME?=test -test-gcp: $(LINUXKIT) test.img.tar.gz - $(LINUXKIT) push gcp test.img.tar.gz - $(LINUXKIT) run gcp $(CLOUDSDK_IMAGE_NAME) | tee test-gcp.log - $(call check_test_log, test-gcp.log) - .PHONY: test -test: $(LINUXKIT) test-initrd.img test-bzImage test-cmdline - $(LINUXKIT) run test | tee test.log - $(call check_test_log, test.log) - -test-ltp.img.tar.gz: $(MOBY) test/ltp/test-ltp.yml - $(MOBY) build --pull test/ltp/test-ltp.yml - -.PHONY: test-ltp -test-ltp: export CLOUDSDK_IMAGE_NAME?=test-ltp -test-ltp: $(LINUXKIT) artifacts/test-ltp.img.tar.gz - $(LINUXKIT) push gcp artifacts/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) - -artifacts: - mkdir -p $@ - -artifacts/test.img.tar.gz: test.img.tar.gz | artifacts - cp test.img.tar.gz artifacts/ - -artifacts/test-ltp.img.tar.gz: test-ltp.img.tar.gz | artifacts - cp test-ltp.img.tar.gz artifacts/ +test: + $(MAKE) -C test .PHONY: collect-artifacts collect-artifacts: artifacts/test.img.tar.gz artifacts/test-ltp.img.tar.gz @@ -95,23 +48,22 @@ collect-artifacts: artifacts/test.img.tar.gz artifacts/test-ltp.img.tar.gz ci: $(MAKE) clean $(MAKE) - $(MAKE) test - $(MAKE) collect-artifacts - $(MAKE) test-ltp + $(MAKE) install + $(MAKE) -C test all ci-tag: $(MAKE) clean $(MAKE) - $(MAKE) test - $(MAKE) collect-artifacts - $(MAKE) test-ltp + $(MAKE) install + $(MAKE) -C test all ci-pr: $(MAKE) clean $(MAKE) - $(MAKE) test - $(MAKE) artifacts/test.img.tar.gz + $(MAKE) install + $(MAKE) -C test pr .PHONY: clean clean: rm -rf bin *.log *-kernel *-cmdline *.img *.iso *.tar.gz *.qcow2 *.vhd *.vmx *.vmdk + $(MAKE) -C test clean diff --git a/test/Makefile b/test/Makefile new file mode 100644 index 000000000..d5520efce --- /dev/null +++ b/test/Makefile @@ -0,0 +1,68 @@ +.PHONY: default pr all + +default: check-deps kernel-config +pr: check-deps kernel-config ../artifacts/test.img.tar.gz +all: check-deps kernel-config ltp ../artifacts/test.img.tar.gz ../artifacts/test-ltp.img.tar.gz + +MOBY:=$(shell command -v moby 2> /dev/null) +LINUXKIT:=$(shell command -v linuxkit 2> /dev/null) + +.PHONY: check-deps +check-deps: +ifndef MOBY + $(error "moby is not available. please install it.") +endif +ifndef LINUXKIT + $(error "linuxkit binary not found. please install it.") +endif + +define check_test_log + @cat $1 |grep -q 'test suite PASSED' +endef + +../artifacts: + mkdir -p $@ + +test-kernel-config-initrd.img: $(MOBY) cases/test-kernel-config.yml + $(MOBY) build --pull cases/test-kernel-config.yml + +# uses qemu +.PHONY: kernel-config +kernel-config: $(LINUXKIT) test-kernel-config-initrd.img test-kernel-config-kernel test-kernel-config-cmdline + $(LINUXKIT) run qemu test-kernel-config 2>&1 | tee test.log + $(call check_test_log, test.log) + +# qemu only at this time +.PHONY: qemu-efi +efi: $(LINUXKIT) test-kernel-config-efi.iso + $(LINUXKIT) run qemu -uefi test-kernel-config | tee test-efi.log + $(call check_test_log, test-efi.log) + +# For GCP tests +../artifacts/test.img.tar.gz: test-kernel-config.img.tar.gz | ../artifacts + mv test-kernel-config.img.tar.gz ../artifacts/test.img.tar.gz + +.PHONY: gcp +gcp: export CLOUDSDK_IMAGE_NAME?=test-kernel-config +gcp: $(LINUXKIT) ../test.img.tar.gz + $(LINUXKIT) push gcp ../artifacts/test.img.tar.gz + $(LINUXKIT) run gcp $(CLOUDSDK_IMAGE_NAME) | tee test-gcp.log + $(call check_test_log, test-gcp.log) + +# For LTP tests +test-ltp.img.tar.gz: $(MOBY) cases/test-ltp.yml + $(MOBY) build --pull cases/test-ltp.yml + +../artifacts/test-ltp.img.tar.gz: test-ltp.img.tar.gz | ../artifacts + mv test-ltp.img.tar.gz ../artifacts + +.PHONY: ltp +ltp: export CLOUDSDK_IMAGE_NAME?=test-ltp +ltp: $(LINUXKIT) test-ltp.img.tar.gz + $(LINUXKIT) push gcp ../artifacts/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) + +.PHONY: clean +clean: + rm -rf bin *.log *-kernel *-cmdline *.img *.iso *.tar.gz *.qcow2 *.vhd *.vmx *.vmdk From 16cfd3ea2d62e7f5a8ceac2007c2ce88060c3a2b Mon Sep 17 00:00:00 2001 From: Dave Tucker Date: Fri, 5 May 2017 11:51:10 +0100 Subject: [PATCH 4/4] tests: Rename kernel-config image to test-kernel-config Signed-off-by: Dave Tucker --- test/cases/test-kernel-config.yml | 2 +- test/pkg/kernel-config/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cases/test-kernel-config.yml b/test/cases/test-kernel-config.yml index 4622d3858..a3337cad8 100644 --- a/test/cases/test-kernel-config.yml +++ b/test/cases/test-kernel-config.yml @@ -19,7 +19,7 @@ onboot: net: host command: ["/sbin/dhcpcd", "--nobackground", "-f", "/dhcpcd.conf", "-1"] - name: check-kernel-config - image: "linuxkit/kernel-config:ecff41279ccbc408079a3996a956432651c6eb9c" + image: "linuxkit/test-kernel-config:ecff41279ccbc408079a3996a956432651c6eb9c" readonly: true services: - name: poweroff diff --git a/test/pkg/kernel-config/Makefile b/test/pkg/kernel-config/Makefile index 96d172c7a..6aa8831a0 100644 --- a/test/pkg/kernel-config/Makefile +++ b/test/pkg/kernel-config/Makefile @@ -1,7 +1,7 @@ .PHONY: tag push BASE=alpine:3.5 -IMAGE=kernel-config +IMAGE=test-kernel-config default: push