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 (94 lines) | stat: -rw-r--r-- 3,581 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
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
82
83
84
85
86
87
88
89
90
91
92
93
94
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 number of instances (with and without the instance key)
    and removes them one by one, ensuring that in all cases the common directory
    is only removed once all instances are gone.

# slow in autopkgtest (>1m)
backends: [-autopkgtest]

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

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

execute: |
    echo "Install a snap with instance key set"
    "$TESTSTOOLS"/snaps-state install-local-as test-snapd-sh test-snapd-sh_foo

    # foo instance directories are present
    SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)"
    test -d "$SNAP_MOUNT_DIR/test-snapd-sh_foo"
    test -d "/var/snap/test-snapd-sh_foo"

    # and so are the common directories
    test -d "$SNAP_MOUNT_DIR/test-snapd-sh"
    test -d "/var/snap/test-snapd-sh"

    # get another revision of test-snapd-sh_foo
    "$TESTSTOOLS"/snaps-state install-local-as test-snapd-sh test-snapd-sh_foo

    # install instance-key-less snap
    "$TESTSTOOLS"/snaps-state install-local test-snapd-sh

    # and a bar instance
    "$TESTSTOOLS"/snaps-state install-local-as test-snapd-sh test-snapd-sh_bar
    # bar instance directories are present
    test -d "$SNAP_MOUNT_DIR/test-snapd-sh_bar"
    test -d "/var/snap/test-snapd-sh_bar"

    # remove foo instance, rev x1
    snap remove --revision=x1 test-snapd-sh_foo
    # foo instance directories are present
    test -d "$SNAP_MOUNT_DIR/test-snapd-sh_foo"
    test -d "/var/snap/test-snapd-sh_foo"
    # and so are the common directories, required by other revision of foo
    # instance and other snaps
    test -d "$SNAP_MOUNT_DIR/test-snapd-sh"
    test -d "/var/snap/test-snapd-sh"

    # remove foo instance snap
    snap remove --purge test-snapd-sh_foo
    # foo instance directories should be gone now
    not test -d "$SNAP_MOUNT_DIR/test-snapd-sh_foo"
    not test -d "/var/snap/test-snapd-sh_foo"
    # common directories are still around, required by test-snapd-sh and
    # test-snapd-sh_bar
    test -d "$SNAP_MOUNT_DIR/test-snapd-sh"
    test -d "/var/snap/test-snapd-sh"

    # remove instance-key-less one
    snap remove --purge test-snapd-sh
    # common directories are still around, required by test-snapd-sh_bar
    test -d "$SNAP_MOUNT_DIR/test-snapd-sh"
    test -d "/var/snap/test-snapd-sh"

    # remove bar instance
    snap remove --purge test-snapd-sh_bar
    not test -d "$SNAP_MOUNT_DIR/test-snapd-sh_bar"
    not test -d "/var/snap/test-snapd-sh_bar"

    # common directors should be gone now too
    not test -d "$SNAP_MOUNT_DIR/test-snapd-sh"
    not test -d "/var/snap/test-snapd-sh"

    # make sure that the sole snap without instance key is handled correctly too
    "$TESTSTOOLS"/snaps-state install-local test-snapd-sh
    # another revision
    "$TESTSTOOLS"/snaps-state install-local test-snapd-sh
    test -d "$SNAP_MOUNT_DIR/test-snapd-sh"
    test -d "/var/snap/test-snapd-sh"
    snap remove --purge test-snapd-sh
    not test -d "$SNAP_MOUNT_DIR/test-snapd-sh"
    not test -d "/var/snap/test-snapd-sh"