tests: Move upgrade/rebase tests from unit to vmcheck/test-upgrades

Now we stop running rpm-ostreed as non-root, which is going to be
a maintenance pain going forward.  If we do introduce non-VM based
tests I think we should look to doing in-container testing.

Closes: #1339
Approved by: cgwalters
This commit is contained in:
Colin Walters 2018-04-18 14:02:02 -04:00 committed by Atomic Bot
parent a50a6cb959
commit 9df2428a1a
4 changed files with 101 additions and 168 deletions

View File

@ -54,7 +54,6 @@ uninstalled_test_programs = \
$(NULL)
uninstalled_test_scripts = \
tests/check/test-upgrade-rebase.sh \
tests/check/test-lib-introspection.sh \
tests/check/test-ucontainer.sh \
$(NULL)

View File

@ -1,162 +0,0 @@
#!/bin/bash
#
# Copyright (C) 2014 Colin Walters <walters@verbum.org>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
set -e
. ${commondir}/libtest.sh
export RPMOSTREE_SUPPRESS_REQUIRES_ROOT_CHECK=yes
ensure_dbus
echo "1..18"
setup_os_repository "archive-z2" "syslinux"
echo "ok setup"
set -x
# Note: Daemon already knows what sysroot to use, so avoid passing
# --sysroot=sysroot to rpm-ostree commands as it will result
# in a warning message.
OSTREE="ostree --repo=sysroot/ostree/repo"
REMOTE_OSTREE="ostree --repo=testos-repo --gpg-homedir=${test_tmpdir}/gpghome"
# This initial deployment gets kicked off with some kernel arguments
$OSTREE remote add --set=gpg-verify=false testos file://$(pwd)/testos-repo testos/buildmaster/x86_64-runtime
$OSTREE pull testos:testos/buildmaster/x86_64-runtime
ostree admin --sysroot=sysroot deploy --karg=root=LABEL=MOO --karg=quiet --os=testos testos:testos/buildmaster/x86_64-runtime
assert_status_jq '.deployments[0].version == "1.0.10"'
echo "ok status shows right version"
os_repository_new_commit
rpm-ostree upgrade --os=testos
$OSTREE remote add --set=gpg-verify=false otheros file://$(pwd)/testos-repo testos/buildmaster/x86_64-runtime
rpm-ostree rebase --os=testos otheros:
assert_status_jq '.deployments[0].version == "'$(date "+%Y%m%d.0")'"'
echo "ok rebase onto newer version"
# Jump backward to 1.0.9
rpm-ostree deploy --os=testos 1.0.9
assert_status_jq '.deployments[0].version == "1.0.9"'
echo "ok deploy older known version"
# Remember the current revision for later.
revision=$($OSTREE rev-parse otheros:testos/buildmaster/x86_64-runtime)
# Jump forward to a locally known version.
rpm-ostree deploy --os=testos 1.0.10
assert_status_jq '.deployments[0].version == "1.0.10"'
echo "ok deploy newer known version"
# Jump forward to a new, locally unknown version.
# Here we also test the "version=" argument prefix.
os_repository_new_commit 1 1
rpm-ostree deploy --os=testos version=$(date "+%Y%m%d.1")
assert_status_jq '.deployments[0].version == "'$(date "+%Y%m%d.1")'"'
echo "ok deploy newer unknown version"
# Jump backward again to 1.0.9, but this time using the
# "revision=" argument prefix (and test case sensitivity).
rpm-ostree deploy --os=testos REVISION=$revision
assert_status_jq '.deployments[0].version == "1.0.9"'
echo "ok deploy older version by revision"
# Make a commit on a different branch and make sure that it doesn't let us
# deploy it
other_rev=$($REMOTE_OSTREE commit -b other-branch --tree=ref=$revision)
if rpm-ostree deploy --os=testos REVISION=$other_rev 2>OUTPUT-err; then
assert_not_reached "Deploying an out-of-branch commit unexpectedly succeeded."
fi
assert_file_has_content OUTPUT-err 'Checksum .* not found in .*'
echo "ok error on deploying commit on other branch"
# Make sure we can do an upgrade after a deploy
os_repository_new_commit 2 3
rpm-ostree upgrade --os=testos
assert_status_jq '.deployments[0].version == "'$(date "+%Y%m%d.3")'"'
echo "ok upgrade after deploy"
# Make sure we're currently on otheros
assert_status_jq '.deployments[0].origin|startswith("otheros:")'
os_repository_new_commit 2 2
rpm-ostree rebase --os=testos testos:testos/buildmaster/x86_64-runtime $(date "+%Y%m%d.2")
assert_status_jq '.deployments[0].origin|startswith("testos:")'
assert_status_jq '.deployments[0].version == "'$(date "+%Y%m%d.2")'"'
echo "ok rebase onto other branch at specific version"
branch=testos/buildmaster/x86_64-runtime
new_csum=$($REMOTE_OSTREE commit -b $branch --tree=ref=$branch)
rpm-ostree rebase --os=testos otheros:$branch $new_csum
assert_status_jq '.deployments[0].origin|startswith("otheros:")'
assert_status_jq '.deployments[0].checksum == "'$new_csum'"'
echo "ok rebase onto other branch at specific checksum"
if rpm-ostree rebase --os=testos testos:testos/buildmaster/x86_64-runtime $other_rev 2>OUTPUT-err; then
assert_not_reached "Rebasing onto out-of-branch commit unexpectedly succeeded."
fi
assert_file_has_content OUTPUT-err 'Checksum .* not found in .*'
echo "ok error on rebasing onto commit on other branch"
# Make sure that we can deploy from a remote which has gone from unsigned to
# signed commits.
$REMOTE_OSTREE commit -b $branch --tree=ref=$branch \
--gpg-sign=$TEST_GPG_KEYID --add-metadata-string version=gpg-signed
$OSTREE remote add secureos file://$(pwd)/testos-repo
rpm-ostree rebase --os=testos secureos:$branch gpg-signed
echo "ok deploy from remote with unsigned and signed commits"
rpm-ostree rebase --os=testos :$branch
assert_status_jq '.deployments[0].origin|startswith("testos/")'
echo "ok rebase from refspec with remote to local branch"
$OSTREE commit -b another-branch --tree=ref=$branch
rpm-ostree rebase --os=testos another-branch
assert_status_jq '.deployments[0].origin == "another-branch"'
echo "ok rebase from local branch to local branch"
csum1=$($OSTREE commit -b another-branch --tree=ref=$branch)
csum2=$($OSTREE commit -b another-branch --tree=ref=$branch)
rpm-ostree deploy --os=testos $csum1
if [ "$($OSTREE rev-parse another-branch)" != $csum2 ]; then
assert_not_reached "deploying from local branch changes branch"
fi
echo "ok local deploy doesn't affect branch"
rpm-ostree rebase --skip-purge --os=testos testos:testos/buildmaster/x86_64-runtime
assert_status_jq '.deployments[0].origin == "testos:testos/buildmaster/x86_64-runtime"'
ostree --repo=${test_tmpdir}/testos-repo commit --add-metadata-string version=1.0.2 -b testos/stable/x86_64-runtime -s "Build" \
--tree=ref=testos/buildmaster/x86_64-runtime
rpm-ostree rebase --skip-purge --os=testos -b testos/stable/x86_64-runtime
assert_status_jq '.deployments[0].origin == "testos:testos/stable/x86_64-runtime"'
ostree --repo=${test_tmpdir}/sysroot/ostree/repo commit -b localbranch --tree=ref=testos:testos/stable/x86_64-runtime
rpm-ostree rebase --skip-purge --os=testos -m '' -b localbranch
assert_status_jq '.deployments[0].origin == "localbranch"'
echo "ok rebase new syntax"
rpm-ostree rebase --skip-purge --os=testos ostree://testos:testos/buildmaster/x86_64-runtime
assert_status_jq '.deployments[0].origin == "testos:testos/buildmaster/x86_64-runtime"'
echo "ok rebase refspec syntax"
rpm-ostree rebase --os=testos :another-branch

View File

@ -531,14 +531,25 @@ vm_ostreeupdate_lift_commit() {
vm_cmd ostree --repo=$REMOTE_OSTREE refs $checksum --create=$branch
}
# use a previously stolen commit to create an update on our vmcheck branch,
# complete with version string and pkglist metadata
vm_ostreeupdate_create() {
_commit_and_inject_pkglist() {
version=$1; shift
branch=vmcheck_tmp/$version
src_ref=$1; shift
vm_cmd ostree commit --repo=$REMOTE_OSTREE -b vmcheck --fsync=no \
--tree=ref=$branch --add-metadata-string=version=$version
--tree=ref=$src_ref --add-metadata-string=version=$version
# avoid libtool wrapper here since we're running on the VM and it would try to
# cd to topsrcdir/use gcc; libs are installed anyway
vm_cmd /var/roothome/sync/.libs/inject-pkglist $REMOTE_OSTREE vmcheck
}
# use a previously stolen commit to create an update on our vmcheck branch,
# complete with version string and pkglist metadata
vm_ostreeupdate_create() {
version=$1; shift
_commit_and_inject_pkglist $version vmcheck_tmp/$version
}
# create a new no-op update with version metadata $1
vm_ostreeupdate_create_noop() {
version=$1; shift
_commit_and_inject_pkglist $version vmcheck
}

85
tests/vmcheck/test-upgrades.sh Executable file
View File

@ -0,0 +1,85 @@
#!/bin/bash
#
# Copyright (C) 2018 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
set -euo pipefail
. ${commondir}/libtest.sh
. ${commondir}/libvm.sh
set -x
# Prepare an OSTree repo with updates
vm_ostreeupdate_prepare
vm_rpmostree rebase vmcheckmote:vmcheck
vm_reboot
vm_rpmostree cleanup -pr
vm_assert_status_jq ".deployments[0][\"origin\"] == \"vmcheckmote:vmcheck\"" \
".deployments[0][\"booted\"]" \
".deployments[0][\"version\"] == \"v1\""
vm_rpmostree status > status.txt
assert_file_has_content_literal status.txt 'auto updates disabled'
# start it up again since we rebooted
vm_start_httpd ostree_server $REMOTE_OSTREE 8888
echo "ok prep"
# Test base ostree update
vm_ostreeupdate_create v2
vm_rpmostree upgrade
vm_reboot
vm_start_httpd ostree_server $REMOTE_OSTREE 8888
vm_rpmostree cleanup -pr
vm_assert_status_jq ".deployments[0][\"booted\"]" \
".deployments[0][\"version\"] == \"v2\""
echo "ok upgrade"
vm_cmd ostree remote add otherremote --no-gpg-verify http://localhost:8888/
vm_rpmostree reload
vm_rpmostree rebase otherremote:
vm_assert_status_jq ".deployments[0][\"origin\"] == \"otherremote:vmcheck\"" \
".deployments[0][\"booted\"]|not"
vm_rpmostree rebase vmcheckmote:
vm_assert_status_jq ".deployments[0][\"origin\"] == \"vmcheckmote:vmcheck\"" \
".deployments[0][\"booted\"]|not"
echo "ok rebase"
# A new update is available...but deploy v1 again
vm_ostreeupdate_create_noop v3
vm_rpmostree deploy v1
vm_assert_status_jq ".deployments[0][\"booted\"]|not" \
".deployments[0][\"version\"] == \"v1\""
vm_rpmostree cleanup -pr
vm_rpmostree deploy version=v3
vm_assert_status_jq ".deployments[0][\"booted\"]|not" \
".deployments[0][\"version\"] == \"v3\""
v3rev=$(vm_get_deployment_info 0 checksum)
vm_rpmostree deploy v1
vm_rpmostree cleanup -pr
vm_rpmostree deploy REVISION=${v3rev}
vm_assert_status_jq ".deployments[0][\"booted\"]|not" \
".deployments[0][\"version\"] == \"v3\""
vm_rpmostree deploy v1
vm_reboot
vm_start_httpd ostree_server $REMOTE_OSTREE 8888
vm_rpmostree cleanup -pr
vm_rpmostree rebase otherremote:vmcheck ${v3rev}
vm_assert_status_jq ".deployments[0][\"booted\"]|not" \
".deployments[0][\"version\"] == \"v3\""
echo "ok deploy"