-
Notifications
You must be signed in to change notification settings - Fork 582
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add auto-install transition test
- Loading branch information
Showing
4 changed files
with
180 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
tests/main/snapd-snap-transition-auto-install/connections-reference.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Interface Plug Slot Notes | ||
audio-playback firefox:audio-playback :audio-playback - | ||
audio-record firefox:audio-record :audio-record - | ||
avahi-observe firefox:avahi-observe :avahi-observe - | ||
bluez fwupd:bluez :bluez - | ||
browser-support firefox:browser-sandbox :browser-support - | ||
camera firefox:camera :camera - | ||
content[gnome-42-2204] firefox:gnome-42-2204 gnome-42-2204:gnome-42-2204 - | ||
content[gtk-3-themes] firefox:gtk-3-themes gtk-common-themes:gtk-3-themes - | ||
content[icon-themes] firefox:icon-themes gtk-common-themes:icon-themes - | ||
content[sound-themes] firefox:sound-themes gtk-common-themes:sound-themes - | ||
cups-control firefox:cups-control :cups-control - | ||
desktop firefox:desktop :desktop - | ||
desktop-legacy firefox:desktop-legacy :desktop-legacy - | ||
gsettings firefox:gsettings :gsettings - | ||
hardware-observe firefox:hardware-observe :hardware-observe - | ||
hardware-observe fwupd:hardware-observe :hardware-observe - | ||
home firefox:home :home - | ||
home fwupd:home :home - | ||
joystick firefox:joystick :joystick - | ||
login-session-observe firefox:login-session-observe :login-session-observe - | ||
mount-control firefox:host-hunspell :mount-control - | ||
network firefox:network :network - | ||
network fwupd:network :network - | ||
network-bind firefox:network-bind :network-bind - | ||
opengl firefox:opengl :opengl - | ||
opengl fwupd:opengl :opengl - | ||
personal-files firefox:dot-mozilla-firefox :personal-files - | ||
polkit fwupd:polkit :polkit - | ||
raw-usb fwupd:raw-usb :raw-usb - | ||
removable-media firefox:removable-media :removable-media - | ||
screen-inhibit-control firefox:screen-inhibit-control :screen-inhibit-control - | ||
shutdown fwupd:shutdown :shutdown - | ||
system-files firefox:etc-firefox :system-files - | ||
system-files firefox:host-usr-share-hunspell :system-files - | ||
system-packages-doc firefox:system-packages-doc :system-packages-doc - | ||
u2f-devices firefox:u2f-devices :u2f-devices - | ||
udisks2 fwupd:udisks2 :udisks2 - | ||
unity7 firefox:unity7 :unity7 - | ||
upower-observe firefox:upower-observe :upower-observe - | ||
upower-observe fwupd:upower-observe :upower-observe - | ||
wayland firefox:wayland :wayland - | ||
x11 firefox:x11 :x11 - |
126 changes: 126 additions & 0 deletions
126
tests/main/snapd-snap-transition-auto-install/task.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
summary: Ensure auto-install based transition to snapd snap works. | ||
|
||
details: | | ||
Ensure that we can transition classic systems to snapd snap | ||
with auto-install of snapd snap from snapd deb or snapd in core | ||
triggered by any snap install. This change was introduced in PR14173. | ||
# Exclude Ubuntu Core systems - require proper remodeling | ||
# Simplify test by limiting system to ubuntu 22.04 amd64 | ||
systems: [ubuntu-22.04-64] | ||
|
||
environment: | ||
SNAPD_SRC/deb: "deb" | ||
SNAPD_SRC/core: "core" | ||
|
||
prepare: | | ||
# remove all snaps to remove snapd | ||
snap remove core | ||
# this is only possible when snapd is the only installed snap | ||
snap remove snapd | ||
# at this point we expect to be running from the deb | ||
systemctl restart snapd.service | ||
# Install deb + core before introduction of snapd auto-install | ||
# on classic systems. | ||
# deb: snapd | Aug 2024 | 2.63+22.04ubuntu0.1 | http://archive.ubuntu.com/ubuntu/pool/main/s/snapd/2.63+22.04ubuntu0.1_amd64.deb | ||
# deb: snapd | Apr 2022 | 2.55.3+22.04 | http://archive.ubuntu.com/ubuntu/pool/main/s/snapd/2.55.3+22.04_amd64.deb | ||
# snap: core | Jun 2024 | 16-2.61.4-20240607 (rev 17200) | https://snapcraft.io/core/releases | ||
# 'deb' : transition snapd deb to re-exec from snapd snap | ||
# 'core': transition re-exec from snapd in core snap to re-exec from snapd snap | ||
if [ "$SNAPD_SRC" = "deb" ]; then | ||
# core < deb, exec snapd deb | ||
apt install -y --allow-downgrades snapd=2.63+22.04ubuntu0.1 | ||
else | ||
# core => deb, re-exec snapd from core snap | ||
apt install -y --allow-downgrades snapd=2.55.3+22.04 | ||
fi | ||
snap install core --revision=17200 # 16-2.61.4-20240607 | ||
execute: | | ||
# check re-exec disabled, exec from snapd deb or re-exec from core snap | ||
snap_mount_dir="$(os.paths snap-mount-dir)" | ||
expect="" | ||
if [ "${SNAP_REEXEC:-}" = "0" ]; then | ||
echo "Ensure re-exec disabled" | ||
expect="DEBUG: re-exec disabled by user" | ||
elif [ "$SNAPD_SRC" = "deb" ]; then | ||
echo "Ensure exec from snapd deb" | ||
expect="DEBUG: snap \(at \"$snap_mount_dir/core/current\"\) is older \(\"2\.61\.4\"\) than distribution package \(\"2\.63\+22\.04ubuntu0\.1\"\)" | ||
else | ||
echo "Ensure re-exec from core snap" | ||
expect="DEBUG: restarting into \"$snap_mount_dir/core/current/usr/bin/snap\"" | ||
fi | ||
SNAPD_DEBUG=1 snap list 2>&1 | MATCH "$expect" | ||
# Install snaps with snaps with complex interface requirements. | ||
# Use specific revisions to pin expected behaviour. | ||
install_snaps() { | ||
snap install firefox --revision=4848 # 130.0-2 | ||
snap install modem-manager --revision=541 # 1.20.0-2 | ||
snap install fwupd --revision=6368 # 1.9.23-12-g92df65c6a | ||
} | ||
# Trigger transition to snapd by installing either deb or core snap that supports snapd auto-install | ||
# For both the deb and the core snap, installation of snapd snap is expected to follow after | ||
# installation of any snap. | ||
change_marker=$(snap changes | wc -l) | ||
expected_changes_after_mark="" | ||
expected_snap_with_snapd_prereq="" | ||
if [ "$SNAPD_SRC" = "deb" ]; then | ||
echo "Update snapd deb and install snaps to trigger auto-install of snapd" | ||
# install snapd deb built during image preparation | ||
sudo dpkg -i "${GOHOME}"/snapd_*.deb | ||
# Install snaps after updating snapd deb to exercise the post PR14173 logic for installing snapd snap. | ||
# The first snap install will trigger the snapd auto-install. | ||
install_snaps | ||
expected_changes_after_mark="3" | ||
expected_snap_with_snapd_prereq="firefox" | ||
else | ||
echo "Install snaps, update core snap and trigger auto-install of snapd with install of hello-world snap" | ||
# install snaps before updating core snap to exercise transition of system slots and plugs | ||
# from provided by core snap to provided by snapd snap | ||
install_snaps | ||
# check connections | ||
snap connections > /tmp/connections-actual.txt | ||
diff -u ./connections-reference.txt /tmp/connections-actual.txt | ||
# install core snap built during image preparation | ||
snap install --dangerous "$TESTSTMP"/core_snap/core_*.snap | ||
# snapd auto-install should happen as prerequisite for hello-world | ||
snap install hello-world | ||
expected_changes_after_mark="5" | ||
expected_snap_with_snapd_prereq="hello-world" | ||
fi | ||
echo "Ensure no change errors during installation" | ||
snap changes | tail -n +"$change_marker" | NOMATCH "Error" | ||
test "$(snap changes | tail -n +"$change_marker" | grep -c "Done")" = "$expected_changes_after_mark" | ||
echo "Ensure snapd snap was successfully automatically installed" | ||
snap list snapd | ||
change=$(snap changes | tail -n +"$change_marker" | grep "Install \"$expected_snap_with_snapd_prereq\"" | awk '{print $1}') | ||
snap change "$change" | NOMATCH "Error" | ||
snap change "$change" | MATCH "INFO Requested daemon restart \(snapd snap\)." | ||
snap change "$change" | MATCH "Automatically connect eligible plugs and slots of snap \"snapd\"" | ||
# check re-exec disabled, exec from snapd deb or re-exec from snapd snap | ||
if [ "${SNAP_REEXEC:-}" = "0" ]; then | ||
echo "Ensure re-exec disabled" | ||
expect="DEBUG: re-exec disabled by user" | ||
elif [ "$SNAPD_SRC" = "deb" ]; then | ||
echo "Ensure exec from snapd deb" | ||
expect="DEBUG: snap \(at \"$snap_mount_dir/snapd/current\"\) is older \(\"2\.[0-9.]*\"\) than distribution package \(\"1337.[0-9.]*\"\)" | ||
else | ||
echo "Ensure re-exec from snapd snap" | ||
expect="DEBUG: restarting into \"$snap_mount_dir/snapd/current/usr/bin/snap\"" | ||
fi | ||
SNAPD_DEBUG=1 snap list 2>&1 | MATCH "$expect" | ||
echo "Ensure expected interface connections" | ||
snap connections > /tmp/connections-actual.txt | ||
diff -u ./connections-reference.txt /tmp/connections-actual.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters