Skip to content

Commit 6ba00ae

Browse files
committed
tests/staged-deploy: test --keep-previous option
Signed-off-by: Rafael Fonseca <r4f4rfs@gmail.com>
1 parent 7a9341f commit 6ba00ae

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

tests/kolainst/destructive/staged-deploy.sh

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ EOF
4646
# xref https://github.com/coreos/coreos-assembler/pull/2814
4747
systemctl mask --now zincati
4848
# Create a synthetic commit for upgrade
49-
ostree commit --no-bindings --parent="${commit}" -b staged-deploy -I --consume t
49+
ostree commit --no-bindings --parent="${commit}" -b staged-deploy -I --consume t --add-metadata-string=version=foobar
5050
newcommit=$(ostree rev-parse staged-deploy)
5151
orig_mtime=$(stat -c '%.Y' /sysroot/ostree/deploy)
5252
systemctl show -p SubState ostree-finalize-staged.path | grep -q waiting
@@ -169,8 +169,46 @@ EOF
169169
ostree admin undeploy 1
170170
echo "ok staged retained"
171171

172+
# Deploy a new version
173+
commit=${host_commit}
174+
ostree checkout -H ${commit} t
175+
ostree commit --no-bindings --parent="${commit}" -b same-version -I --consume t --add-metadata-string=version=foobaz
176+
ostree admin deploy same-version --retain-previous-version
177+
178+
# Cleanup refs
179+
ostree refs --delete staged-deploy nonstaged-deploy same-version
180+
echo "ok cleanup refs"
181+
182+
/tmp/autopkgtest-reboot "3"
183+
;;
184+
"3")
185+
# Check currently deployed versions
186+
rpm-ostree status
187+
188+
# Make a new commit with the same version as the previous reboot
189+
commit=$(rpmostree_query_json '.deployments[0].checksum')
190+
cd /ostree/repo/tmp
191+
ostree checkout -H ${commit} t
192+
ostree commit --no-bindings --parent="${commit}" -b same-version-again -I --consume t --add-metadata-string=version=foobaz
193+
ostree admin deploy same-version-again --retain-previous-version
194+
195+
# Check that previous version was kept
196+
ostree admin status > status.txt
197+
test $(grep -Fce 'Version: ' status.txt) = 3
198+
echo "ok previous version retained"
199+
200+
# Check also for the staging path
201+
rpm-ostree cleanup -p
202+
ostree admin deploy --stage same-version-again --retain-previous-version
203+
ostree admin finalize-staged
204+
205+
# Check that previous version was kept
206+
ostree admin status > status.txt
207+
test $(grep -Fce 'Version: ' status.txt) = 3
208+
echo "ok previous version retained during stage"
209+
172210
# Cleanup refs
173-
ostree refs --delete staged-deploy nonstaged-deploy
211+
ostree refs --delete same-version-again
174212
echo "ok cleanup refs"
175213

176214
# Now finally, try breaking staged updates and verify that ostree-boot-complete fails on the next boot

0 commit comments

Comments
 (0)