2017-03-31 16:07:29 +03:00
#!/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.
2017-10-01 16:34:23 +03:00
set -euo pipefail
2017-03-31 16:07:29 +03:00
. ${ commondir } /libtest.sh
. ${ commondir } /libvm.sh
set -x
vm_assert_layered_pkg foo absent
2017-06-29 17:11:25 +03:00
vm_assert_layered_pkg bar absent
vm_build_rpm foo
2018-09-06 23:09:04 +03:00
foo_rpm = /var/tmp/vmcheck/yumrepo/packages/x86_64/foo-1.0-1.x86_64.rpm
2017-03-31 16:07:29 +03:00
2017-06-29 17:11:25 +03:00
vm_build_rpm bar
2018-09-06 23:09:04 +03:00
bar_rpm = /var/tmp/vmcheck/yumrepo/packages/x86_64/bar-1.0-1.x86_64.rpm
2017-03-31 16:07:29 +03:00
# We cheat a bit here and don't actually reboot the system. Instead, we just
# check that then pending deployment looks sane.
# UPGRADE
commit = $( vm_cmd ostree commit -b vmcheck --tree= ref = vmcheck)
2019-05-01 17:07:31 +03:00
vm_status_watch_start
2017-06-29 17:11:25 +03:00
vm_rpmostree upgrade --install bar --install $foo_rpm
2019-05-01 17:07:31 +03:00
vm_status_watch_check " Transaction: upgrade --install bar --install $foo_rpm "
2017-03-31 16:07:29 +03:00
vm_assert_status_jq \
" .deployments[0][\"base-checksum\"] == \" ${ commit } \" " \
'.deployments[0]["packages"]|length == 1' \
2017-06-29 17:11:25 +03:00
'.deployments[0]["packages"]|index("bar") >= 0' \
2017-03-31 16:07:29 +03:00
'.deployments[0]["requested-local-packages"]|length == 1' \
'.deployments[0]["requested-local-packages"]|index("foo-1.0-1.x86_64") >= 0'
vm_rpmostree cleanup -p
2017-06-29 17:11:25 +03:00
echo "ok upgrade with bar and local foo"
2017-03-31 16:07:29 +03:00
# DEPLOY
commit = $( vm_cmd ostree commit -b vmcheck --tree= ref = vmcheck \
--add-metadata-string= version = SUPADUPAVERSION)
2019-05-01 17:07:31 +03:00
vm_status_watch_start
2017-06-29 17:11:25 +03:00
vm_rpmostree deploy SUPADUPAVERSION --install foo --install $bar_rpm
2019-05-01 17:07:31 +03:00
vm_status_watch_check " Transaction: deploy SUPADUPAVERSION --install foo --install $bar_rpm "
2017-03-31 16:07:29 +03:00
vm_assert_status_jq \
" .deployments[0][\"base-checksum\"] == \" ${ commit } \" " \
'.deployments[0]["version"] == "SUPADUPAVERSION"' \
'.deployments[0]["packages"]|length == 1' \
'.deployments[0]["packages"]|index("foo") >= 0' \
'.deployments[0]["requested-local-packages"]|length == 1' \
2017-06-29 17:11:25 +03:00
'.deployments[0]["requested-local-packages"]|index("bar-1.0-1.x86_64") >= 0'
2017-03-31 16:07:29 +03:00
vm_rpmostree cleanup -p
2017-06-29 17:11:25 +03:00
echo "ok deploy with foo and local bar"
2017-03-31 16:07:29 +03:00
# REBASE
commit = $( vm_cmd ostree commit -b vmcheck_tmp/rebase \
--tree= ref = vmcheck --add-metadata-string= version = SUPADUPAVERSION)
2019-05-01 17:07:31 +03:00
vm_status_watch_start
2017-03-31 16:07:29 +03:00
vm_rpmostree rebase vmcheck_tmp/rebase SUPADUPAVERSION \
2017-06-29 17:11:25 +03:00
--install bar --install $foo_rpm
2019-05-01 17:07:31 +03:00
vm_status_watch_check " Transaction: rebase vmcheck_tmp/rebase SUPADUPAVERSION --install bar --install $foo_rpm "
2017-03-31 16:07:29 +03:00
vm_assert_status_jq \
" .deployments[0][\"base-checksum\"] == \" ${ commit } \" " \
'.deployments[0]["origin"] == "vmcheck_tmp/rebase"' \
'.deployments[0]["version"] == "SUPADUPAVERSION"' \
'.deployments[0]["packages"]|length == 1' \
2017-06-29 17:11:25 +03:00
'.deployments[0]["packages"]|index("bar") >= 0' \
2017-03-31 16:07:29 +03:00
'.deployments[0]["requested-local-packages"]|length == 1' \
'.deployments[0]["requested-local-packages"]|index("foo-1.0-1.x86_64") >= 0'
vm_rpmostree cleanup -p
2017-06-29 17:11:25 +03:00
echo "ok rebase with bar and local foo"
2017-03-31 16:07:29 +03:00
# PKG CHANGES
2019-05-01 17:07:31 +03:00
vm_status_watch_start
2017-03-31 16:07:29 +03:00
vm_rpmostree install $foo_rpm
2019-05-01 17:07:31 +03:00
vm_status_watch_check " Transaction: install $foo_rpm "
2017-03-31 16:07:29 +03:00
vm_assert_status_jq \
'.deployments[0]["packages"]|length == 0' \
'.deployments[0]["requested-local-packages"]|length == 1' \
'.deployments[0]["requested-local-packages"]|index("foo-1.0-1.x86_64") >= 0'
2019-05-01 17:07:31 +03:00
vm_status_watch_start
2017-06-29 17:11:25 +03:00
vm_rpmostree uninstall foo-1.0-1.x86_64 --install bar
2019-05-01 17:07:31 +03:00
vm_status_watch_check "Transaction: uninstall foo-1.0-1.x86_64 --install bar"
2017-03-31 16:07:29 +03:00
vm_assert_status_jq \
'.deployments[0]["packages"]|length == 1' \
2017-06-29 17:11:25 +03:00
'.deployments[0]["packages"]|index("bar") >= 0' \
2017-03-31 16:07:29 +03:00
'.deployments[0]["requested-local-packages"]|length == 0'
2017-06-29 17:11:25 +03:00
vm_rpmostree install foo --uninstall bar
2017-03-31 16:07:29 +03:00
vm_assert_status_jq \
'.deployments[0]["packages"]|length == 1' \
'.deployments[0]["packages"]|index("foo") >= 0' \
'.deployments[0]["requested-local-packages"]|length == 0'
vm_rpmostree cleanup -p
echo "ok simultaneous pkg changes"