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 (56 lines) | stat: -rw-r--r-- 2,053 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
summary: Verify that the maintenance message is included in the daemon API responses when available

details: |
  Verify present of the maintenance message in the local API.

# kinda slow test, probably enough to keep on one system
systems: [ubuntu-core-20-64]

prepare: |
    # make sure that the snapd daemon gives us time for comms before
    # closing the socket
    echo "SNAPD_SHUTDOWN_DELAY=1" >> /etc/environment
    systemctl restart snapd

restore: |
    # remove SNAPD_SHUTDOWN_DELAY from /etc/environment again
    #shellcheck disable=SC2005
    echo "$(grep -v 'SNAPD_SHUTDOWN_DELAY=1' /etc/environment)" > /etc/environment
    systemctl restart snapd

execute: |
    if [ "$SPREAD_REBOOT" = 0 ]; then
        current=$(readlink /snap/snapd/current)
        SNAPD_SNAP=$(ls /var/lib/snapd/snaps/snapd_"$current".snap)
        
        # we have three seconds between the maintenance json being written and the snapd listener being
        # closed so we need to catch it in that timeframe.
        echo "Testing maintenance message for daemon restarts"
        snap install --dangerous "$SNAPD_SNAP" &
        retry -n 20 --wait 0.5 sh -c 'snap debug api '/v2/changes?select=all' | gojq ".maintenance" | MATCH "daemon is restarting"'
        wait

        echo "Restoring the snapd snap"
        snap revert snapd

        echo "Testing maintenance message for system reboots"
        snap refresh core20 --channel=stable --amend &
        retry -n 20 --wait 0.5 sh -c 'snap debug api '/v2/changes?select=all' | gojq ".maintenance" | MATCH "system is restarting"'
        wait

        REBOOT
    fi

    if [ "$SPREAD_REBOOT" = 1 ]; then
        echo "Waiting for the core20 to finish refresh"
        CHANGE_ID=$(snap changes | tr -s '\n' | awk 'END{ print $1 }')
        snap watch "$CHANGE_ID"

        echo "Restoring the core20 snap"
        snap revert core20
        REBOOT
    fi
    
    echo "Waiting for the core20 to finish revert"
    CHANGE_ID=$(snap changes | tr -s '\n' | awk 'END{ print $1 }')
    snap watch "$CHANGE_ID"