Files
snapd/tests/main/interfaces-content/task.yaml
Miguel Pires 4a37a20d7b tests: clear snap cache before interfaces-content test
The test was pulling in the core snap which failed to be validated.
This happened because the snap was already in the cache and had
been modified in the prepare stage. Since it was modified, there's
no assertion matching the digest. Clearing the cache fixes the
problem. This was triggered because we recently stopped building
core on i386 so all channels now have the same revision.

Signed-off-by: Miguel Pires <miguel.pires@canonical.com>
2023-10-23 15:59:42 +01:00

64 lines
2.6 KiB
YAML

summary: Ensure that the content sharing interface works.
details: |
The content-sharing interface interface allows a snap to access contents from
other snap
A snap which defines the content sharing plug must be shown in the interfaces list.
The plug must be autoconnected on install and, as usual, must be able to be
reconnected.
# slow in autopkgtest (>4m)
backends: [-autopkgtest]
# This test purges the state which causes the device to reinitialize
# with (potentially) a different core snap. Running this on core will
# also trigger a reboot in the middle of the tests because the new
# core will be applied. So skip the test on core devices.
systems: [-ubuntu-core-*]
prepare: |
echo "Ensure an empty state so that installing test-snapd-content-plug"
echo "will pull in test-snapd-content-slot *and* core"
tests.systemd stop-unit snapd.service
rm -f /var/lib/snapd/state.json
# clear cache to prevent it from being used in the download, because that core
# was modified by the prepare suite and will fail to be validated
rm -f /var/lib/snapd/snaps/core_*
systemctl start snapd
snap wait system seed.loaded
execute: |
echo "When a snap declaring a content sharing plug is installed"
snap install --edge test-snapd-content-plug
echo "Then this pulls in the default provider"
snap list | MATCH test-snapd-content-slot
echo "Then the snap is listed as connected"
snap interfaces -i content | grep -Pzq "test-snapd-content-slot:shared-content-slot +test-snapd-content-plug:shared-content-plug"
echo "And fstab files are created"
[ "$(find /var/lib/snapd/mount -type f -name "*.fstab" | wc -l)" -gt 0 ]
echo "And we can use the shared content"
test-snapd-content-plug.content-plug | grep "Some shared content"
echo "And the current mount profile is the same as the desired mount profile"
# Exclude the rootfs line, which is only in the /run/ fstab
grep -v "x-snapd.origin=rootfs" /run/snapd/ns/snap.test-snapd-content-plug.fstab \
| diff -u - /var/lib/snapd/mount/snap.test-snapd-content-plug.fstab
echo "When the plug is disconnected"
snap disconnect test-snapd-content-plug:shared-content-plug test-snapd-content-slot:shared-content-slot
echo "Then the fstab files are removed"
[ "$(find /var/lib/snapd/mount -type f -name "*.fstab" | wc -l)" -eq 0 ]
echo "When the plug is reconnected"
snap connect test-snapd-content-plug:shared-content-plug test-snapd-content-slot:shared-content-slot
echo "Then the fstab files are recreated"
[ "$(find /var/lib/snapd/mount -type f -name "*.fstab" | wc -l)" -gt 0 ]