Skip to content

Commit 7245ca8

Browse files
committed
tests: Move code into new function remove_all_snapshots
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
1 parent 3c9a81d commit 7245ca8

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

script/tests/test_encryption.sh

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,20 @@ pullImages() {
210210
failExit $? "Image layerinfo on plain image failed"
211211
}
212212

213+
remove_all_snapshots()
214+
{
215+
local v
216+
217+
# to avoid caching effects of the image we just decrypted and then exported,
218+
# remove all snapshots to simulate a clean system for import
219+
# The following is a brute-force removal ignoring dependencies
220+
while [ -n "$($CTR snapshot ls | tail -n +2)" ]; do
221+
for v in $($CTR snapshot ls | tail -n +2 | cut -d" " -f1); do
222+
$CTR snapshot rm $v &>/dev/null
223+
done
224+
done
225+
}
226+
213227
setupPGP() {
214228
GPGHOMEDIR=${WORKDIR}/gpg2
215229

@@ -312,14 +326,9 @@ testPGP() {
312326

313327
# remove ${ALPINE} and ${ALPINE_ENC} to clear cached and so we need to decrypt
314328
$CTR images rm --sync ${ALPINE} ${ALPINE_ENC} &>/dev/null
315-
# to avoid caching effects of the image we just decrypted and then exported,
316-
# remove all snapshots to simulate a clean system for import
317-
# The following is a brute-force removal ignoring dependencies
318-
while [ -n "$($CTR snapshot ls | tail -n +2)" ]; do
319-
for v in $($CTR snapshot ls | tail -n +2 | cut -d" " -f1); do
320-
$CTR snapshot rm $v &>/dev/null
321-
done
322-
done
329+
330+
remove_all_snapshots
331+
323332

324333
$CTR images import \
325334
--all-platforms \

0 commit comments

Comments
 (0)