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 (103 lines) | stat: -rw-r--r-- 4,136 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
summary: Ensure that the openvswitch interface works.

details: |
    The openvswitch interface allows to task to the openvswitch socket (rw mode).

    A snap which defines a openvswitch plug must be shown in the interfaces list.
    The plug must not be autoconnected on install and, as usual, must be able to be
    reconnected.

    A snap declaring a plug on this interface must be able to do all the operations that
    are carried through the socket, in this test we exercise bridge and port creation,
    list and deletion.

# Openvswitch getting stuck during installation sporadically on ubuntu-14.04-64
# Openvswitch service fails to start on debian-sid
# Openvswitch service not available on the following systems
systems: [-ubuntu-core-*, -opensuse-*, -amazon-*, -arch-linux-*, -centos-*, -debian-sid-*, -ubuntu-14.04-64]

prepare: |
    echo "Given openvswitch is installed"
    tests.pkgs install openvswitch-switch

    # Ensure the openvswitch service is started which isn't the case by
    # default on all distributions
    if systemctl status openvswitch-switch.service | MATCH "Loaded:.*loaded"; then
        systemctl enable --now openvswitch-switch.service
    elif systemctl status openvswitch.service | MATCH "Loaded:.*loaded"; then
        systemctl enable --now openvswitch.service
    fi

    echo "And a snap declaring a plug on the openvswitch interface is installed"
    snap install --edge test-snapd-openvswitch-consumer

    echo "And a tap interface is defined"
    ip tuntap add tap1 mode tap

restore: |
    ovs-vsctl del-port br0 tap1 || true
    ovs-vsctl del-br br0 || true

    ip link delete tap1 || true

execute: |
    echo "The interface is disconnected by default"
    snap interfaces -i openvswitch | MATCH -- '^- +test-snapd-openvswitch-consumer:openvswitch'

    echo "When the plug is connected"
    snap connect test-snapd-openvswitch-consumer:openvswitch

    echo "Then the snap is able to create a bridge"
    test-snapd-openvswitch-consumer.ovs-vsctl add-br br0
    ovs-vsctl list-br | MATCH br0

    echo "And the snap is able to create a port"
    test-snapd-openvswitch-consumer.ovs-vsctl add-port br0 tap1
    ovs-vsctl list-ports br0 | MATCH tap1

    echo "And the snap is able to delete a port"
    test-snapd-openvswitch-consumer.ovs-vsctl del-port br0 tap1
    ovs-vsctl list-ports br0 | NOMATCH tap1

    echo "And the snap is able to delete a bridge"
    test-snapd-openvswitch-consumer.ovs-vsctl del-br br0
    ovs-vsctl list-br | NOMATCH br0

    if [ "$(snap debug confinement)" = partial ] ; then
        exit 0
    fi

    echo "When the plug is disconnected"
    snap disconnect test-snapd-openvswitch-consumer:openvswitch

    echo "Then the snap is not able to create a bridge"
    if test-snapd-openvswitch-consumer.ovs-vsctl add-br br0 2> bridge-creation.error; then
        echo "Expected permission error accessing openvswitch socket with disconnected plug"
        exit 1
    fi
    MATCH 'database connection failed \(Permission denied\)' < bridge-creation.error

    ovs-vsctl add-br br0

    echo "And the snap is not able to create a port"
    if test-snapd-openvswitch-consumer.ovs-vsctl add-port br0 tap1 2> port-creation.error; then
        echo "Expected permission error accessing openvswitch socket with disconnected plug"
        exit 1
    fi
    MATCH 'database connection failed \(Permission denied\)' < port-creation.error

    ovs-vsctl add-port br0 tap1

    echo "And the snap is not able to delete a port"
    if test-snapd-openvswitch-consumer.ovs-vsctl del-port br0 tap1 2> port-deletion.error; then
        echo "Expected permission error accessing openvswitch socket with disconnected plug"
        exit 1
    fi
    MATCH 'database connection failed \(Permission denied\)' < port-deletion.error

    echo "And the snap is not able to delete a bridge"
    if test-snapd-openvswitch-consumer.ovs-vsctl del-br br0 2> br-creation.error; then
        echo "Expected permission error accessing openvswitch socket with disconnected plug"
        exit 1
    fi
    MATCH 'database connection failed \(Permission denied\)' < br-creation.error