Accepting request 683779 from home:cyphar:containers:docker-test
- docker-test: add support for running the new integration/ tests with tests.sh OBS-URL: https://build.opensuse.org/request/show/683779 OBS-URL: https://build.opensuse.org/package/show/Virtualization:containers/docker?expand=0&rev=297
This commit is contained in:
parent
5d5d984bf3
commit
46a92a1eb8
@ -4,6 +4,7 @@ Sun Mar 10 21:12:09 UTC 2019 - Aleksa Sarai <asarai@suse.com>
|
||||
- docker-test: improvements to test packaging (we don't need to ship around the
|
||||
entire source tree, and we also need to build the born-again integration/
|
||||
tests which contain a suite-per-directory).
|
||||
- docker-test: add support for running the new integration/ tests with tests.sh
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Feb 26 09:39:57 UTC 2019 - Michal Jura <mjura@suse.com>
|
||||
|
28
tests.sh
28
tests.sh
@ -12,11 +12,12 @@ TESTS_EXE="$DOCKER_DIR/integration-cli/tests.main"
|
||||
VERSION="$(cat "$DOCKER_DIR/VERSION")"
|
||||
|
||||
# working dirs
|
||||
TESTS_DIR=/tmp/docker-int-tests
|
||||
FROZEN_IMAGES_DIR="$TESTS_DIR/frozen-images"
|
||||
TEST_TMPDIR=/tmp/docker-int-tests
|
||||
FROZEN_IMAGES_DIR="$TEST_TMPDIR/frozen-images"
|
||||
FROZEN_IMAGES_LINK=/docker-frozen-images
|
||||
BUNDLES_DIR="$TESTS_DIR/run/bundles"
|
||||
BUNDLES_DIR="$TEST_TMPDIR/run/bundles"
|
||||
|
||||
readarray -t TESTS < <(find "$DOCKER_DIR" -type f -executable -name 'tests.main')
|
||||
CHECK_TIMEOUT="${CHECK_TIMEOUT:-15m}"
|
||||
TEST_TIMEOUT="${TEST_TIMEOUT:-6h}"
|
||||
TEST_ARGS=("-check.v" "-check.timeout=${CHECK_TIMEOUT}" "-test.timeout=${TEST_TIMEOUT}")
|
||||
@ -86,13 +87,13 @@ require_git() { git version >/dev/null 2>&1 ; }
|
||||
|
||||
################################################################################
|
||||
|
||||
[ -x "$TESTS_EXE" ] || abort "integration tests executable not found at $TESTS_EXE"
|
||||
[ "$EUID" -eq 0 ] || abort "this script must be run as root"
|
||||
[ -n "$VERSION" ] || abort "could not obtain version"
|
||||
[ "${#TESTS[@]}" -eq 0 ] || abort "integration tests executable not found at $TESTS_EXE"
|
||||
[ "$EUID" -eq 0 ] || abort "this script must be run as root"
|
||||
[ -n "$VERSION" ] || abort "could not obtain version"
|
||||
|
||||
if [ "$#" -gt 0 ] ; then
|
||||
# run only some specific tests
|
||||
TEST_SELECT="-check.f=$(echo $@ | tr ' ' '|')"
|
||||
TEST_ARGS+=( "-check.f=$(echo $@ | tr ' ' '|')" )
|
||||
fi
|
||||
|
||||
# We want this to fail if the bundles already exist and cannot be removed.
|
||||
@ -131,7 +132,7 @@ fi
|
||||
/usr/sbin/useradd --create-home --gid docker unprivilegeduser >/dev/null 2>&1 || /bin/true
|
||||
|
||||
# prepare some expected dirs, files, etc...
|
||||
fix_expected "$TESTS_DIR/contrib" "$DOCKER_DIR/contrib"
|
||||
fix_expected "$TEST_TMPDIR/contrib" "$DOCKER_DIR/contrib"
|
||||
fix_expected "$DEST/fixtures" "$DOCKER_DIR/integration-cli/fixtures"
|
||||
fix_expected "$DEST/../Dockerfile" "$DOCKER_DIR/Dockerfile"
|
||||
|
||||
@ -196,7 +197,7 @@ cleanup() {
|
||||
|
||||
log "Removing extra files and restoring backups..."
|
||||
restore_backup /etc/subuid /etc/subgid
|
||||
rm -f "$TESTS_DIR/contrib" "$DEST/fixtures" "$FROZEN_IMAGES_LINK"
|
||||
rm -f "$TEST_TMPDIR/contrib" "$DEST/fixtures" "$FROZEN_IMAGES_LINK"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
@ -223,9 +224,12 @@ ln -sf "$FROZEN_IMAGES_DIR" "$FROZEN_IMAGES_LINK"
|
||||
debian:jessie@sha256:287a20c5f73087ab406e6b364833e3fb7b3ae63ca0eb3486555dc27ed32c6e60 \
|
||||
hello-world:latest@sha256:be0cd392e45be79ffeffa6b05338b98ebb16c87b255f48e297ec7f98e123905c
|
||||
|
||||
log "Running integration tests..."
|
||||
cd "$DEST" && \
|
||||
"$TESTS_EXE" "${TEST_ARGS[@]}" $TEST_SELECT 2>&1 | tee "$TEST_LOG" || /bin/true
|
||||
for TEST in "${TESTS[@]}"
|
||||
do
|
||||
cd "$(dirname "$TEST")"
|
||||
log "Running integration test ($TEST)..." | tee -a "$TEST_LOG"
|
||||
"$TEST" "${TEST_ARGS[@]}" 2>&1 | tee -a "$TEST_LOG" || /bin/true
|
||||
done
|
||||
if [ -n "$ENABLE_XUNIT" ] ; then
|
||||
log "Generating xunit logs..."
|
||||
go2xunit -fail -gocheck -input "$TEST_LOG" -output "$TEST_LOG.xml"
|
||||
|
Loading…
Reference in New Issue
Block a user