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 (66 lines) | stat: -rw-r--r-- 2,673 bytes parent folder | download
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
summary: Check that root can activate the session agent via socket activation

details: |
    This test demonstrates that the session-agent service unit is activated
    when we issue a query to the /run/user/<UID>/snapd-session-agent.socket
    socket as root.

    It is also checks that if we manually stop the session-agent, it can be
    restarted via socket activation and the user running the session agent
    can also communicate with it.    

systems:
    # Ubuntu 14.04 does not have a complete systemd implementation
    - -ubuntu-14.04-*
    # Systemd on Amazon Linux 2 does not have the user@uid unit
    - -amazon-linux-2-*
    # fails regularly with "curl: Recv failure: connection reset by peer"
    - -ubuntu-core-16-*

prepare: |
    # Ensure that snapd.session-agent.socket is enabled.  This may not
    # be the case on distributions where presets have been used to
    # disable it.
    if [ ! -L /usr/lib/systemd/user/sockets.target.wants/snapd.session-agent.socket ] &&
            ! systemctl --user --global is-enabled snapd.session-agent.socket; then
        systemctl --user --global enable snapd.session-agent.socket
        touch agent-was-enabled
    fi

    snap install --devmode --edge test-snapd-curl
    snap alias test-snapd-curl.curl curl

    tests.session -u test prepare

restore: |
    tests.session -u test restore

    if [ -f agent-was-enabled ]; then
        systemctl --user --global disable snapd.session-agent.socket
    fi

execute: |
    echo "Initially snap session-agent is not running"
    not tests.session -u test exec systemctl --user is-active snapd.session-agent.service

    echo "However its REST API socket exists"
    test -S /run/user/12345/snapd-session-agent.socket

    echo "We can issue queries to the socket as root"
    snap debug api --fail --session-agent-uid=12345 \
        /v1/session-info

    echo "Now snap session-agent is running"
    tests.session -u test exec systemctl --user is-active snapd.session-agent.service

    echo "If we stop session-agent, it can be restarted via socket activation"
    tests.session -u test exec systemctl --user stop snapd.session-agent.service
    not tests.session -u test exec systemctl --user is-active snapd.session-agent.service

    snap debug api --fail --session-agent-uid=12345 \
        /v1/session-info
    tests.session -u test exec systemctl --user is-active snapd.session-agent.service

    echo "The user running the session agent can also communicate with it"
    tests.session -u test exec test-snapd-curl.curl --unix-socket /run/user/12345/snapd-session-agent.socket \
        -D- http://localhost/v1/session-info | MATCH "HTTP/1.1 200 OK"