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