Correctly space expected_status
[integration/test.git] / csit / suites / openflowplugin / MD_SAL_NSF_OF13 / 020_restconf_topology.robot
1 *** Settings ***
2 Documentation       Test suite for RESTCONF Topology
3
4 Library             Collections
5 Library             RequestsLibrary
6 Library             ../../../libraries/Common.py
7 Variables           ../../../variables/Variables.py
8 Resource            ../../../variables/openflowplugin/Variables.robot
9 Resource            ../../../libraries/Utils.robot
10
11 Suite Setup         Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
12 Suite Teardown      Delete All Sessions
13
14
15 *** Variables ***
16 @{node_list}    openflow:1    openflow:2    openflow:3
17
18
19 *** Test Cases ***
20 Get RESTCONF Topology
21     [Documentation]    Get RESTCONF Topology and validate the result.
22     Wait Until Keyword Succeeds
23     ...    10s
24     ...    2s
25     ...    Check For Elements At URI
26     ...    ${RFC8040_OPERATIONAL_TOPO_API}
27     ...    ${node_list}
28     ${resp}    RequestsLibrary.Get Request    session    ${RFC8040_OPERATIONAL_TOPO_API}
29     Log    ${resp.text}
30
31 List all the links
32     [Documentation]    List all the links in the topology.
33     ${body1}    Create Dictionary    dest-node=openflow:1    dest-tp=openflow:1:2
34     ${body2}    Create Dictionary    source-node=openflow:3    source-tp=openflow:3:3
35     ${link2}    Create Dictionary    link-id=openflow:3:3    destination=${body1}    source=${body2}
36     Set Suite Variable    ${link2}
37     ${body1}    Create Dictionary    dest-node=openflow:1    dest-tp=openflow:1:1
38     ${body2}    Create Dictionary    source-node=openflow:2    source-tp=openflow:2:3
39     ${link1}    Create Dictionary    link-id=openflow:2:3    destination=${body1}    source=${body2}
40     Set Suite Variable    ${link1}
41     ${body1}    Create Dictionary    dest-node=openflow:3    dest-tp=openflow:3:3
42     ${body2}    Create Dictionary    source-node=openflow:1    source-tp=openflow:1:2
43     ${link4}    Create Dictionary    link-id=openflow:1:2    destination=${body1}    source=${body2}
44     Set Suite Variable    ${link4}
45     ${body1}    Create Dictionary    dest-node=openflow:2    dest-tp=openflow:2:3
46     ${body2}    Create Dictionary    source-node=openflow:1    source-tp=openflow:1:1
47     ${link3}    Create Dictionary    link-id=openflow:1:1    destination=${body1}    source=${body2}
48     Set Suite Variable    ${link3}
49     ${links}    Create List    ${link1}    ${link2}    ${link3}    ${link4}
50     Wait Until Keyword Succeeds    10s    2s    Verify Links    ${links}
51
52 Link Down
53     [Documentation]    Take link s1-s2 down
54     Write    link s1 s2 down
55     Read Until    mininet>
56     ${links}    Create List    ${link2}    ${link4}
57     # increasing the WUKS timeout to 60s to see if the CI environment might just be taking
58     # longer for this test with the lithium redesign plugin
59     Wait Until Keyword Succeeds    60s    2s    Verify Links    ${links}
60     # shot in the dark.    maybe the "link s1 s2 down" really didn't take the link(s) down?
61     # hopefully this output below will show that.
62     Write    sh ovs-vsctl find Interface name="s1-eth1"
63     ${output}    Read Until    mininet>
64     Log    ${output}
65     Write    sh ovs-vsctl find Interface name="s1-eth2"
66     ${output}    Read Until    mininet>
67     Log    ${output}
68
69 Link Up
70     [Documentation]    Take link s1-s2 up
71     Write    link s1 s2 up
72     Read Until    mininet>
73     ${links}    Create List    ${link1}    ${link2}    ${link3}    ${link4}
74     Wait Until Keyword Succeeds    10s    2s    Verify Links    ${links}
75
76 Remove Port
77     [Documentation]    Remove port s2-eth2
78     [Tags]    exclude
79     Write    sh ovs-vsctl del-port s2 s2-eth2
80     Read Until    mininet>
81     @{list}    Create List    openflow%3A2%3A2
82     Wait Until Keyword Succeeds
83     ...    10s
84     ...    2s
85     ...    Check For Elements Not At URI
86     ...    ${RFC8040_OPERATIONAL_TOPO_API}
87     ...    ${list}
88
89 Add Port
90     [Documentation]    Add port s2-eth2, new id 5
91     [Tags]    exclude
92     Write    sh ovs-vsctl add-port s2 s2-eth2
93     Read Until    mininet>
94     @{list}    Create List    openflow%3A2%3A5
95     Wait Until Keyword Succeeds    10s    2s    Check For Elements At URI    ${RFC8040_OPERATIONAL_TOPO_API}    ${list}
96
97
98 *** Keywords ***
99 Verify Links
100     [Arguments]    ${expected_links}
101     ${resp}    RequestsLibrary.Get Request    session    ${RFC8040_OPERATIONAL_TOPO_FLOW1_API}
102     Log    ${resp.text}
103     Should Be Equal As Strings    ${resp.status_code}    200
104     ${result}    To JSON    ${resp.text}
105     Log    ${result}
106     ${content}    Get From Dictionary    ${result}    network-topology:topology
107     ${topology}    Get From List    ${content}    0
108     ${links}    Get From Dictionary    ${topology}    link
109     FOR    ${expected_link}    IN    @{expected_links}
110         Should Contain    ${links}    ${expected_link}
111     END