tests: Migrate some basic unit tests that start daemon to vmcheck

The unit tests run an rpm-ostree daemon as non-root, which worked
surprisingly well for quite a while.  But it started failing when
working on a patch which adds caching that writes to `/var`.

Since we have the vmcheck system now, let's switch over to that.
This PR moves the random "basic" tests we'd accumulated like
one to verify `StateRoot` is only in `status --verbose`, but not
the tests for the `rebase` command etc.

Closes: #1336
Approved by: jlebon
This commit is contained in:
Colin Walters 2018-04-15 14:44:24 -04:00 committed by Atomic Bot
parent b11d1fc1e3
commit 4f42b94da7
3 changed files with 56 additions and 41 deletions

View File

@ -24,7 +24,7 @@ export RPMOSTREE_SUPPRESS_REQUIRES_ROOT_CHECK=yes
ensure_dbus
echo "1..26"
echo "1..20"
setup_os_repository "archive-z2" "syslinux"
@ -38,10 +38,6 @@ set -x
OSTREE="ostree --repo=sysroot/ostree/repo"
REMOTE_OSTREE="ostree --repo=testos-repo --gpg-homedir=${test_tmpdir}/gpghome"
rpm-ostree --version > version.yaml
python -c 'import yaml; v=yaml.safe_load(open("version.yaml")); assert("Version" in v["rpm-ostree"])'
echo "ok yaml version"
# 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
@ -50,18 +46,6 @@ ostree admin --sysroot=sysroot deploy --karg=root=LABEL=MOO --karg=quiet --os=te
assert_status_jq '.deployments[0].version == "1.0.10"'
echo "ok status shows right version"
rpm-ostree status > status.txt
assert_file_has_content status.txt ' ostree://testos:testos/buildmaster/x86_64-runtime'
assert_file_has_content status.txt 'Version: 1.0.10'
assert_not_file_has_content status.txt StateRoot:
rpm-ostree status -v > status.txt
assert_file_has_content status.txt StateRoot:
echo "ok status text"
dbus-send --session --dest=org.projectatomic.rpmostree1 --print-reply=literal /org/projectatomic/rpmostree1/testos org.projectatomic.rpmostree1.OSExperimental.Moo boolean:true > moo.txt
assert_file_has_content moo.txt '🐄'
echo "ok experimental"
os_repository_new_commit
rpm-ostree upgrade --os=testos
@ -176,30 +160,6 @@ assert_status_jq '.deployments[0].origin == "testos:testos/buildmaster/x86_64-ru
echo "ok rebase refspec syntax"
rpm-ostree rebase --os=testos :another-branch
originpath=$(ostree admin --sysroot=sysroot --print-current-dir).origin
echo "unconfigured-state=Access to TestOS requires ONE BILLION DOLLARS" >> ${originpath}
rpm-ostree reload
rpm-ostree status
if rpm-ostree upgrade --os=testos 2>err.txt; then
assert_not_reached "Upgraded from unconfigured-state"
fi
assert_file_has_content err.txt 'ONE BILLION DOLLARS'
echo "ok unconfigured status"
# Ensure it returns an error when passing a wrong option.
rpm-ostree --help | awk '/^$/ {in_commands=0} {if(in_commands==1){print $0}} /^Builtin Commands:/ {in_commands=1}' > commands
while read command; do
if rpm-ostree $command --n0t-3xisting-0ption &>/dev/null; then
assert_not_reached "command $command --n0t-3xisting-0ption was successful"
fi
done < commands
echo "ok error on unknown command options"
if rpm-ostree nosuchcommand --nosuchoption 2>err.txt; then
assert_not_reached "Expected an error for nosuchcommand"
fi
assert_file_has_content err.txt 'Unknown.*command'
echo "ok error on unknown command"
if ! skip_one_with_asan; then
cat >test-rpmostree-gi-arch <<EOF

View File

@ -303,6 +303,10 @@ vm_has_dormant_packages() {
! vm_has_layered_packages "$@"
}
vm_get_booted_stateroot() {
vm_get_booted_deployment_info osname
}
# retrieve the checksum of the currently booted deployment
vm_get_booted_csum() {
vm_get_booted_deployment_info checksum

View File

@ -40,6 +40,25 @@ vm_rpmostree status --jsonpath '$.deployments[0].booted' > jsonpath.txt
assert_file_has_content_literal jsonpath.txt '[true]'
echo "ok jsonpath"
vm_rpmostree --version > version.yaml
python -c 'import yaml; v=yaml.safe_load(open("version.yaml")); assert("Version" in v["rpm-ostree"])'
echo "ok yaml version"
# Ensure we return an error when passing a wrong option.
vm_rpmostree --help | awk '/^$/ {in_commands=0} {if(in_commands==1){print $0}} /^Builtin Commands:/ {in_commands=1}' > commands
while read command; do
if vm_rpmostree $command --n0t-3xisting-0ption &>/dev/null; then
assert_not_reached "command $command --n0t-3xisting-0ption was successful"
fi
done < commands
echo "ok error on unknown command options"
if vm_rpmostree nosuchcommand --nosuchoption 2>err.txt; then
assert_not_reached "Expected an error for nosuchcommand"
fi
assert_file_has_content err.txt 'Unknown.*command'
echo "ok error on unknown command"
# Be sure an unprivileged user exists and that we can SSH into it. This is a bit
# underhanded, but we need a bona fide user session to verify non-priv status,
# and logging in through SSH is an easy way to achieve that.
@ -70,6 +89,13 @@ echo "ok auth"
vm_cmd_as testuser rpm-ostree status
echo "ok status doesn't require root"
# StateRoot is only in --verbose
vm_rpmostree status > status.txt
assert_not_file_has_content status.txt StateRoot:
vm_rpmostree status -v > status.txt
assert_file_has_content status.txt StateRoot:
echo "ok status text"
# Also check that we can do status as non-root non-active
vm_cmd runuser -u bin rpm-ostree status
echo "ok status doesn't require active PAM session"
@ -78,6 +104,31 @@ echo "ok status doesn't require active PAM session"
vm_cmd rpm-ostree reload
echo "ok reload"
stateroot=$(vm_get_booted_stateroot)
stateroot_dbus=$(echo ${stateroot} | sed -e 's,-,_,')
vm_cmd dbus-send --system --dest=org.projectatomic.rpmostree1 --print-reply=literal /org/projectatomic/rpmostree1/${stateroot_dbus} org.projectatomic.rpmostree1.OSExperimental.Moo boolean:true > moo.txt
assert_file_has_content moo.txt '🐄'
echo "ok moo"
vm_ansible_inline <<EOF
- shell: |
set -xeuo pipefail
rpm-ostree cleanup -p
originpath=\$(ostree admin --print-current-dir).origin
cp -a \${originpath}{,.orig}
echo "unconfigured-state=Access to TestOS requires ONE BILLION DOLLARS" >> \${originpath}
rpm-ostree reload
rpm-ostree status
if rpm-ostree upgrade 2>err.txt; then
echo "Upgraded from unconfigured-state"
exit 1
fi
grep -qFe 'ONE BILLION DOLLARS' err.txt
mv \${originpath}{.orig,}
rpm-ostree reload
EOF
echo "ok unconfigured status"
# https://github.com/projectatomic/rpm-ostree/issues/1301
vm_cmd 'mv /etc/ostree/remotes.d{,.orig}'
vm_cmd systemctl restart rpm-ostreed