From 334335e0e59ac380433e0088c9473869bd51d6e2da9272e701ce30316b944452 Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Tue, 12 Mar 2019 22:20:37 +0000 Subject: [PATCH] Accepting request 684497 from home:cyphar:containers:docker-test More tests.sh improvements to increase the success percentage and to run dockerd-related tests. OBS-URL: https://build.opensuse.org/request/show/684497 OBS-URL: https://build.opensuse.org/package/show/Virtualization:containers/docker?expand=0&rev=303 --- docker.spec | 2 ++ tests.sh | 43 +++++++++++++++---------------------------- 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/docker.spec b/docker.spec index a2d02f1..e99a003 100644 --- a/docker.spec +++ b/docker.spec @@ -219,11 +219,13 @@ Zsh command line completion support for %{name}. %package test %global __requires_exclude ^libgo.so.*$ Summary: Test package for docker +# Needed for test-suite. Group: System/Management Requires: curl Requires: go Requires: iputils Requires: jq +Requires: net-tools-deprecated # KUBIC-SPECIFIC: This was required when upgrading from the original kubic # packaging, when everything was renamed to -kubic. It also is # used to ensure that nothing complains too much when using diff --git a/tests.sh b/tests.sh index b57c155..36ab8b6 100644 --- a/tests.sh +++ b/tests.sh @@ -16,11 +16,10 @@ FROZEN_IMAGES_LINK=/docker-frozen-images readarray -t TESTS < <(find "$DOCKER_DIR/integration-cli" -type f -executable -name 'tests.main') CHECK_TIMEOUT="${CHECK_TIMEOUT:-15m}" -TEST_TIMEOUT="${TEST_TIMEOUT:-6h}" +TEST_TIMEOUT="${TEST_TIMEOUT:-0}" TEST_ARGS=("-check.v" "-check.timeout=${CHECK_TIMEOUT}" "-test.timeout=${TEST_TIMEOUT}") TEST_SELECT= TEST_LOG=/tmp/docker-tests.log -ENABLE_XUNIT="${ENABLE_XUNIT-yes}" KEEPBUNDLE="${KEEPBUNDLE:-}" # the config file for Docker @@ -60,10 +59,8 @@ restore_backup() { for x in $@ ; do if [ -f "$x.nbak" ] ; then rm -f "$x.nbak" - else - if [ -f "$x.bak" ] ; then - mv -f "$x.bak" "$x" - fi + elif [ -f "$x.bak" ] ; then + mv -f "$x.bak" "$x" fi done } @@ -82,24 +79,6 @@ if [ "$#" -gt 0 ] ; then TEST_ARGS+=( "-check.f=$(echo $@ | tr ' ' '|')" ) fi -if [ -n "$ENABLE_XUNIT" ] ; then - if [ ! -x /usr/local/bin/go2xunit ] ; then - echo >&2 "Installing go2xunit." - - require_go || abort "the Go compiler is not installed" - - export GOPATH="$(mktemp -d)" - - go get -d github.com/tebeka/go2xunit - cd "$GOPATH/src/github.com/tebeka/go2xunit" && go build -o /usr/local/bin/go2xunit . - chmod 755 /usr/local/bin/go2xunit - [ -x /usr/local/bin/go2xunit ] || abort "go2xunit could not be built" - - rm -rf "$GOPATH" - export -n GOPATH - fi -fi - # tests require this user and group /usr/sbin/groupadd -r docker >/dev/null 2>&1 || /bin/true /usr/sbin/useradd --create-home --gid docker unprivilegeduser >/dev/null 2>&1 || /bin/true @@ -159,6 +138,7 @@ cleanup() { rm -f "$FROZEN_IMAGES_LINK" log "Removing images and containers..." + export DOCKER_HOST="$DOCKER_TEST_HOST" docker ps -aq | xargs docker rm -f &>/dev/null || : docker images -q | xargs docker rmi -f &>/dev/null || : @@ -203,6 +183,17 @@ do docker build -t "$(basename "$dir")" "$dir" done +# For some reason, dockerd appears to put the containerd.sock in the wrong +# place under systemd. So we just manually add a symlink for it. +[ -e "/var/run/docker/containerd/containerd.sock" ] || \ + ln -s docker-containerd.sock /var/run/docker/containerd/containerd.sock + +# And there appears to be an issue with daemon.json as a configuration format, +# so we need to hide our generated configuration. The original will be restored +# in cleanup(). +rm -f "$CFG_DOCKER" + +# Run all of our tests. rm -f "$TEST_LOG" for TEST in "${TESTS[@]}" do @@ -210,9 +201,5 @@ do log "Running integration test ($TEST)..." | tee -a "$TEST_LOG" "$TEST" "${TEST_ARGS[@]}" 2>&1 | tee -a "$TEST_LOG" || : done -if [ -n "$ENABLE_XUNIT" ] ; then - log "Generating xunit logs..." - go2xunit -fail -gocheck -input "$TEST_LOG" -output "$TEST_LOG.xml" -fi export -n DOCKER_HOST