File: task.yaml

package info (click to toggle)
snapd 2.72-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 80,412 kB
  • sloc: sh: 16,506; ansic: 16,211; python: 11,213; makefile: 1,919; exp: 190; awk: 58; xml: 22
file content (47 lines) | stat: -rw-r--r-- 2,027 bytes parent folder | download | duplicates (3)
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
summary: Checks handling of common snap directories of parallel installed snaps

details: |
    Snapd allows installation of the same snap more than once by combining the
    same snap name with different values of an instance key.

    Installation of a snap under an instance key is somewhat different than
    installation of a snap with an empty instance key, because the a set of
    directories without the key must also be created as anchor points for the
    bind mount system used at runtime.

    The test installs a specially crafted snap, which fails to install
    correctly, with an instance key and observes that the directories that do
    not contain the instance key, but are required for operation, are removed by
    the undo handler of the appropriate task.

prepare: |
    snap set system experimental.parallel-instances=true

restore: |
    snap set system experimental.parallel-instances=null

execute: |
    # the snap is named 'test-snapd-service'
    path="$("$TESTSTOOLS"/snaps-state pack-local test-snapd-service-v2-bad)"
    test -n "$path"

    echo "Given a snap that fails to install"
    not snap install --dangerous "$path"
    snap change --last=install | MATCH 'Error.*Start snap "test-snapd-service" \(unset\) services'

    echo "Shared snap directories are cleaned up in undo"
    SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)"
    not test -d "$SNAP_MOUNT_DIR/test-snapd-service"
    not test -d "/var/snap/test-snapd-service"

    echo "Given a snap with instance key foo that fails to install"
    not snap install --dangerous --name test-snapd-service_foo "$path"
    snap change --last=install | MATCH 'Error.*Start snap "test-snapd-service_foo" \(unset\) services'

    echo "Instance foo directories are cleaned up"
    not test -d "$SNAP_MOUNT_DIR/test-snapd-service_foo"
    not test -d "/var/snap/test-snapd-service_foo"

    echo "Shared snap directories are cleaned up as well"
    not test -d "$SNAP_MOUNT_DIR/test-snapd-service"
    not test -d "/var/snap/test-snapd-service"