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 (81 lines) | stat: -rw-r--r-- 2,769 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
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
summary: Check that undo for snap refresh works

details: |
    Check that when a snap refresh fails, the refresh is undone.
    Verify the `snap tasks` command shows the proper information.

# ubuntu-14.04: systemd-run not supported
systems: [-ubuntu-core-*, -ubuntu-14.04*]

environment:
    BLOB_DIR: $(pwd)/fake-store-blobdir
    GOOD_SNAP: test-snapd-python-webserver
    BAD_SNAP: test-snapd-tools

prepare: |
    if [ "$TRUST_TEST_KEYS" = "false" ]; then
        echo "This test needs test keys to be trusted"
        exit
    fi

    echo "Given two snaps are installed"
    for snap in $GOOD_SNAP $BAD_SNAP; do
        snap install "$snap"
    done

    echo "And the daemon is configured to point to the fake store"
    "$TESTSTOOLS"/store-state setup-fake-store "$BLOB_DIR"

restore: |
    if [ "$TRUST_TEST_KEYS" = "false" ]; then
        echo "This test needs test keys to be trusted"
        exit
    fi

    "$TESTSTOOLS"/store-state teardown-fake-store "$BLOB_DIR"
    rm -rf "$BLOB_DIR"

execute: |
    if [ "$TRUST_TEST_KEYS" = "false" ]; then
        echo "This test needs test keys to be trusted"
        exit
    fi

    echo "Precondition check for the fake store"
    snap refresh 2>&1 | MATCH "All snaps up to date"

    echo "When the store is configured to make them refreshable"
    "$TESTSTOOLS"/store-state init-fake-refreshes "$BLOB_DIR" "$GOOD_SNAP"
    retry -n 4 --wait 0.5 test -e "$BLOB_DIR/${GOOD_SNAP}"*fake1*.snap
    "$TESTSTOOLS"/store-state init-fake-refreshes "$BLOB_DIR" "$BAD_SNAP"
    retry -n 4 --wait 0.5 test -e "$BLOB_DIR/${BAD_SNAP}"*fake1*.snap

    echo "When a snap is broken"
    echo "i-am-broken-now" >> "$BLOB_DIR/${BAD_SNAP}"*fake1*.snap

    echo "And a refresh is performed"
    if snap refresh ; then
        echo "snap refresh should fail but it did not, test is broken"
        exit 1
    fi

    echo "Then the new version of the good snap got installed"
    snap list | MATCH -E "${GOOD_SNAP}.*?fake1"

    echo "But the bad snap did not get updated"
    snap list | MATCH -E "${BAD_SNAP}"| NOMATCH "fake"

    #shellcheck source=tests/lib/changes.sh
    . "$TESTSLIB"/changes.sh
    chg_id=$(change_id "Refresh snap" Error)

    echo "Verify the snap change"
    snap change "$chg_id" | MATCH "Undone.*Download snap \"${BAD_SNAP}\""
    snap change "$chg_id" | MATCH "Done.*Download snap \"${GOOD_SNAP}\""
    snap change "$chg_id" | MATCH "ERROR cannot verify snap \"test-snapd-tools\", no matching signatures found"

    echo "Verify the 'snap tasks' is the same as 'snap change'"
    snap tasks "$chg_id" | MATCH "Undone.*Download snap \"${BAD_SNAP}\""

    echo "Verify the 'snap tasks --last' shows last refresh change"
    snap tasks --last=refresh | MATCH "Undone.*Download snap \"${BAD_SNAP}\""