tests: Add RPMs to installed kola tests, port layering-local
I'd like to get to the point where we drop the `vmcheck.sh`/`libvm.sh` stuff. Instead we use kola directly, and write our tests in a way that they default to run on the target, not on the host because it's *much* more natural to type e.g. `rpm-ostree upgrade` instead of `vm_rpmostree upgrade`. We'd done a bit of porting, but a blocker was that a lot of our tests dynamically generate RPMs and send them over. Instead, let's generate the RPMs ahead of time in a "build" step, then they all get passed at once via kola ext data. Add the concept of multiple repo versions too. Right now we only generate the one RPM needed for the `layering-local` test and port it.
This commit is contained in:
parent
6b13f2596c
commit
85f22baec7
@ -338,6 +338,14 @@ assert_jq() {
|
||||
done
|
||||
}
|
||||
|
||||
# Takes a list of `jq` expressions, each of which should evaluate to a boolean,
|
||||
# and asserts that they are true.
|
||||
rpmostree_assert_status() {
|
||||
rpm-ostree status --json > status.json
|
||||
assert_jq status.json "$@"
|
||||
rm -f status.json
|
||||
}
|
||||
|
||||
# This function below was taken and adapted from coreos-assembler. We
|
||||
# should look into sharing this code more easily.
|
||||
|
||||
|
1
tests/kolainst/.gitignore
vendored
Normal file
1
tests/kolainst/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
rpm-repos/
|
@ -4,12 +4,15 @@ TESTDIRS := $(shell find -mindepth 1 -maxdepth 1 -type d)
|
||||
|
||||
KOLA_TESTDIR = $(DESTDIR)/usr/lib/coreos-assembler/tests/kola/rpm-ostree/
|
||||
|
||||
all:
|
||||
@echo "No build step"
|
||||
rpm-repos: kolainst-build.sh
|
||||
./kolainst-build.sh
|
||||
|
||||
install:
|
||||
all: rpm-repos
|
||||
|
||||
install: all
|
||||
install -d -m 0755 $(KOLA_TESTDIR)
|
||||
rsync -prlv ./nondestructive $(KOLA_TESTDIR)/
|
||||
rsync -prlv ./destructive $(KOLA_TESTDIR)/
|
||||
rsync -prlv ../common/*.sh $(KOLA_TESTDIR)/nondestructive/data/
|
||||
rsync -prlv ../common/*.sh $(KOLA_TESTDIR)/destructive/data/
|
||||
rsync -prlv rpm-repos/ $(KOLA_TESTDIR)/destructive/data/rpm-repos/
|
||||
|
101
tests/kolainst/destructive/layering-local
Executable file
101
tests/kolainst/destructive/layering-local
Executable file
@ -0,0 +1,101 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2017 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
|
||||
|
||||
. ${KOLA_EXT_DATA}/libtest.sh
|
||||
|
||||
set -x
|
||||
cd $(mktemp -d)
|
||||
|
||||
case "${AUTOPKGTEST_REBOOT_MARK:-}" in
|
||||
"")
|
||||
|
||||
if rpm -q foo 2>/dev/null; then
|
||||
fatal "found foo"
|
||||
fi
|
||||
|
||||
# Disable repos, no Internet access should be required
|
||||
rm -rf /etc/yum.repos.d/
|
||||
booted_commit=$(rpm-ostree status --json | jq -r '.deployments[0].checksum')
|
||||
ostree refs ${booted_commit} --create vmcheck
|
||||
rpm-ostree rebase :vmcheck
|
||||
ostree refs ${booted_commit} --create vmcheck_tmp/without_foo
|
||||
rpm-ostree install ${KOLA_EXT_DATA}/rpm-repos/0/packages/x86_64/foo-1.2-3.x86_64.rpm
|
||||
rpmostree_assert_status '.deployments[0]["packages"]|length == 0' \
|
||||
'.deployments[0]["requested-packages"]|length == 0' \
|
||||
'.deployments[0]["requested-local-packages"]|length == 1' \
|
||||
'.deployments[0]["live-inprogress"]|not' \
|
||||
'.deployments[0]["live-replaced"]|not'
|
||||
echo "ok install foo locally"
|
||||
/tmp/autopkgtest-reboot "1"
|
||||
;;
|
||||
"1")
|
||||
rpmostree_assert_status '.deployments[0]["packages"]|length == 0' \
|
||||
'.deployments[0]["requested-packages"]|length == 0' \
|
||||
'.deployments[0]["requested-local-packages"]|length == 1' \
|
||||
'.deployments[0]["live-inprogress"]|not' \
|
||||
'.deployments[0]["live-replaced"]|not'
|
||||
assert_streq $(rpm -q foo) foo-1.2-3.x86_64
|
||||
echo "ok pkg foo added locally"
|
||||
|
||||
# check we could uninstall the package using either its NEVRA or name
|
||||
rpm-ostree uninstall foo-1.2-3.x86_64
|
||||
rpmostree_assert_status '.deployments[0]["requested-local-packages"]|length == 0'
|
||||
rpm-ostree cleanup -p
|
||||
rpm-ostree uninstall foo
|
||||
rpmostree_assert_status '.deployments[0]["requested-local-packages"]|length == 0'
|
||||
rpm-ostree cleanup -p
|
||||
echo "ok uninstall by NEVRA or name"
|
||||
|
||||
# check that we can still request foo and it's dormant
|
||||
rpm-ostree install foo
|
||||
|
||||
rpmostree_assert_status '.deployments[0]["packages"]|length == 0' \
|
||||
'.deployments[0]["requested-packages"]|length == 1' \
|
||||
'.deployments[0]["requested-local-packages"]|length == 1'
|
||||
echo "ok request foo"
|
||||
|
||||
# check that uninstalling the local rpm makes us go back to repos
|
||||
rpm-ostree uninstall foo-1.2-3.x86_64
|
||||
|
||||
rpmostree_assert_status '.deployments[0]["packages"]|length == 1' \
|
||||
'.deployments[0]["requested-packages"]|length == 1' \
|
||||
'.deployments[0]["requested-local-packages"]|length == 0'
|
||||
echo "ok layer foo back from repos"
|
||||
|
||||
# check that trying to install a package already in the base errors out
|
||||
booted_commit=$(rpm-ostree status --json | jq -r '.deployments[0].checksum')
|
||||
ostree refs ${booted_commit} --create vmcheck_tmp/with_foo
|
||||
ostree commit -b vmcheck --tree=ref=vmcheck_tmp/with_foo
|
||||
rpm-ostree uninstall foo
|
||||
rpm-ostree upgrade # upgrades to new base which has foo
|
||||
if rpm-ostree install ${KOLA_EXT_DATA}/rpm-repos/0/packages/x86_64/foo-1.2-3.x86_64.rpm; then
|
||||
assert_not_reached "didn't error out when trying to install same pkg"
|
||||
fi
|
||||
echo "ok error on layering same pkg in base"
|
||||
|
||||
# check that installing local RPMs without any repos available works
|
||||
ostree commit -b vmcheck --tree=ref=vmcheck_tmp/without_foo
|
||||
rpm-ostree upgrade
|
||||
rpm-ostree install ${KOLA_EXT_DATA}/rpm-repos/0/packages/x86_64/foo-1.2-3.x86_64.rpm
|
||||
echo "ok layer local foo without repos"
|
||||
;;
|
||||
*) echo "unexpected mark: ${AUTOPKGTEST_REBOOT_MARK}"; exit 1;;
|
||||
esac
|
21
tests/kolainst/kolainst-build.sh
Executable file
21
tests/kolainst/kolainst-build.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
# This pre-generates RPMs for testing that will be provided
|
||||
# to the kola tests as data/, so we don't need to rpmbuild.
|
||||
set -euo pipefail
|
||||
dn=$(cd "$(dirname "$0")" && pwd)
|
||||
topsrcdir=$(git rev-parse --show-toplevel)
|
||||
commondir=$(cd "$dn/../common" && pwd)
|
||||
export topsrcdir commondir
|
||||
. "${commondir}/libtest.sh"
|
||||
|
||||
rm rpm-repos -rf
|
||||
mkdir rpm-repos
|
||||
|
||||
test_tmpdir=$(mktemp -d)
|
||||
repover=0
|
||||
|
||||
# Right now we build just one rpm, with one repo version,
|
||||
# but the idea is to extend this with more.
|
||||
mkdir rpm-repos/${repover}
|
||||
build_rpm foo version 1.2 release 3
|
||||
mv ${test_tmpdir}/yumrepo/* rpm-repos/${repover}
|
@ -1,90 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (C) 2017 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
|
||||
|
||||
vm_assert_layered_pkg foo absent
|
||||
|
||||
vm_cmd ostree refs $(vm_get_deployment_info 0 checksum) --create vmcheck_tmp/without_foo
|
||||
vm_build_rpm foo version 1.2 release 3
|
||||
vm_rpmostree install /var/tmp/vmcheck/yumrepo/packages/x86_64/foo-1.2-3.x86_64.rpm
|
||||
vm_assert_status_jq '.deployments[0]["packages"]|length == 0' \
|
||||
'.deployments[0]["requested-packages"]|length == 0' \
|
||||
'.deployments[0]["requested-local-packages"]|length == 1' \
|
||||
'.deployments[0]["live-inprogress"]|not' \
|
||||
'.deployments[0]["live-replaced"]|not'
|
||||
echo "ok install foo locally"
|
||||
|
||||
vm_reboot
|
||||
|
||||
vm_assert_status_jq '.deployments[0]["packages"]|length == 0' \
|
||||
'.deployments[0]["requested-packages"]|length == 0' \
|
||||
'.deployments[0]["requested-local-packages"]|length == 1' \
|
||||
'.deployments[0]["live-inprogress"]|not' \
|
||||
'.deployments[0]["live-replaced"]|not'
|
||||
vm_has_local_packages foo-1.2-3.x86_64
|
||||
vm_assert_layered_pkg foo-1.2-3.x86_64 present
|
||||
echo "ok pkg foo added locally"
|
||||
|
||||
# check we could uninstall the package using either its NEVRA or name
|
||||
vm_rpmostree uninstall foo-1.2-3.x86_64
|
||||
vm_assert_status_jq '.deployments[0]["requested-local-packages"]|length == 0'
|
||||
vm_rpmostree cleanup -p
|
||||
vm_rpmostree uninstall foo
|
||||
vm_assert_status_jq '.deployments[0]["requested-local-packages"]|length == 0'
|
||||
vm_rpmostree cleanup -p
|
||||
echo "ok uninstall by NEVRA or name"
|
||||
|
||||
# check that we can still request foo and it's dormant
|
||||
vm_rpmostree install foo
|
||||
|
||||
vm_assert_status_jq '.deployments[0]["packages"]|length == 0'
|
||||
vm_assert_status_jq '.deployments[0]["requested-packages"]|length == 1'
|
||||
vm_assert_status_jq '.deployments[0]["requested-local-packages"]|length == 1'
|
||||
echo "ok request foo"
|
||||
|
||||
# check that uninstalling the local rpm makes us go back to repos
|
||||
vm_rpmostree uninstall foo-1.2-3.x86_64
|
||||
|
||||
vm_assert_status_jq '.deployments[0]["packages"]|length == 1'
|
||||
vm_assert_status_jq '.deployments[0]["requested-packages"]|length == 1'
|
||||
vm_assert_status_jq '.deployments[0]["requested-local-packages"]|length == 0'
|
||||
echo "ok layer foo back from repos"
|
||||
|
||||
# check that trying to install a package already in the base errors out
|
||||
vm_cmd ostree refs $(vm_get_deployment_info 0 checksum) --create vmcheck_tmp/with_foo
|
||||
vm_cmd ostree commit -b vmcheck --tree=ref=vmcheck_tmp/with_foo
|
||||
vm_rpmostree uninstall foo
|
||||
vm_rpmostree upgrade # upgrades to new base which has foo
|
||||
if vm_rpmostree install /var/tmp/vmcheck/yumrepo/packages/x86_64/foo-1.2-3.x86_64.rpm; then
|
||||
assert_not_reached "didn't error out when trying to install same pkg"
|
||||
fi
|
||||
echo "ok error on layering same pkg in base"
|
||||
|
||||
# check that installing local RPMs without any repos available works
|
||||
vm_cmd ostree commit -b vmcheck --tree=ref=vmcheck_tmp/without_foo
|
||||
vm_rpmostree upgrade
|
||||
vm_cmd rm -rf /etc/yum.repos.d/
|
||||
vm_rpmostree install /var/tmp/vmcheck/yumrepo/packages/x86_64/foo-1.2-3.x86_64.rpm
|
||||
echo "ok layer local foo without repos"
|
Loading…
x
Reference in New Issue
Block a user