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