rpm-ostree/tests/vmcheck/test-reset.sh
Jonathan Lebon 07ecfca3d9 Add new reset command
Add a new `reset` command that makes it easy to blow away all
customizations: overlays, overrides, and initramfs. One can use flags to
only reset some of the customizations.

I placed this under `ex` out of conservatism. It's a pretty simple
command with simple behaviour, though the features it relies on
(no-layering, no-initramfs) are brand new. We can move it out of there
in a release or two?

Closes: #1387

Closes: #1419
Approved by: cgwalters
2018-06-26 20:32:28 +00:00

109 lines
3.8 KiB
Bash
Executable File

#!/bin/bash
#
# Copyright (C) 2018 Jonathan Lebon <jonathan@jlebon.com>
#
# 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
# add a builtin foobar
vm_build_rpm foo
vm_rpmostree install foo
vm_cmd ostree refs $(vm_get_pending_csum) --create vmcheck_tmp/with_foo
vm_rpmostree cleanup -p
vm_cmd ostree commit -b vmcheck --tree=ref=vmcheck_tmp/with_foo
vm_rpmostree upgrade
# now do some layering, overrides, and initramfs
vm_build_rpm foo version 2.0
vm_build_rpm bar
vm_build_rpm baz
vm_rpmostree override replace --install bar \
--install /tmp/vmcheck/yumrepo/packages/x86_64/baz-1.0-1.x86_64.rpm \
/tmp/vmcheck/yumrepo/packages/x86_64/foo-2.0-1.x86_64.rpm
vm_rpmostree initramfs --enable
vm_reboot
vm_assert_status_jq \
'.deployments[0].booted' \
'.deployments[0]["packages"]|length == 1' \
'.deployments[0]["requested-packages"]|length == 1' \
'.deployments[0]["requested-local-packages"]|length == 1' \
'.deployments[0]["base-local-replacements"]|length == 1' \
'.deployments[0]["regenerate-initramfs"]'
echo "ok setup"
# check removing layering only
vm_rpmostree ex reset --overlays
vm_assert_status_jq \
'.deployments[0]["packages"]|length == 0' \
'.deployments[0]["requested-packages"]|length == 0' \
'.deployments[0]["requested-local-packages"]|length == 0' \
'.deployments[0]["base-local-replacements"]|length == 1' \
'.deployments[0]["regenerate-initramfs"]'
vm_rpmostree cleanup -p
echo "ok reset overlays"
# check removing overrides only
vm_rpmostree ex reset --overrides
vm_assert_status_jq \
'.deployments[0]["packages"]|length == 1' \
'.deployments[0]["requested-packages"]|length == 1' \
'.deployments[0]["requested-local-packages"]|length == 1' \
'.deployments[0]["base-local-replacements"]|length == 0' \
'.deployments[0]["regenerate-initramfs"]'
vm_rpmostree cleanup -p
echo "ok reset overrides"
# check stopping initramfs only
vm_rpmostree ex reset --initramfs
vm_assert_status_jq \
'.deployments[0]["packages"]|length == 1' \
'.deployments[0]["requested-packages"]|length == 1' \
'.deployments[0]["requested-local-packages"]|length == 1' \
'.deployments[0]["base-local-replacements"]|length == 1' \
'.deployments[0]["regenerate-initramfs"]|not'
vm_rpmostree cleanup -p
echo "ok reset initramfs"
# all together now
vm_rpmostree ex reset
vm_assert_status_jq \
'.deployments[0]["packages"]|length == 0' \
'.deployments[0]["requested-packages"]|length == 0' \
'.deployments[0]["requested-local-packages"]|length == 0' \
'.deployments[0]["base-local-replacements"]|length == 0' \
'.deployments[0]["regenerate-initramfs"]|not'
vm_rpmostree cleanup -p
echo "ok reset EVERYTHING"
# reset everything and overlay at the same time
vm_build_rpm a-new-package
vm_rpmostree ex reset --install a-new-package
vm_assert_status_jq \
'.deployments[0]["packages"]|length == 1' \
'.deployments[0]["packages"]|index("a-new-package") >= 0' \
'.deployments[0]["requested-packages"]|length == 1' \
'.deployments[0]["requested-local-packages"]|length == 0' \
'.deployments[0]["base-local-replacements"]|length == 0' \
'.deployments[0]["regenerate-initramfs"]|not'
echo "ok reset --install"