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
|
summary: Test basic component tasks
details: |
Verifies that basic snap component operations (install, refresh, remove) work.
systems: [ubuntu-16.04-64, ubuntu-18.04-64, ubuntu-2*, ubuntu-core-*, fedora-*]
execute: |
# Build snap and component
snap pack snap-with-comps/
snap pack comp1/
# Installing component without snap should fail
if snap install --dangerous snap-with-comps+comp1_1.0.comp; then
exit 1
fi
# Install snap
snap install --dangerous snap-with-comps_1.0_all.snap
SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)"
# Check component removed
check_removed() {
local comp_rev=$1
local mnt_point=$SNAP_MOUNT_DIR/snap-with-comps/components/mnt/comp1/${comp_rev}
local comp_inst_path=/var/lib/snapd/snaps/snap-with-comps+comp1_${comp_rev}.comp
mount | not MATCH "^${comp_inst_path/+/\\+} on ${mnt_point} .*"
not stat "$comp_inst_path"
not stat "$mnt_point"
}
# Install local component function
# $1: expected component revision
install_comp() {
# x1 is the snap revision
# Find out previous comp rev
symlink=$SNAP_MOUNT_DIR/snap-with-comps/components/x1/comp1
prev_comp_rev=$(basename "$(readlink "$symlink")")
comp_rev=$1
chg_id=$(snap install --no-wait --dangerous snap-with-comps+comp1_1.0.comp)
snap watch "$chg_id"
# Check component install change was as expected
snap change "$chg_id" | MATCH "^Done .*Prepare component"
snap change "$chg_id" | MATCH "^Done .*Mount component"
snap change "$chg_id" | MATCH "^Done .*Make component .* available to the system"
# File has been copied around
comp_inst_path=/var/lib/snapd/snaps/snap-with-comps+comp1_${comp_rev}.comp
stat "$comp_inst_path"
# Component is mounted (note that we need to escape the "+" in the path)
mnt_point=$SNAP_MOUNT_DIR/snap-with-comps/components/mnt/comp1/${comp_rev}
mount | MATCH "^${comp_inst_path/+/\\+} on ${mnt_point} .*"
# And symlinked
readlink "$symlink" | MATCH "\\.\\./mnt/comp1/$comp_rev"
readlink -f "$symlink" | MATCH "$mnt_point"
# and is seen from snap app
snap-with-comps.test
# Old component is not mounted and has been removed
if [ -n "$prev_comp_rev" ]; then
check_removed "$prev_comp_rev"
fi
}
# Install, then reinstall local component
install_comp x1
install_comp x2
# Check message on installation
snap install --dangerous snap-with-comps+comp1_1.0.comp |
MATCH 'component comp1 1\.0 for snap-with-comps 1\.0 installed'
# Remove the component and check result
snap remove snap-with-comps+comp1
check_removed x3
# Remove the snap
snap remove snap-with-comps
# Reinstall, install component, remove all in one change and check
snap install --dangerous snap-with-comps_1.0_all.snap
install_comp x1
snap remove snap-with-comps
check_removed x1
not test -d "$SNAP_MOUNT_DIR"/snap-with-comps/
snap list | NOMATCH snap-with-comps
|