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 (98 lines) | stat: -rw-r--r-- 5,081 bytes parent folder | download | duplicates (2)
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
95
96
97
98
summary: Check parallel installation of sideloaded snaps containing services

details: |
    Check that snaps with services can have parallel installations and that
    removing one instance does not affect the others.

# takes >3min to run
backends: [-autopkgtest]

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

restore: |
    snap remove --purge test-snapd-service || true
    snap remove --purge test-snapd-service_foo || true
    snap remove --purge test-snapd-service_longname || true
    snap unset system experimental.parallel-instances

execute: |
    "$TESTSTOOLS"/snaps-state install-local test-snapd-service

    check_services_active() {
       test -n "$1"
       systemctl is-active "snap.$1.test-snapd-service.service"
       systemctl is-active "snap.$1.test-snapd-other-service.service"
    }

    SNAP_MOUNT_DIR="$(os.paths snap-mount-dir)"
    for instance in foo longname; do
        echo "Install a snap as instance named test-snapd-service_$instance"
        expected="^test-snapd-service_$instance 1.0 installed\$"
        "$TESTSTOOLS"/snaps-state install-local-as test-snapd-service "test-snapd-service_$instance" | MATCH "$expected"

        test -d "$SNAP_MOUNT_DIR/test-snapd-service_$instance/x1"

        test -f /etc/systemd/system/snap.test-snapd-service_$instance.test-snapd-service.service
        test -f /etc/systemd/system/snap.test-snapd-service_$instance.test-snapd-other-service.service
        check_services_active "test-snapd-service_$instance"
    done

    check_services_active test-snapd-service

    echo "All snaps are listed"
    snap list | MATCH '^test-snapd-service '
    snap list | MATCH '^test-snapd-service_foo '
    snap list | MATCH '^test-snapd-service_longname '

    echo "Ensure we can use snapctl to stop a service of the main installation, but not affect others"
    snap run --shell test-snapd-service -c "snapctl stop test-snapd-service.test-snapd-other-service"
    systemctl is-active snap.test-snapd-service.test-snapd-other-service | MATCH "inactive"
    systemctl is-active snap.test-snapd-service_foo.test-snapd-other-service | MATCH "^active"
    systemctl is-active snap.test-snapd-service_longname.test-snapd-other-service | MATCH "^active"

    echo "Ensure we can start it again"
    snap run --shell test-snapd-service -c "snapctl start test-snapd-service.test-snapd-other-service"
    systemctl is-active snap.test-snapd-service.test-snapd-other-service | MATCH "^active"
    systemctl is-active snap.test-snapd-service_foo.test-snapd-other-service | MATCH "^active"
    systemctl is-active snap.test-snapd-service_longname.test-snapd-other-service | MATCH "^active"

    echo "Ensure we can use snapctl to stop a service in parallel installs without affecting others"
    for instance in foo longname; do
        echo "Testing stop of test-snapd-service_$instance"
        systemctl is-active "snap.test-snapd-service_${instance}.test-snapd-other-service" | MATCH "^active"
        snap run --shell test-snapd-service_${instance} -c "snapctl stop test-snapd-service_${instance}.test-snapd-other-service"
        systemctl is-active "snap.test-snapd-service_${instance}.test-snapd-other-service" | MATCH "inactive"
    done

    echo "Verifying the main install should be unaffected after stop"
    systemctl is-active snap.test-snapd-service.test-snapd-other-service | MATCH "^active"

    for instance in foo longname; do
        echo "Testing start of test-snapd-service_$instance"
        systemctl is-active "snap.test-snapd-service_${instance}.test-snapd-other-service" | MATCH "inactive"
        snap run --shell test-snapd-service_${instance} -c "snapctl start test-snapd-service_${instance}.test-snapd-other-service"
        systemctl is-active "snap.test-snapd-service_${instance}.test-snapd-other-service" | MATCH "^active"
    done

    echo "Verifying snap can only manage its own services"
    snap run --shell test-snapd-service_foo -c "snapctl stop test-snapd-service.test-snapd-other-service" |& MATCH "snapctl: unknown service"

    echo "Removing one instance does not remove services from other instances"
    snap remove --purge test-snapd-service_foo
    not test -f /etc/systemd/system/snap.test-snapd-service_foo.test-snapd-service.service
    test -f /etc/systemd/system/snap.test-snapd-service_longname.test-snapd-service.service
    test -f /etc/systemd/system/snap.test-snapd-service.test-snapd-service.service

    echo "The services of remaining snaps are still active"
    check_services_active test-snapd-service
    check_services_active test-snapd-service_longname

    snap remove --purge test-snapd-service
    not test -f /etc/systemd/system/snap.test-snapd-service.test-snapd-service.service
    test -f /etc/systemd/system/snap.test-snapd-service_longname.test-snapd-service.service
    echo "The services of remaining snap are active"
    check_services_active test-snapd-service_longname

    snap remove --purge test-snapd-service_longname
    not test -f /etc/systemd/system/snap.test-snapd-service_longname.test-snapd-service.service