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 (96 lines) | stat: -rw-r--r-- 3,980 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
summary: smoke test for the store-state tool

details: |
    Verify the functionality of the store-state tool. The tool is used to setup
    and teardown a fake store, setup and teardown a staging store, to make snaps
    installable in the fake store, and to initialize fake refreshes.

# cannot work with the staging store without a testing build with compiled-in staging keys
backends: [-external]

# ubuntu-14.04: systemd-run not supported
systems: [-ubuntu-14.04-64]

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

    # acquire session macaroon
    snap find core

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

    # Check help
    "$TESTSTOOLS"/store-state | MATCH "usage: store-state setup-fake-store <DIR>"
    "$TESTSTOOLS"/store-state -h | MATCH "usage: store-state setup-fake-store <DIR>"
    "$TESTSTOOLS"/store-state --help | MATCH "usage: store-state setup-fake-store <DIR>"

    # Staging store cannot be used with snapd deb from the repository
    # The staging keys are being checked before snapd re-exec into snapd snap
    if not tests.info is-snapd-from-archive; then
        # Setup staging store
        "$TESTSTOOLS"/store-state setup-staging-store
        snap info core | MATCH "store-url:.*https://staging-api.snapcraft.io"

        # Teardown staging store
        "$TESTSTOOLS"/store-state teardown-staging-store
        snap info core | MATCH "store-url:.*https://snapcraft.io"
    fi

    # install test snap dependency before switching to fake store
    base_dep="$(gojq -r --yaml-input '.base' < snap/meta/snap.yaml.in)"
    snap install "$base_dep"

    # Setup fakestore
    STORE_DIR="$(pwd)/fake-store-blobdir"
    snap ack "$TESTSLIB/assertions/testrootorg-store.account-key"
    "$TESTSTOOLS"/store-state setup-fake-store "$STORE_DIR"
    systemctl is-active fakestore
    ss -ntlp | MATCH "127.0.0.1:11028"
    snap info core | NOMATCH "store-url:.*https://snapcraft.io"

    # Check make-snap-installable command with snap-id
    create_snap() {
        gojq --yaml-input --yaml-output \
            ".name = \"$1\"" snap/meta/snap.yaml.in > snap/meta/snap.yaml
        "$TESTSTOOLS"/snaps-state pack-local snap
    }

    cp "$TESTSLIB"/assertions/developer1.account "$STORE_DIR/asserts"
    cp "$TESTSLIB"/assertions/developer1.account-key "$STORE_DIR/asserts"
    snap ack "$TESTSLIB/assertions/developer1.account"
    snap ack "$TESTSLIB/assertions/developer1.account-key"
    snap_path=$(create_snap my-test-snap)
    "$TESTSTOOLS"/store-state make-snap-installable "$STORE_DIR" "${snap_path}" "EaXqgt1lyCaxKaQCU349mlodBkDCXRcg"
    snap install my-test-snap 2>&1 | MATCH "my-test-snap 1.0.* installed"

    # Check make-snap-installable command without snap-id
    snap_path=$(create_snap my-test-snap-2)
    "$TESTSTOOLS"/store-state make-snap-installable "$STORE_DIR" "${snap_path}"
    snap install my-test-snap-2 2>&1 | MATCH "my-test-snap-2 1.0.* installed"

    # Check snaps can be removed
    snap remove my-test-snap
    snap remove my-test-snap-2

    # Check teardown fakestore
    "$TESTSTOOLS"/store-state teardown-fake-store "$STORE_DIR"
    not systemctl is-active fakestore
    ss -ntlp | NOMATCH "127.0.0.1:11028"

    # Check init-fake-refreshes command
    snap install test-snapd-tools
    "$TESTSTOOLS"/store-state setup-fake-store "$STORE_DIR"
    "$TESTSTOOLS"/store-state init-fake-refreshes "$STORE_DIR" "test-snapd-tools"
    snap refresh test-snapd-tools | MATCH "test-snapd-tools .* refreshed"
    "$TESTSTOOLS"/store-state teardown-fake-store "$STORE_DIR"

    # Test setup and teardown errors
    "$TESTSTOOLS"/store-state setup-fake-store 2>&1 | MATCH "store-state: the provided dir cannot be empty"
    "$TESTSTOOLS"/store-state teardown-fake-store "noexist" | MATCH 'store-state: the provided top dir does not exist "noexist"'