Migrate Get Requests invocations(libraries)
[integration/test.git] / csit / suites / openflowplugin / Flows_Stats_OF13 / 010__SM_add_upd_del_flows.robot
index 1303005a4e215354e89baaba9845b9f1d8810f9e..4430b615eb5a761e58aa1ba1ba3732be2ce1824c 100644 (file)
@@ -1,29 +1,35 @@
 *** Settings ***
-Documentation     Test suite for Stats Manager flows collection
-Suite Setup       Initialization Phase
-Suite Teardown    Teardown Phase
-Library           OperatingSystem
-Library           Collections
-Library           XML
-Library           ../../../libraries/XmlComparator.py
-Variables         ../../../variables/Variables.py
-Library           RequestsLibrary
-Library           ../../../libraries/Common.py
+Documentation       Test suite for Stats Manager flows collection
+
+Library             OperatingSystem
+Library             Collections
+Library             XML
+Library             ../../../libraries/XmlComparator.py
+Library             RequestsLibrary
+Library             ../../../libraries/Common.py
+Variables           ../../../variables/Variables.py
+Resource            ../../../variables/openflowplugin/Variables.robot
+
+Suite Setup         Initialization Phase
+Suite Teardown      Teardown Phase
+
 
 *** Variables ***
-${XmlsDir}        ${CURDIR}/../../../variables/xmls
-${switch_idx}     1
-${switch_name}    s${switch_idx}
-@{xml_files}      f1.xml    f2.xml    f3.xml    f5.xml    f7.xml    f8.xml    f9.xml
-...               f10.xml    f11.xml    f14.xml    f17.xml    f19.xml    f24.xml
+${XmlsDir}          ${CURDIR}/../../../variables/xmls
+${switch_idx}       1
+${switch_name}      s${switch_idx}
+@{xml_files}        f1.xml    f2.xml    f3.xml    f5.xml    f7.xml    f8.xml    f9.xml
+...                 f10.xml    f11.xml    f14.xml    f17.xml    f19.xml    f24.xml
+
 
 *** Test Cases ***
 Test Add Flows
     [Documentation]    Add all flows and waits for SM to collect data
-    : FOR    ${flowfile}    IN    @{xml_files}
-    \    Log    ${flowfile}
-    \    Init Flow Variables    ${flowfile}
-    \    Run Keyword And Continue On Failure    Add Flow
+    FOR    ${flowfile}    IN    @{xml_files}
+        Log    ${flowfile}
+        Init Flow Variables    ${flowfile}
+        Run Keyword And Continue On Failure    Add Flow
+    END
 
 Test Is Flow 1 Added
     [Documentation]    Checks if flow is configured and operational
@@ -105,10 +111,11 @@ Test Is Flow 24 Added
 
 Test Delete Flows
     [Documentation]    Delete all flows and waits for SM to collect data
-    : FOR    ${flowfile}    IN    @{xml_files}
-    \    Log    ${flowfile}
-    \    Init Flow Variables    ${flowfile}
-    \    Run Keyword And Continue On Failure    Delete Flow
+    FOR    ${flowfile}    IN    @{xml_files}
+        Log    ${flowfile}
+        Init Flow Variables    ${flowfile}
+        Run Keyword And Continue On Failure    Delete Flow
+    END
 
 Test Is Flow 1 Deleted
     [Documentation]    Checks if flow is not configured and operational
@@ -188,6 +195,7 @@ Test Is Flow 24 Deleted
     Check Config Flow    ${False}
     Check Operational Table    ${False}
 
+
 *** Keywords ***
 Init Flow Variables
     [Arguments]    ${file}
@@ -214,13 +222,17 @@ Check Config Flow Presence
 
 Flow Presence Config Flow
     ${headers}=    Create Dictionary    Accept=application/xml
-    ${resp}=    RequestsLibrary.Get Request    session    /restconf/config/opendaylight-inventory:nodes/node/openflow:${switch_idx}/table/${table_id}/flow/${flow_id}    headers=${headers}
+    ${resp}=    RequestsLibrary.GET On Session
+    ...    session
+    ...    url=${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}/flow=${flow_id}
+    ...    headers=${headers}
+    ...    expected_status=anything
     Log    ${resp}
     Log    ${resp.content}
-    Return From Keyword If    ${resp.status_code}!=200    ${False}    ${EMPTY}
+    IF    ${resp.status_code}!=200    RETURN    ${False}    ${EMPTY}
     ${pres}    ${msg}=    Is Flow Configured    ${data}    ${resp.content}
-    Run Keyword If    '''${msg}'''!='${EMPTY}'    Log    ${msg}
-    Return From Keyword    ${pres}    ${msg}
+    IF    '''${msg}'''!='${EMPTY}'    Log    ${msg}
+    RETURN    ${pres}    ${msg}
 
 Check Operational Table
     [Arguments]    ${expected}
@@ -234,31 +246,40 @@ Check Operational Table Presence
 
 Flow Presence Operational Table
     ${headers}=    Create Dictionary    Accept=application/xml
-    ${resp}=    RequestsLibrary.Get Request    session    /restconf/operational/opendaylight-inventory:nodes/node/openflow:${switch_idx}/table/${table_id}    headers=${headers}
+    ${resp}=    RequestsLibrary.GET On Session
+    ...    session
+    ...    url=${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}?${RFC8040_OPERATIONAL_CONTENT}
+    ...    headers=${headers}
+    ...    expected_status=anything
     Log    ${resp}
     Log    ${resp.content}
-    Return From Keyword If    ${resp.status_code}!=200    ${False}    ${EMPTY}
+    IF    ${resp.status_code}!=200    RETURN    ${False}    ${EMPTY}
     ${pres}    ${msg}=    Is Flow Operational2    ${data}    ${resp.content}
-    Run Keyword If    '''${msg}'''!='${EMPTY}'    Log    ${msg}
-    Return From Keyword    ${pres}    ${msg}
+    IF    '''${msg}'''!='${EMPTY}'    Log    ${msg}
+    RETURN    ${pres}    ${msg}
 
 Add Flow
     Log    ${data}
-    ${resp}=    RequestsLibrary.Put Request    session    /restconf/config/opendaylight-inventory:nodes/node/openflow:${switch_idx}/table/${table_id}/flow/${flow_id}    headers=${HEADERS_XML}    data=${data}
-    ${msg}=    Set Variable    Adding flow for /restconf/config/opendaylight-inventory:nodes/node/openflow:${switch_idx}/table/${table_id}/flow/${flow_id} failed, http response ${resp.status_code} received.
-    Should Be Equal As Strings    ${resp.status_code}    200    msg=${msg}
+    ${resp}=    RequestsLibrary.PUT On Session
+    ...    session
+    ...    url=${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}/flow=${flow_id}
+    ...    headers=${HEADERS_XML}
+    ...    data=${data}
+    ...    expected_status=200
 
 Delete Flow
-    ${resp}=    RequestsLibrary.Delete Request    session    /restconf/config/opendaylight-inventory:nodes/node/openflow:${switch_idx}/table/${table_id}/flow/${flow_id}
-    ${msg}=    Set Variable    Delete flow for /restconf/config/opendaylight-inventory:nodes/node/openflow:${switch_idx}/table/${table_id}/flow/${flow_id} failed, http response ${resp.status_code} received.
-    Should Be Equal As Strings    ${resp.status_code}    200    msg=${msg}
+    ${resp}=    RequestsLibrary.DELETE On Session
+    ...    session
+    ...    url=${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}/flow=${flow_id}
+    ...    expected_status=200
 
 Delete All Flows
     [Documentation]    Deletes all flows
-    : FOR    ${flowfile}    IN    @{xml_files}
-    \    Log    ${flowfile}
-    \    Init Flow Variables    ${flowfile}
-    \    Delete Flow
+    FOR    ${flowfile}    IN    @{xml_files}
+        Log    ${flowfile}
+        Init Flow Variables    ${flowfile}
+        Delete Flow
+    END
 
 Initialization Phase
     [Documentation]    Initiate tcp connection with controller
@@ -270,7 +291,12 @@ Teardown Phase
 
 Get Presence Failure Message
     [Arguments]    ${ds}    ${expected}    ${presence}    ${diffmsg}
-    Return From Keyword If    '''${diffmsg}'''!='${EMPTY}'    Flow found in ${ds} data store but: ${diffmsg}
-    ${msgf}=    Set Variable If    ${expected}==${True}    The flow is expected in operational data store, but    The flow is not expected in operational data store, but
+    IF    '''${diffmsg}'''!='${EMPTY}'
+        RETURN    Flow found in ${ds} data store but: ${diffmsg}
+    END
+    ${msgf}=    Set Variable If
+    ...    ${expected}==${True}
+    ...    The flow is expected in operational data store, but
+    ...    The flow is not expected in operational data store, but
     ${msgp}=    Set Variable If    ${presence}==${True}    it is present.    it is not present.
-    Return From Keyword    ${msgf} ${msgp}
+    RETURN    ${msgf} ${msgp}