Adding link/port bounce test to basic openflow suite
[integration/test.git] / test / 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://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
4 Suite Teardown    Delete All Sessions
5 Library           Collections
6 Library           ../../../libraries/RequestsLibrary.py
7 Library           ../../../libraries/Common.py
8 Variables         ../../../variables/Variables.py
9 Resource          ../../../libraries/Utils.txt
10
11 *** Variables ***
12 @{node_list}      openflow:1    openflow:2    openflow:3
13 ${REST_CONTEXT}    /restconf/operational/network-topology:network-topology
14
15 *** Test Cases ***
16 Get RESTCONF Topology
17     [Documentation]    Get RESTCONF Topology and validate the result.
18     Wait Until Keyword Succeeds    30s    2s    Ensure All Nodes Are In Response    ${REST_CONTEXT}    ${node_list}
19     ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT}
20     Log    ${resp.content}
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    30s    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     Wait Until Keyword Succeeds    30s    2s    Verify Links    ${links}
49
50 Link Up
51     [Documentation]    Take link s1-s2 up
52     Write    link s1 s2 up
53     Read Until    mininet>
54     ${links}    Create List    ${link1}    ${link2}    ${link3}    ${link4}
55     Wait Until Keyword Succeeds    30s    2s    Verify Links    ${links}
56
57 Remove Port
58     [Documentation]    Remove port s2-eth2
59     Write    sh ovs-vsctl del-port s2 s2-eth2
60     Read Until    mininet>
61     @{list}    Create List    openflow:2:2
62     Wait Until Keyword Succeeds    30s    2s    Check For Elements Not At URI    ${REST_CONTEXT}    ${list}
63
64 Add Port
65     [Documentation]    Add port s2-eth2, new id 5
66     Write    sh ovs-vsctl add-port s2 s2-eth2
67     Read Until    mininet>
68     @{list}    Create List    openflow:2:5
69     Wait Until Keyword Succeeds    30s    2s    Check For Elements At URI    ${REST_CONTEXT}    ${list}
70
71 *** Keywords ***
72 Verify Links
73     [Arguments]    ${expected_links}
74     ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT}/topology/flow:1
75     Log    ${resp.content}
76     Should Be Equal As Strings    ${resp.status_code}    200
77     ${result}    To JSON    ${resp.content}
78     Log    ${result}
79     ${content}    Get From Dictionary    ${result}    topology
80     ${topology}    Get From List    ${content}    0
81     ${link}    Get From Dictionary    ${topology}    link
82     Sort List    ${link}
83     Lists Should be Equal    ${link}    ${expected_links}