From eb92306c4897f5402bdc6691e97b99e0f2fc8c2a Mon Sep 17 00:00:00 2001 From: Marco Vedovati Date: Tue, 20 Nov 2018 18:57:11 +0100 Subject: [PATCH 1/2] tests: skip docker,kata install with KATA_DEV_MODE Skip installation of docker and kata packages when the environment variable KATA_DEV_MODE is not empty, as a dev system may be using a non standard setup. Fixes: #195 Signed-off-by: Marco Vedovati --- tests/README.md | 8 ++++---- tests/test_images.sh | 12 +++++++++++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/README.md b/tests/README.md index a0e429ea0..bb82e3f94 100644 --- a/tests/README.md +++ b/tests/README.md @@ -7,10 +7,10 @@ osbuilder provides a test script that creates all images and initrds for all supported distributions and then tests them to ensure a Kata Container can be created with each. -The test script installs all required Kata components on the host system -before creating the images. - -To run all available osbuilder tests: +Before the build phase, the test script installs the Docker container manager +and all the Kata components required to run test containers. This step can be +skipped by setting the environment variable `KATA_DEV_MODE` to a non-empty +value. ``` $ ./test_images.sh diff --git a/tests/test_images.sh b/tests/test_images.sh index fce4348b2..b30b4e689 100755 --- a/tests/test_images.sh +++ b/tests/test_images.sh @@ -235,7 +235,17 @@ setup() [ ! -d "${tests_repo_dir}" ] && git clone "https://${tests_repo}" "${tests_repo_dir}" - chronic $mgr install-docker-system + if [ -z "${KATA_DEV_MODE:-}" ]; then + chronic $mgr install-docker-system + else + info "Running with KATA_DEV_MODE set, skipping installation of docker and kata packages" + # Make sure docker & kata are available + command -v docker >/dev/null || die "docker cannot be found on your PATH" + local cfgRuntime= + cfgRuntime="$(docker info --format "{{(index .Runtimes \"${RUNTIME}\").Path}}")" + [ -n "$cfgRuntime" ] || die "${RUNTIME} is not a configured runtime for docker" + [ -x "$cfgRuntime" ] || die "docker ${RUNTIME} is linked to an invalid executable: $cfgRuntime" + fi chronic $mgr enable-debug # Ensure "docker build" works From 9c0773a39964c4ce60e78a840664fc5f79645bdb Mon Sep 17 00:00:00 2001 From: Marco Vedovati Date: Wed, 21 Nov 2018 09:42:47 +0100 Subject: [PATCH 2/2] test: avoid errors in exit_handler Avoid generating errors in the exit_handler, as those could be misinterpreted as red herrings for the actual error being trapped. Signed-off-by: Marco Vedovati --- tests/test_images.sh | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/tests/test_images.sh b/tests/test_images.sh index b30b4e689..ceef790a4 100755 --- a/tests/test_images.sh +++ b/tests/test_images.sh @@ -153,11 +153,26 @@ exit_handler() info "ERROR: test failed" # The test failed so dump what we can - info "images:" - sudo -E ls -l "${images_dir}" >&2 + if [ -d "${tmp_rootfs}" ]; then + info "rootfs:" + sudo -E ls -l "${tmp_rootfs}" >&2 + else + info "no rootfs created" + # If no rootfs are created, no need to dump other info + return + fi - info "rootfs:" - sudo -E ls -l "${tmp_rootfs}" >&2 + if [ -d "${images_dir}" ]; then + info "images:" + sudo -E ls -l "${images_dir}" >&2 + else + info "no images created" + # If no images are created, no need to dump other info + return + fi + + # Travis tests do not install kata + [ -n "${TRAVIS:-}" ] && return info "local runtime config:" cat /etc/kata-containers/configuration.toml >&2 @@ -172,7 +187,7 @@ exit_handler() sudo -E ps -efwww | egrep "docker|kata" >&2 # Restore the default image in config file - [ -n "${TRAVIS:-}" ] || chronic $mgr configure-image + chronic $mgr configure-image } die()