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
|
summary: Check that snap connect with parallel installs works
details: |
Snapd allows installation of the same snap more than once by combining the
same snap name with different values of an instance key.
Another aspect of the instance system is that plugs and slots are specific
to the instance, allowing the system operator to connect or disconnect them
individually.
The test installs a pair of snaps and checks how interface connections are
made between the application snaps and the core snap providing the slots.
The test explores how auto-connection logic works and that the content
interface is connected correctly.
# slow in autopkgtest (>1m)
backends: [-autopkgtest]
prepare: |
snap set system experimental.parallel-instances=true
echo "Install test snaps"
"$TESTSTOOLS"/snaps-state install-local home-consumer
"$TESTSTOOLS"/snaps-state install-local-as home-consumer home-consumer_foo
# the home interface is not autoconnected on all-snap systems
if os.query is-classic; then
snap disconnect home-consumer:home
snap disconnect home-consumer_foo:home
fi
restore: |
snap set system experimental.parallel-instances=null
execute: |
echo "The plug can be connected to a matching slot of OS snap without snap:slot argument"
snap connect home-consumer:home
snap interfaces -i home | MATCH ':home .*home-consumer'
snap tasks --last=connect| MATCH "Connect home-consumer:home to (core|snapd):home"
echo "Instance snap plug can be connected as well"
snap connect home-consumer_foo:home
snap interfaces -i home | MATCH ':home .*home-consumer_foo'
snap tasks --last=connect| MATCH "Connect home-consumer_foo:home to (core|snapd):home"
echo "When non-instance snap plug is disconnected"
snap disconnect home-consumer:home
snap tasks --last=disconnect| MATCH "Disconnect home-consumer:home from (core|snapd):home"
echo "The instance snap plug remains connected"
snap interfaces -i home | MATCH ':home .*home-consumer_foo'
snap disconnect home-consumer_foo:home
snap tasks --last=disconnect| MATCH "Disconnect home-consumer_foo:home from (core|snapd):home"
# NOTE: Those only work when installed from the store as otherwise we don't
# have snap declaration assertion and cannot check if a given connection
# should be allowed.
CONTENT_CONNECTED_PATTERN='test-snapd-content-slot:shared-content-slot +test-snapd-content-plug_foo:shared-content-plug'
echo "The plug side auto-connects when content is installed"
snap install --edge test-snapd-content-slot
snap install --edge test-snapd-content-plug_foo
snap tasks --last=install| MATCH "Mount snap \"test-snapd-content-plug_foo\""
snap interfaces | MATCH "$CONTENT_CONNECTED_PATTERN"
# Remove the content snaps so that we can reinstall them the other way around
snap remove --purge test-snapd-content-plug_foo
snap remove --purge test-snapd-content-slot
echo "The slot side auto-connects when content snap is installed"
snap install --edge test-snapd-content-plug_foo
# test-snapd-content-slot is installed as a dependency
# snap install --edge test-snapd-content-slot
snap interfaces | MATCH "$CONTENT_CONNECTED_PATTERN"
echo "The interface is disconnected when content snap provider is removed"
snap remove --purge test-snapd-content-slot
snap interfaces | MATCH -- '^-\s+test-snapd-content-plug_foo:shared-content-plug$'
|