forked from coreos/rpm-ostree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-layering-unified.sh
executable file
·116 lines (97 loc) · 4.38 KB
/
test-layering-unified.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/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_assert_layered_pkg bar absent
vm_build_rpm foo
foo_rpm=/var/tmp/vmcheck/yumrepo/packages/x86_64/foo-1.0-1.x86_64.rpm
vm_build_rpm bar
bar_rpm=/var/tmp/vmcheck/yumrepo/packages/x86_64/bar-1.0-1.x86_64.rpm
# 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 --bootable)
vm_status_watch_start
vm_rpmostree upgrade --install bar --install $foo_rpm
vm_status_watch_check "Transaction: upgrade --install bar --install $foo_rpm"
vm_assert_status_jq \
".deployments[0][\"base-checksum\"] == \"${commit}\"" \
'.deployments[0]["packages"]|length == 1' \
'.deployments[0]["packages"]|index("bar") >= 0' \
'.deployments[0]["requested-local-packages"]|length == 1' \
'.deployments[0]["requested-local-packages"]|index("foo-1.0-1.x86_64") >= 0'
vm_rpmostree cleanup -p
echo "ok upgrade with bar and local foo"
# DEPLOY
commit=$(vm_cmd ostree commit -b vmcheck --tree=ref=vmcheck --bootable \
--add-metadata-string=version=SUPADUPAVERSION)
vm_status_watch_start
vm_rpmostree deploy SUPADUPAVERSION --install foo --install $bar_rpm
vm_status_watch_check "Transaction: deploy SUPADUPAVERSION --install foo --install $bar_rpm"
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' \
'.deployments[0]["requested-local-packages"]|index("bar-1.0-1.x86_64") >= 0'
vm_rpmostree cleanup -p
echo "ok deploy with foo and local bar"
# REBASE
commit=$(vm_cmd ostree commit -b vmcheck_tmp/rebase --bootable \
--tree=ref=vmcheck --add-metadata-string=version=SUPADUPAVERSION)
vm_status_watch_start
vm_rpmostree rebase vmcheck_tmp/rebase SUPADUPAVERSION \
--install bar --install $foo_rpm
vm_status_watch_check "Transaction: rebase vmcheck_tmp/rebase SUPADUPAVERSION --install bar --install $foo_rpm"
vm_assert_status_jq \
".deployments[0][\"base-checksum\"] == \"${commit}\"" \
'.deployments[0]["origin"] == "vmcheck_tmp/rebase"' \
'.deployments[0]["version"] == "SUPADUPAVERSION"' \
'.deployments[0]["packages"]|length == 1' \
'.deployments[0]["packages"]|index("bar") >= 0' \
'.deployments[0]["requested-local-packages"]|length == 1' \
'.deployments[0]["requested-local-packages"]|index("foo-1.0-1.x86_64") >= 0'
vm_rpmostree cleanup -p
echo "ok rebase with bar and local foo"
# PKG CHANGES
vm_status_watch_start
vm_rpmostree install $foo_rpm
vm_status_watch_check "Transaction: install $foo_rpm"
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'
vm_status_watch_start
vm_rpmostree uninstall foo-1.0-1.x86_64 --install bar
vm_status_watch_check "Transaction: uninstall foo-1.0-1.x86_64 --install bar"
vm_assert_status_jq \
'.deployments[0]["packages"]|length == 1' \
'.deployments[0]["packages"]|index("bar") >= 0' \
'.deployments[0]["requested-local-packages"]|length == 0'
vm_rpmostree install foo --uninstall bar
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"