Use RFC8040 URL for DAEXIM tests
[integration/test.git] / csit / libraries / FlowLib.robot
index 819f99db6f477b826f55e1bcec9da04ecf0489a2..70b6e0270123cdfd9b7c5fc793892d50791b0775 100644 (file)
@@ -10,8 +10,9 @@ Library           ScaleClient.py
 Library           FlowLib.py
 Library           XmlComparator.py
 Library           Common.py
-Variables         ../variables/Variables.py
+Resource          CompareStream.robot
 Resource          ../variables/openflowplugin/Variables.robot
+Variables         ../variables/Variables.py
 
 *** Keywords ***
 Check No Switches In Inventory
@@ -75,9 +76,9 @@ Check Linear Topology
         Should Contain    ${resp.text}    "source-tp":"openflow:${switch}:2"
         Should Contain    ${resp.text}    "dest-tp":"openflow:${switch}:2"
         ${edge}    Evaluate    ${switch}==1 or ${switch}==${switches}
-        Run Keyword Unless    ${edge}    Should Contain    ${resp.text}    "tp-id":"openflow:${switch}:3"
-        Run Keyword Unless    ${edge}    Should Contain    ${resp.text}    "source-tp":"openflow:${switch}:3"
-        Run Keyword Unless    ${edge}    Should Contain    ${resp.text}    "dest-tp":"openflow:${switch}:3"
+        Run Keyword If    not ${edge}    Should Contain    ${resp.text}    "tp-id":"openflow:${switch}:3"
+        Run Keyword If    not ${edge}    Should Contain    ${resp.text}    "source-tp":"openflow:${switch}:3"
+        Run Keyword If    not ${edge}    Should Contain    ${resp.text}    "dest-tp":"openflow:${switch}:3"
     END
 
 Check Flows Operational Datastore
@@ -107,7 +108,7 @@ Check Number Of Groups
 Check Flow Stats Are Available
     [Arguments]    ${node_id}    ${flows}
     [Documentation]    A GET on the /node=${node_id} inventory API is made and flow stats string is checked for existence.
-    ${resp}    RequestsLibrary.Get Request    session    ${RFC8040_NODES_API}/node=${node_id}/table=2
+    ${resp}    RequestsLibrary.Get Request    session    ${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:table=2
     Log    ${resp.text}
     Should Be Equal As Strings    ${resp.status_code}    200
     Should Contain X Times    ${resp.text}    priority    ${flows}
@@ -133,7 +134,7 @@ Add Table Miss Flows
     ${switches}=    Convert To Integer    ${switches}
     ${data}=    OperatingSystem.Get File    ${CURDIR}/../variables/openflowplugin/table_miss_flow.json
     FOR    ${switch}    IN RANGE    1    ${switches+1}
-        TemplatedRequests.Put As Json To Uri    ${RFC8040_NODES_API}/node=openflow%3A${switch}/table=0/flow=default    ${data}    session
+        TemplatedRequests.Put As Json To Uri    ${RFC8040_NODES_API}/node=openflow%3A${switch}/flow-node-inventory:table=0/flow=default    ${data}    session
     END
 
 Check Table Miss Flows
@@ -141,7 +142,7 @@ Check Table Miss Flows
     [Documentation]    Check table miss flows in switches.
     ${switches}=    Convert To Integer    ${switches}
     FOR    ${switch}    IN RANGE    1    ${switches+1}
-        TemplatedRequests.Get As Json From Uri    ${RFC8040_NODES_API}/node=openflow%3A${switch}/table=0/flow=default    session
+        TemplatedRequests.Get As Json From Uri    ${RFC8040_NODES_API}/node=openflow%3A${switch}/flow-node-inventory:table=0/flow=default    session
     END
 
 Create Inventory Flow
@@ -275,10 +276,10 @@ Remove Flow XML Element
 Add Group To Controller And Verify
     [Arguments]    ${group_body}    ${node_id}    ${group_id}
     [Documentation]    Push group through REST-API and verify in data-store
-    ${resp}    RequestsLibrary.Put Request    session    ${RFC8040_NODES_API}/node=${node_id}/group=${group_id}    headers=${HEADERS_XML}    data=${group_body}
+    ${resp}    RequestsLibrary.Put Request    session    ${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:group=${group_id}    headers=${HEADERS_XML}    data=${group_body}
     Log    ${resp.text}
     BuiltIn.Should_Match    "${resp.status_code}"    "20?"
-    ${resp}    RequestsLibrary.Get Request    session    ${RFC8040_NODES_API}/node=${node_id}/group=${group_id}?content=config    headers=${ACCEPT_XML}
+    ${resp}    RequestsLibrary.Get Request    session    ${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:group=${group_id}?content=config    headers=${ACCEPT_XML}
     Log    ${resp.text}
     Should Be Equal As Strings    ${resp.status_code}    200
     Compare Xml    ${group_body}    ${resp.text}
@@ -286,10 +287,10 @@ Add Group To Controller And Verify
 Add Flow To Controller And Verify
     [Arguments]    ${flow_body}    ${node_id}    ${table_id}    ${flow_id}
     [Documentation]    Push flow through REST-API and verify in data-store
-    ${resp}    RequestsLibrary.Put Request    session    ${RFC8040_NODES_API}/node=${node_id}/table=${table_id}/flow=${flow_id}    headers=${HEADERS_XML}    data=${flow_body}
+    ${resp}    RequestsLibrary.Put Request    session    ${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id}    headers=${HEADERS_XML}    data=${flow_body}
     Log    ${resp.text}
     BuiltIn.Should_Match    "${resp.status_code}"    "20?"
-    ${resp}    RequestsLibrary.Get Request    session    ${RFC8040_NODES_API}/node=${node_id}/table=${table_id}/flow=${flow_id}?content=config    headers=${ACCEPT_XML}
+    ${resp}    RequestsLibrary.Get Request    session    ${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id}?content=config    headers=${ACCEPT_XML}
     Log    ${resp.text}
     Should Be Equal As Strings    ${resp.status_code}    200
     Compare Xml    ${flow_body}    ${resp.text}
@@ -307,10 +308,10 @@ Verify Flow On Mininet Switch
 Remove Group From Controller And Verify
     [Arguments]    ${node_id}    ${group_id}
     [Documentation]    Remove group and verify
-    ${resp}    RequestsLibrary.Delete Request    session    ${RFC8040_NODES_API}/node=${node_id}/group=${group_id}
+    ${resp}    RequestsLibrary.Delete Request    session    ${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:group=${group_id}
     Log    ${resp.text}
     Should Be Equal As Strings    ${resp.status_code}    204
-    ${resp}    RequestsLibrary.Get Request    session    ${RFC8040_NODES_API}/node=${node_id}/group=${group_id}?content=config
+    ${resp}    RequestsLibrary.Get Request    session    ${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:group=${group_id}?content=config
     Builtin.Return_From_Keyword_If    ${resp.status_code} == 404 or ${resp.status_code} == 409
     Builtin.Log    ${resp.text}
     Builtin.Fail    The request failed with code ${resp.status_code}
@@ -318,10 +319,10 @@ Remove Group From Controller And Verify
 Remove Flow From Controller And Verify
     [Arguments]    ${node_id}    ${table_id}    ${flow_id}
     [Documentation]    Remove flow and verify
-    ${resp}    RequestsLibrary.Delete Request    session    ${RFC8040_NODES_API}/node=${node_id}/table=${table_id}/flow=${flow_id}
+    ${resp}    RequestsLibrary.Delete Request    session    ${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id}
     Log    ${resp.text}
     Should Be Equal As Strings    ${resp.status_code}    204
-    ${resp}    RequestsLibrary.Get Request    session    ${RFC8040_NODES_API}/node=${node_id}/table=${table_id}/flow=${flow_id}?content=config
+    ${resp}    RequestsLibrary.Get Request    session    ${RFC8040_NODES_API}/node=${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id}?content=config
     Builtin.Return_From_Keyword_If    ${resp.status_code} == 404 or ${resp.status_code} == 409
     Builtin.Log    ${resp.text}
     Builtin.Fail    The request failed with code ${resp.status_code}
@@ -391,7 +392,7 @@ Flow Presence In Config Store
     [Documentation]    Checks the config store for given flow. Returns True if present, otherwise returns False
     ...    This keyword assumes that the global/suite variables are available (${table_id}, ${flow_id} and ${switch_idx}
     ${headers}=    Create Dictionary    Accept=application/xml
-    ${resp}=    RequestsLibrary.Get Request    session    ${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/table=${table_id}/flow=${flow_id}?content=config    headers=${headers}
+    ${resp}=    RequestsLibrary.Get Request    session    ${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}/flow=${flow_id}?content=config    headers=${headers}
     Log    ${resp}
     Log    ${resp.text}
     Return From Keyword If    ${resp.status_code}!=200    ${False}    ${EMPTY}
@@ -404,7 +405,7 @@ Flow Presence In Operational Store
     [Documentation]    Checks the operational store for given flow. Returns True if present, otherwise returns False
     ...    This keyword assumes that the global/suite variables are available (${table_id}, ${flow_id} and ${switch_idx}
     ${headers}=    Create Dictionary    Accept=application/xml
-    ${resp}=    RequestsLibrary.Get Request    session    ${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/table=${table_id}    headers=${headers}
+    ${resp}=    RequestsLibrary.Get Request    session    ${RFC8040_NODES_API}/node=openflow%3A${switch_idx}/flow-node-inventory:table=${table_id}    headers=${headers}
     Log    ${resp}
     Log    ${resp.text}
     Return From Keyword If    ${resp.status_code}!=200    ${False}    ${EMPTY}
@@ -452,15 +453,17 @@ Add Flow Via RPC
     ${strxml}=    Element To String    ${req}
     ${resp}=    RequestsLibrary.Post Request    session    /rests/operations/sal-flow:add-flow    data=${strxml}
     Log    ${resp.text}
-    Should Be Equal As Strings    ${resp.status_code}    200
+    ${expected_status_code}=    CompareStream.Set_Variable_If_At_Least_Phosphorus    204    200
+    Log    ${expected_status_code}
+    Should Be Equal As Strings    ${resp.status_code}    ${expected_status_code}
 
 Add Flow Via Restconf
     [Arguments]    ${node_id}    ${table_id}    ${flow_body}
     [Documentation]    Configures a flow specified by given flow details (${node_id}, ${table_id}, ${flow_body}) using POST method
     Log    ${flow_body}
-    ${resp}=    RequestsLibrary.Post Request    session    ${RFC8040_NODES_API}/node=openflow%3A${node_id}/table=${table_id}    data=${flow_body}
+    ${resp}=    RequestsLibrary.Post Request    session    ${RFC8040_NODES_API}/node=openflow%3A${node_id}/flow-node-inventory:table=${table_id}    data=${flow_body}
     Log    ${resp.text}
-    ${msg}=    Set Variable    Adding flow for ${RFC8040_NODES_API}/node=openflow%3A${node_id}/table=${table_id} failed, http response ${resp.status_code} received.
+    ${msg}=    Set Variable    Adding flow for ${RFC8040_NODES_API}/node=openflow%3A${node_id}/flow-node-inventory:table=${table_id} failed, http response ${resp.status_code} received.
     Should Be Equal As Strings    ${resp.status_code}    201    msg=${msg}
 
 Update Flow Via RPC
@@ -488,15 +491,17 @@ Update Flow Via RPC
     ${strxml}=    Element To String    ${xml}
     ${resp}=    RequestsLibrary.Post Request    session    /rests/operations/sal-flow:update-flow    data=${strxml}
     Log    ${resp.text}
-    Should Be Equal As Strings    ${resp.status_code}    200
+    ${expected_status_code}=    CompareStream.Set_Variable_If_At_Least_Phosphorus    204    200
+    Log    ${expected_status_code}
+    Should Be Equal As Strings    ${resp.status_code}    ${expected_status_code}
 
 Update Flow Via Restconf
     [Arguments]    ${node_id}    ${table_id}    ${flow_id}    ${flow_body}
     [Documentation]    Updates a flow configuration by given flow details (${node_id}, ${table_id}, ${flow_body}) using PUT method
     Log    ${flow_body}
-    ${resp}=    RequestsLibrary.Put Request    session    ${RFC8040_NODES_API}/node=openflow%3A${node_id}/table=${table_id}/flow=${flow_id}    data=${flow_body}
+    ${resp}=    RequestsLibrary.Put Request    session    ${RFC8040_NODES_API}/node=openflow%3A${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id}    data=${flow_body}
     Log    ${resp.text}
-    ${msg}=    Set Variable    Updating flow for ${RFC8040_NODES_API}/node=openflow%3A${node_id}/table=${table_id}/flow=${flow_id} failed, http response ${resp.status_code} received.
+    ${msg}=    Set Variable    Updating flow for ${RFC8040_NODES_API}/node=openflow%3A${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id} failed, http response ${resp.status_code} received.
     Should Be Equal As Strings    ${resp.status_code}    204    msg=${msg}
 
 Delete Flow Via RPC
@@ -514,20 +519,22 @@ Delete Flow Via RPC
     ${strxml}=    Element To String    ${req}
     ${resp}=    RequestsLibrary.Post Request    session    /rests/operations/sal-flow:remove-flow    data=${strxml}
     Log    ${resp.text}
-    Should Be Equal As Strings    ${resp.status_code}    200
+    ${expected_status_code}=    CompareStream.Set_Variable_If_At_Least_Phosphorus    204    200
+    Log    ${expected_status_code}
+    Should Be Equal As Strings    ${resp.status_code}    ${expected_status_code}
 
 Delete Flow Via Restconf
     [Arguments]    ${node_id}    ${table_id}    ${flow_id}
     [Documentation]    Deletes a flow from configuration datastore specified by given flow details (${node_id}, ${table_id}, ${flow_body}) using DELETE method
-    ${resp}=    RequestsLibrary.Delete Request    session    ${RFC8040_NODES_API}/node=openflow%3A${node_id}/table=${table_id}/flow=${flow_id}
+    ${resp}=    RequestsLibrary.Delete Request    session    ${RFC8040_NODES_API}/node=openflow%3A${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id}
     Log    ${resp.text}
-    ${msg}=    Set Variable    Delete flow for ${RFC8040_NODES_API}/node=openflow%3A${node_id}/table=${table_id}/flow=${flow_id} failed, http response ${resp.status_code} received.
+    ${msg}=    Set Variable    Delete flow for ${RFC8040_NODES_API}/node=openflow%3A${node_id}/flow-node-inventory:table=${table_id}/flow=${flow_id} failed, http response ${resp.status_code} received.
     Should Be Equal As Strings    ${resp.status_code}    204    msg=${msg}
 
 Get Flow Id
     [Arguments]    ${dpnid}    ${table_id}    ${flow_element}
     [Documentation]    This verifies specific flow-id for particular table-id matching from the flow element
-    ${resp} =    RequestsLibrary.Get Request    session    ${RFC8040_NODES_API}/node=openflow%3A${dpnid}/table=${table_id}?content=config
+    ${resp} =    RequestsLibrary.Get Request    session    ${RFC8040_NODES_API}/node=openflow%3A${dpnid}/flow-node-inventory:table=${table_id}?content=config
     BuiltIn.Log    ${resp.text}
     @{flow_id} =    String.Get Regexp Matches    ${resp.text}    id\":\"(\\d+${flow_element})    1
     [Return]    @{flow_id}[0]