rpm-ostree/tests/compose
Jonathan Lebon cf19d83502 ci: unite testsuites and run vmcheck on centos
We can be a bit less wasteful here by merging the check and vmcheck
suites into a single suite. The check suite today takes a negligible
amount of time to run, so we're not gaining much by parallelizing them.
It's more of a sanity check at this point before we start vmcheck.

Also start running vmcheck on CentOS 7. We adapt the ci scripts to
accomodate both Fedora and CentOS target machines.

This commit also switches to Fedora 26 as the primary test base.

Closes: #871
Approved by: cgwalters
2017-07-18 13:58:38 +00:00

111 lines
2.8 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
dn=$(cd $(dirname $0) && pwd)
export topsrcdir=$(cd $dn/.. && pwd)
# avoid refetching yum metadata everytime
export RPMOSTREE_USE_CACHED_METADATA=1
LOG=${LOG:-compose.log}
date > ${LOG}
colour_print() {
colour=$1; shift
[ ! -t 1 ] || echo -en "\e[${colour}m"
echo -n "$@"
[ ! -t 1 ] || echo -en "\e[0m"
echo
}
pass_print() {
colour_print 32 "$@" # green
}
fail_print() {
colour_print 31 "$@" # red
}
skip_print() {
colour_print 34 "$@" # blue
}
uid=$(id -u)
test_compose_datadir=/var/tmp/rpmostree-compose-cache-${uid}
export test_compose_datadir
mkdir -p ${test_compose_datadir}
datadir_owner=$(stat -c '%u' ${test_compose_datadir})
test ${uid} = ${datadir_owner}
# Pre-cache RPMs for each test, and share ostree repos between them for efficiency
repo=${test_compose_datadir}/repo
export repo
ostree --repo=${repo} init --mode=archive
repobuild=${test_compose_datadir}/repo-build
export repobuild
ostree --repo=${repobuild} init --mode=bare-user
mkdir -p ${test_compose_datadir}/cache
echo "Preparing compose tests..." | tee -a ${LOG}
# take the host repo if it matches our target tree
if [ -n "${RPMOSTREE_COMPOSE_TEST_USE_HOST_REPO:-}" ]; then
# NB: when bumping 26 here, also bump fedora.repo, .papr.yml
(source /etc/os-release;
if [ "$ID" == "fedora" ] && [ "$VERSION_ID" == "26" ]; then
echo "Taking stable Fedora repo file from test env."
cp -fv /etc/yum.repos.d/fedora.repo ${dn}/composedata
fi) &>> ${LOG}
fi
# Delete the default ref, since we want to use subrefs of it
(rm ${repobuild}/refs/heads/* -rf
rpm-ostree compose --repo=${repobuild} tree --dry-run --cachedir=${test_compose_datadir}/cache ${dn}/composedata/fedora-base.json
rm ${repobuild}/refs/heads/* -rf) &>> ${LOG}
total=0
pass=0
fail=0
skip=0
for tf in $(find ${dn}/compose-tests -name 'test-*.sh' | sort); do
if [ -n "${TESTS+ }" ]; then
tfbn=$(basename "$tf" .sh)
tfbn=" ${tfbn#test-} "
if [[ " $TESTS " != *$tfbn* ]]; then
continue
fi
fi
let "total += 1"
bn=$(basename ${tf})
printf "Running $bn...\n"
printf "\n\n===== ${bn} =====\n\n" >> ${LOG}
# do some dirty piping to get some instant feedback and help debugging
if ${tf} |& tee -a ${LOG} \
| grep -e '^ok ' --line-buffered \
| xargs -d '\n' -n 1 echo " "; then
pass_print "PASS: $bn"
echo "PASS" >> ${LOG}
let "pass += 1"
else
if test $? = 77; then
skip_print "SKIP: $bn"
echo "SKIP" >> ${LOG}
let "skip += 1"
else
fail_print "FAIL: $bn"
echo "FAIL" >> ${LOG}
let "fail += 1"
fi
fi
done
[ ${fail} -eq 0 ] && printer=pass || printer=fail
${printer}_print "TOTAL: $total PASS: $pass SKIP: $skip FAIL: $fail"
echo "See ${LOG} for more information."
[ ${fail} -eq 0 ]