tests/compose: Rework caching to cache RPMs

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
This commit is contained in:
Colin Walters 2017-11-30 14:32:49 -05:00 committed by Atomic Bot
parent 7f5082deef
commit dafb3d6daa
4 changed files with 28 additions and 22 deletions

View File

@ -39,27 +39,18 @@ 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
# Create a consistent cache of the RPMs
echo "Preparing compose tests..." | tee -a ${LOG}
setup_rpmmd_repos ${dn}/composedata
# Delete the default ref, since we want to use subrefs of it
compose_prepargs=
if test -n "${RPMOSTREE_COMPOSE_CACHEONLY:-}"; then
compose_prepargs="--cache-only"
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
(set -x
rm ${repobuild}/refs/heads/* -rf
rpm-ostree compose --repo=${repobuild} tree --dry-run ${compose_prepargs} --cachedir=${test_compose_datadir}/cache ${dn}/composedata/fedora-base.json
rm ${repobuild}/refs/heads/* -rf) &>> ${LOG}
rm ${tmp_repo} -rf
total=0
pass=0

View File

@ -23,17 +23,32 @@ pyappendjsonmember() {
pyeditjson "jd['"$1"'] += $2" < ${treefile} > ${treefile}.new && mv ${treefile}{.new,}
}
export repo=$(pwd)/repo
export repobuild=$(pwd)/repo-build
prepare_compose_test() {
name=$1
shift
ostree --repo=${repo} init --mode=archive
ostree --repo=${repobuild} init --mode=bare-user
mkdir -p ${test_compose_datadir}/cache
cp -r ${dn}/../composedata .
# We use the local RPM package cache
rm -f composedata/*.repo
cat > composedata/fedora-local.repo <<EOF
[fedora-local]
baseurl=${test_compose_datadir}/cache
enabled=1
gpgcheck=0
EOF
export treefile=composedata/fedora-${name}.json
pyeditjson "jd['ref'] += \"/${name}\"" < composedata/fedora-base.json > ${treefile}
pysetjsonmember "repos" '["fedora-local"]' ${treefile}
# FIXME extract from json
export treeref=fedora/stable/x86_64/${name}
}
compose_base_argv="--repo ${repobuild} --cache-only --cachedir=${test_compose_datadir}/cache"
compose_base_argv="--repo ${repobuild}"
runcompose() {
rpm-ostree compose tree ${compose_base_argv} ${treefile} "$@"
ostree --repo=${repo} pull-local ${repobuild}

View File

@ -10,7 +10,6 @@ prepare_compose_test "misc-tweaks"
pysetjsonmember "documentation" "False"
# And tweak some of the systemd units
pysetjsonmember "default_target" '"multi-user.target"'
pyappendjsonmember "packages" '["tuned"]'
pysetjsonmember "units" '["tuned.service"]'
# And test adding/removing files
pysetjsonmember "add-files" '[["foo.txt", "/usr/etc/foo.txt"],

View File

@ -3,7 +3,8 @@
"repos": ["fedora"],
"packages": ["kernel", "nss-altfiles", "systemd", "ostree", "selinux-policy-targeted", "chrony"],
"packages": ["kernel", "nss-altfiles", "systemd", "ostree", "selinux-policy-targeted", "chrony",
"tuned"],
"packages-aarch64": ["grub2-efi", "ostree-grub2",
"efibootmgr", "shim"],