dafb3d6daa
When we added the `--ex-unified-core` option our caching story got very messy because the non-unified core caches RPMs, but unified does ostree repo caching. For jigdo, we want the RPMs. Fix this by mirroring the RPMs using `--download-only` and pointing the tests consistently at that. Closes: #1122 Approved by: jlebon
102 lines
2.5 KiB
Bash
Executable File
102 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
dn=$(cd $(dirname $0) && pwd)
|
|
|
|
export topsrcdir=$(cd $dn/.. && pwd)
|
|
. ${dn}/common/libcomposetest.sh
|
|
|
|
# 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}
|
|
|
|
# Create a consistent cache of the RPMs
|
|
echo "Preparing compose tests..." | tee -a ${LOG}
|
|
tmp_repo=${test_compose_datadir}/tmp-repo
|
|
if test -z "${RPMOSTREE_COMPOSE_CACHEONLY:-}"; then
|
|
mkdir -p ${test_compose_datadir}/cache
|
|
setup_rpmmd_repos ${dn}/composedata
|
|
ostree --repo=${tmp_repo} init --mode=bare-user
|
|
# We use rpm-ostree in dry-run --cachedir mode
|
|
rpm-ostree compose --repo=${tmp_repo} tree --download-only --cachedir=${test_compose_datadir}/cache ${dn}/composedata/fedora-base.json &>> ${LOG}
|
|
(cd ${test_compose_datadir}/cache && createrepo_c .)
|
|
fi
|
|
rm ${tmp_repo} -rf
|
|
|
|
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"
|
|
if test -n "${RPMOSTREE_COMPOSE_FASTFAIL:-}"; then
|
|
break;
|
|
fi
|
|
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 ]
|