mirror of
https://github.com/token2/snapd.git
synced 2026-03-13 11:15:47 -07:00
79 lines
2.9 KiB
YAML
79 lines
2.9 KiB
YAML
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)"
|
|
|
|
# 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
|
|
prev_mnt_point=$SNAP_MOUNT_DIR/snap-with-comps/components/mnt/comp1/${prev_comp_rev}
|
|
prev_comp_inst_path=/var/lib/snapd/snaps/snap-with-comps+comp1_${prev_comp_rev}.comp
|
|
mount | not MATCH "^${prev_comp_inst_path/+/\\+} on ${prev_mnt_point} .*"
|
|
not stat "$prev_comp_inst_path"
|
|
not stat "$prev_mnt_point"
|
|
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'
|
|
|
|
# TODO: add checks for components removals when implemented by snapd
|
|
# For the moment, remove the snap and then manually the components
|
|
snap remove snap-with-comps
|
|
cd /etc/systemd/system/
|
|
systemctl stop -- *'snap\x2dwith\x2dcomps-components-mnt-comp1-x3.mount'
|
|
cd -
|
|
rm /etc/systemd/system/*'-snap\x2dwith\x2dcomps-components-mnt-comp1-x3.mount'
|
|
rm -rf "$SNAP_MOUNT_DIR"/snap-with-comps/
|