Adding link/port bounce test to basic openflow suite
[integration/test.git] / test / csit / suites / openflowplugin / MD_SAL_NSF_OF13 / 020__restconf_topology.robot
index f6d3f60a83c085516dad5f55fb1436c53f9c15a1..13a214eeaff4968dfd4bf2c5102d2d559bc445e0 100644 (file)
@@ -1,5 +1,5 @@
 *** Settings ***
-Documentation     Test suite RESTCONF Topology
+Documentation     Test suite for RESTCONF Topology
 Suite Setup       Create Session    session    http://${CONTROLLER}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS}
 Suite Teardown    Delete All Sessions
 Library           Collections
@@ -9,68 +9,69 @@ Variables         ../../../variables/Variables.py
 Resource          ../../../libraries/Utils.txt
 
 *** Variables ***
-${topology1}      "flow:1"
-${node1}          "openflow:1"
-${node2}          "openflow:2"
-${node3}          "openflow:3"
 @{node_list}      openflow:1    openflow:2    openflow:3
-${key}            link
-${REST_CONTEXT_1}    /restconf/operational/network-topology:network-topology
-${REST_CONTEXT_2}    /restconf/operational/network-topology:network-topology/topology/flow:1
-${REST_CONTEXT_3}    /restconf/config/network-topology:network-topology/topology/flow:1/link/userlink
+${REST_CONTEXT}    /restconf/operational/network-topology:network-topology
 
 *** Test Cases ***
 Get RESTCONF Topology
     [Documentation]    Get RESTCONF Topology and validate the result.
-    Wait Until Keyword Succeeds    30s    2s    Ensure All Nodes Are In Response    ${REST_CONTEXT_1}    ${node_list}
-    ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT_1}
+    Wait Until Keyword Succeeds    30s    2s    Ensure All Nodes Are In Response    ${REST_CONTEXT}    ${node_list}
+    ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT}
     Log    ${resp.content}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    Should Contain    ${resp.content}    ${topology1}
 
 List all the links
     [Documentation]    List all the links in the topology.
     ${body1}    Create Dictionary    dest-node=openflow:1    dest-tp=openflow:1:2
     ${body2}    Create Dictionary    source-node=openflow:3    source-tp=openflow:3:3
     ${link2}    Create Dictionary    link-id=openflow:3:3    destination=${body1}    source=${body2}
+    Set Suite Variable    ${link2}
     ${body1}    Create Dictionary    dest-node=openflow:1    dest-tp=openflow:1:1
     ${body2}    Create Dictionary    source-node=openflow:2    source-tp=openflow:2:3
     ${link1}    Create Dictionary    link-id=openflow:2:3    destination=${body1}    source=${body2}
+    Set Suite Variable    ${link1}
     ${body1}    Create Dictionary    dest-node=openflow:3    dest-tp=openflow:3:3
     ${body2}    Create Dictionary    source-node=openflow:1    source-tp=openflow:1:2
     ${link4}    Create Dictionary    link-id=openflow:1:2    destination=${body1}    source=${body2}
+    Set Suite Variable    ${link4}
     ${body1}    Create Dictionary    dest-node=openflow:2    dest-tp=openflow:2:3
     ${body2}    Create Dictionary    source-node=openflow:1    source-tp=openflow:1:1
     ${link3}    Create Dictionary    link-id=openflow:1:1    destination=${body1}    source=${body2}
+    Set Suite Variable    ${link3}
     ${links}    Create List    ${link1}    ${link2}    ${link3}    ${link4}
     Wait Until Keyword Succeeds    30s    2s    Verify Links    ${links}
 
-Add a link
-    [Documentation]    Add a link, list to validate the result.
-    ${body1}    Create Dictionary    dest-node=openflow:3    dest-tp=openflow:3:1
-    ${body2}    Create Dictionary    source-node=openflow:2    source-tp=openflow:2:1
-    ${body3}    Create Dictionary    link-id=userlink    destination=${body1}    source=${body2}
-    ${links}    Create List    ${body3}
-    ${body}    Create Dictionary    link=${links}
-    ${resp}    RequestsLibrary.Put    session    ${REST_CONTEXT_3}    data=${body}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT_3}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    ${result}    To JSON    ${resp.content}
-    ${link}    Get From Dictionary    ${result}    link
-    Lists Should be Equal    ${link}    ${links}
+Link Down
+    [Documentation]    Take link s1-s2 down
+    Write    link s1 s2 down
+    Read Until    mininet>
+    ${links}    Create List    ${link2}    ${link4}
+    Wait Until Keyword Succeeds    30s    2s    Verify Links    ${links}
 
-Remove a link
-    [Documentation]    Remove a link, list to validate the result.
-    ${resp}    RequestsLibrary.Delete    session    ${REST_CONTEXT_3}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT_3}
-    Should Be Equal As Strings    ${resp.status_code}    404
+Link Up
+    [Documentation]    Take link s1-s2 up
+    Write    link s1 s2 up
+    Read Until    mininet>
+    ${links}    Create List    ${link1}    ${link2}    ${link3}    ${link4}
+    Wait Until Keyword Succeeds    30s    2s    Verify Links    ${links}
+
+Remove Port
+    [Documentation]    Remove port s2-eth2
+    Write    sh ovs-vsctl del-port s2 s2-eth2
+    Read Until    mininet>
+    @{list}    Create List    openflow:2:2
+    Wait Until Keyword Succeeds    30s    2s    Check For Elements Not At URI    ${REST_CONTEXT}    ${list}
+
+Add Port
+    [Documentation]    Add port s2-eth2, new id 5
+    Write    sh ovs-vsctl add-port s2 s2-eth2
+    Read Until    mininet>
+    @{list}    Create List    openflow:2:5
+    Wait Until Keyword Succeeds    30s    2s    Check For Elements At URI    ${REST_CONTEXT}    ${list}
 
 *** Keywords ***
 Verify Links
     [Arguments]    ${expected_links}
-    ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT_2}
+    ${resp}    RequestsLibrary.Get    session    ${REST_CONTEXT}/topology/flow:1
     Log    ${resp.content}
     Should Be Equal As Strings    ${resp.status_code}    200
     ${result}    To JSON    ${resp.content}