File: task.yaml

package info (click to toggle)
snapd 2.71-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 79,536 kB
  • sloc: ansic: 16,114; sh: 16,105; python: 9,941; makefile: 1,890; exp: 190; awk: 40; xml: 22
file content (76 lines) | stat: -rw-r--r-- 3,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
summary: Check that the ubuntu-core system is rebooted after the core snap is refreshed

details: |
    This test checks that when invoking a manual refresh/revert for core or core18 snaps,
    a reboot is triggered and the command would exit after the first phase of the installation
    reporting "snapd is about to reboot the system" or "Change X waiting on external action to be completed"

systems: [ubuntu-core-*]

environment:
    # uploading the core or otherwise large snap triggers OOM
    SNAPD_NO_MEMORY_LIMIT: 1

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

    TARGET_SNAP_NAME="$(snaps.name core)"
    # Save initial revision
    "$TESTSTOOLS"/snaps-state show-revision "$TARGET_SNAP_NAME" > initi_rev.log

restore: |
    TARGET_SNAP_NAME="$(snaps.name core)"
    # We need to make sure the base snap has the initial rev
    test "$("$TESTSTOOLS"/snaps-state show-revision "$TARGET_SNAP_NAME")" == "$(cat initi_rev.log)"
    
    # 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: |
    TARGET_SNAP_NAME="$(snaps.name core)"

    # After installing a new version of the core/core18 snap the system is rebooted
    if [ "$SPREAD_REBOOT" = 0 ]; then
        currRev="$(readlink /snap/"${TARGET_SNAP_NAME}"/current)"
        echo "$currRev" > initialRev

        # use journalctl wrapper to grep only the logs collected while the test is running
        if "$TESTSTOOLS"/journal-state get-log | MATCH "Waiting for system reboot"; then
            echo "Already waiting for system reboot, exiting..."
            exit 1
        fi

        # install new target snap
        snap install --dangerous --no-wait /var/lib/snapd/snaps/"${TARGET_SNAP_NAME}"_"${currRev}".snap

        # Detect in the logs when the reboot can been triggered
        "$TESTSTOOLS"/journal-state match-log -n 50 --wait 2 "Waiting for system reboot"

        REBOOT
    elif [ "$SPREAD_REBOOT" = 1 ]; then
        # Wait for the install to complete.
        snap watch --last=install

        # Check the current revision has changed
        currRev="$(readlink /snap/"${TARGET_SNAP_NAME}"/current)"
        [ "$(cat initialRev)" !=  "$currRev" ]

        # revert the target snap
        snap revert "$TARGET_SNAP_NAME" 2>&1 | MATCH "snapd is about to reboot the system|waiting on external action to be completed"

        # Detect in the logs when the reboot can been triggered
        "$TESTSTOOLS"/journal-state match-log -n 50 --wait 2 "Waiting for system reboot"

        REBOOT
    elif [  "$SPREAD_REBOOT" = 2 ]; then
        # Wait for the revert to complete.
        snap watch --last=revert-snap
        # Check the current revision is the same than the original
        currRev="$(readlink /snap/"${TARGET_SNAP_NAME}"/current)"
        [ "$(cat initialRev)" ==  "$currRev" ]
    fi