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
|
summary: Check that the refresh data copy works.
details: |
Snapd implements a system, where a refreshed snap's data associated with a
particular revision is copied to the revision that a snap is being refreshed
to. This allows the snap to perform destructive data manipulations, like
schema changes, while simultaneously allowing the user to revert to the
previously used revision for both the application code and user data.
The test checks that snap user data is correctly copied for both root and
non-root users.
execute: |
echo "For an installed snap"
snap install test-snapd-sh
rev=$(snap list test-snapd-sh|tail -n1|tr -s ' '|cut -f3 -d' ')
homes=(/root/ /home/test/)
echo "That has some user data"
for h in "${homes[@]}"; do
test -d "$h"
d="${h}snap/test-snapd-sh/$rev"
mkdir -p "$d"
touch "$d/mock-data"
chown --recursive --reference="$h" "${h}snap/"
done
echo "When the snap is refreshed"
snap refresh --channel=edge test-snapd-sh
new_rev=$(snap list test-snapd-sh|tail -n1|tr -s ' '|cut -f3 -d' ')
echo "Then the user data gets copied"
for h in "${homes[@]}"; do
test -e "${h}snap/test-snapd-sh/$new_rev/mock-data"
test -e "${h}snap/test-snapd-sh/$rev/mock-data"
done
echo "When the snap is removed"
snap remove --purge test-snapd-sh
echo "Then all user data and root data is gone"
for h in "${homes[@]}"; do
test ! -e "${h}snap/test-snapd-sh/$new_rev/mock-data"
test ! -e "${h}snap/test-snapd-sh/$rev/mock-data"
done
|