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 (35 lines) | stat: -rw-r--r-- 1,793 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
summary: Check that unknown tasks are aborted

details: |
    Snapd can, in theory, freely move in "time" by refreshing itself and
    reverting to the earlier revision. It is possible to introduce an update
    that defines a change with a new task that old snapd did not know about. The
    test crafts a particular state file, which contains a task with an fake,
    unknown handler name in order to check that such tasks do not cause snapd to
    malfunction entirely, which would make rollback impossible.

execute: |
    echo "Stop snapd"
    systemctl stop snapd.{service,socket}

    LAST_LANE_ID=$(gojq ".[\"last-lane-id\"]" /var/lib/snapd/state.json)

    TASK_SNIPPET="{\"id\":\"90999\",\"kind\":\"alien-task\",\"summary\":\"alien task\",\"status\":0,\"data\":{},\"wait-tasks\":[],\"lanes\":[$LAST_LANE_ID],\"change\":\"80999\",\"spawn-time\":\"2010-11-09T22:04:10.320985653Z\"}"

    CHANGE_SNIPPET="{\"id\":\"80999\",\"kind\":\"some-change\",\"summary\":\"...\",\"status\":0,\"clean\":true,\"data\":{},\"task-ids\":[\"90999\"],\"spawn-time\":\"2010-11-09T22:04:10.320985653Z\"}"

    echo "Add unknown task to the state"
    gojq ".changes[\"80999\"]=$CHANGE_SNIPPET" /var/lib/snapd/state.json > /var/lib/snapd/state.json.new
    mv /var/lib/snapd/state.json.new /var/lib/snapd/state.json
    gojq ".tasks[\"90999\"]=$TASK_SNIPPET" /var/lib/snapd/state.json > /var/lib/snapd/state.json.new
    mv /var/lib/snapd/state.json.new /var/lib/snapd/state.json

    systemctl start snapd.{service,socket}

    echo "Ensure that unknown task was ignored"
    for _ in $(seq 10); do
        snap changes|MATCH ".*80999.*Done" && break
        sleep 1
    done 
    snap changes | MATCH ".*80999.*Done"
    snap change 80999 | MATCH ".*INFO no handler for task \"alien-task\", task ignored"