Skip to content

Commit

Permalink
Reorganize container tests
Browse files Browse the repository at this point in the history
Factorize the container launch part into tests/run, and change
tests/run-$OS to only be the part that runs inside the container. That
way, the latter can be re-used in CI environments that do their own
container launching.
  • Loading branch information
martinpitt committed Oct 22, 2019
1 parent 1848d84 commit b1e729d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 47 deletions.
16 changes: 8 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ sudo: true
services:
- docker
env:
- TEST=tests/run-ubuntu RELEASE=devel
- TEST=tests/run-ubuntu RELEASE=rolling
- TEST=tests/run-ubuntu RELEASE=latest
- TEST=tests/run-fedora RELEASE=latest
- TEST=tests/run-fedora RELEASE=rawhide
script: $TEST
- IMAGE=ubuntu:devel
- IMAGE=ubuntu:rolling
- IMAGE=ubuntu:latest
- IMAGE=fedora:latest
- IMAGE=fedora:rawhide
script: tests/run $IMAGE
deploy:
- provider: releases
api_key:
Expand All @@ -18,12 +18,12 @@ deploy:
skip_cleanup: true
on:
tags: true
condition: "$RELEASE = devel"
condition: "$IMAGE = ubuntu:devel"
- provider: pypi
user: "Martin.Pitt"
password:
secure: "jv9FTmI6rzNBJXjmo8lU7yWsQ9bG4Faqxi0JK6TgY6n9tGGyLWHa5eviIPq3Ka1Q6xiUJDjTGZH8dgFFZhd2V+TjL7Y4V4nip0/rpIyUJ8ZzJBatN3xlYXPWWiLM7kmcVbupMHKok0BIDv9QdSCSZ3owxIBahghQ/w3gWB7B+HVv7CiyPwrYpAL6EYkVl1XvAtWYLyECGcPpRRhDQwP/BxRSaFrxZKHmJjJDPHF5y673wKUgilHARB1sHhamGBF82n+9YsPp7Xt0ahmBVexzWKuOAkcpdoJWpOmCeVTt5ss5z1YvseFc2AS0Pn1+MtOrEAsPP/GUoe8GLoxD820tRs9UQ5x9XovHV5RRQ1knvCqxAsTd9IA21VjhpVGjg+wmwpM3jGXJjm+SIHAwx/2gDKkROkkJyFGk5ySZgjraxmgSXQN7O/mu+zDTx0+0EOa8OGjZiSHnQvscQALZfAXRjkfoXFmSttRapSZQz0XMHNSaH/gRSlOsrJgDNk97+lkTHUfSNHmVaE+Ucq6iocjXRz5IgyrQSFFax8ZQtDQC/HD2OkXALQ8ovRcU3WZSWk5zS0MYYaW6Irfouwx4ELD2cJ/g/BV+yhpHAZFjsMHnA3Shpt1OsmuqYlHNzIlM90JeStet6s7DrQwdoBoKW44jzfcms3hYXh3g8up+M3bDXt0="
skip_cleanup: true
on:
tags: true
condition: "$RELEASE = devel"
condition: "$IMAGE = ubuntu:devel"
11 changes: 11 additions & 0 deletions tests/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
set -eux
IMAGE="$1"

if type podman >/dev/null 2>&1; then
RUNC=podman
else
RUNC="sudo docker"
fi

$RUNC run --interactive --rm --volume `pwd`:/source --workdir /source "$IMAGE" /bin/sh tests/run-${IMAGE%:*}
21 changes: 3 additions & 18 deletions tests/run-fedora
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
#!/bin/sh
set -eu

if type podman >/dev/null 2>&1; then
RUNC=podman
else
RUNC="sudo docker"
fi

$RUNC run --interactive --rm --volume `pwd`:/source fedora:${RELEASE:-latest} /bin/sh << EOF
set -ex
SUCCESS=0
trap "if [ \$SUCCESS -eq 0 ] && [ -n '${DEBUG:-}' ]; then echo sleeping indefinitely for debugging; sleep infinity; fi" EXIT INT QUIT PIPE
set -eux
# install build dependencies
# FIXME: s/which/type in tests
dnf -y install which python3-setuptools python3-nose python3-gobject-base \
Expand All @@ -24,11 +11,9 @@ mkdir -p /run/systemd/system

# run build and test as user
useradd build
su -s /bin/sh - build << EOG
su -s /bin/sh - build << EOF
set -ex
cp -r /source /tmp
cp -r $(pwd) /tmp/source
cd /tmp/source
python3 setup.py test
EOG
SUCCESS=1
EOF
28 changes: 7 additions & 21 deletions tests/run-ubuntu
100755 → 100644
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
#!/bin/sh
set -eu

if type podman >/dev/null 2>&1; then
RUNC=podman
else
RUNC="sudo docker"
fi

$RUNC run --interactive --rm --volume `pwd`:/source ${ARCH:-amd64}/ubuntu:${RELEASE:-rolling} /bin/sh << EOF
set -ex
SUCCESS=0
trap "if [ \$SUCCESS -eq 0 ] && [ -n '${DEBUG:-}' ]; then echo sleeping indefinitely for debugging; sleep infinity; fi" EXIT INT QUIT PIPE
set -eux

# go-faster apt
echo 'Acquire::Languages "none";' > /etc/apt/apt.conf.d/90nolanguages
Expand All @@ -30,24 +18,22 @@ mkdir -p /run/systemd/system

# run build and test as user
useradd build
su -s /bin/sh - build << EOG
su -s /bin/sh - build << EOF
set -ex
cp -r /source /tmp
cp -r $(pwd) /tmp/source
cd /tmp/source
python3 setup.py test
python2 setup.py test
# massively parallel test to check for races
for i in \\\$(seq 100); do
for i in \$(seq 100); do
( PYTHONPATH=. python3 tests/test_api.py TestTemplates || touch /tmp/fail ) &
done
wait
[ ! -e /tmp/fail ]
./setup.py sdist
EOG
# copy release tarball to outside
cp -r /tmp/source/dist /source/
SUCCESS=1
EOF

# copy release tarball to outside; for bind mounts only
[ ! -d /source ] || cp -r /tmp/source/dist /source/

0 comments on commit b1e729d

Please sign in to comment.