Modification on SFC test Cases
[integration/test.git] / csit / libraries / SxpLib.robot
index da4e5d4bb1b4c3d1ca5e49f6e9e2ff2b4ac64945..c75a7820fa3309bd005aff9c2036cb25cc124a30 100644 (file)
@@ -151,10 +151,22 @@ Clean Peer Groups
 Add Filter
     [Arguments]    ${name}    ${type}    ${entries}    ${node}=127.0.0.1    ${session}=session    ${policy}=auto-update
     [Documentation]    Add Filter via RPC from Node
+    ${data} =    Prepare Add/Update Filter Data    ${name}    ${type}    ${entries}    ${node}    ${policy}
+    Post To Controller    ${session}    add-filter    ${data}
+
+Update Filter
+    [Arguments]    ${name}    ${type}    ${entries}    ${node}=127.0.0.1    ${session}=session    ${policy}=auto-update
+    [Documentation]    Update Filter via RPC
+    ${data} =    Prepare Add/Update Filter Data    ${name}    ${type}    ${entries}    ${node}    ${policy}
+    Post To Controller    ${session}    update-filter    ${data}
+
+Prepare Add/Update Filter Data
+    [Arguments]    ${name}    ${type}    ${entries}    ${node}=127.0.0.1    ${policy}=auto-update
+    [Documentation]    Prepare XML payload for add-filter and update-filter RPCs. Payloads for both RPCs are the same.
     ${data} =    CompareStream.Run_Keyword_If_At_Least_Else    carbon    Add Filter Xml    ${name}    ${type}    ${entries}
     ...    ${node}    ${policy}
     ...    ELSE    Add Filter Xml    ${name}    ${type}    ${entries}    ${node}
-    Post To Controller    ${session}    add-filter    ${data}
+    [Return]    ${data}
 
 Add Domain Filter
     [Arguments]    ${name}    ${domains}    ${entries}    ${node}=127.0.0.1    ${filter_name}=base-domain-filter    ${session}=session
@@ -307,8 +319,7 @@ Setup SXP Environment
     RequestsLibrary.Create Session    session    http://${ODL_SYSTEM_IP}:${RESTCONFPORT}    auth=${AUTH}    timeout=${DEFAULT_TIMEOUT_HTTP}    max_retries=0
     : FOR    ${num}    IN RANGE    1    ${node_range}+1
     \    ${node} =    Sxp.Get Ip From Number    ${num}
-    \    ${rnd_retry_time} =    BuiltIn.Evaluate    random.randint(1, 10)    modules=random
-    \    Add Node    ${node}    retry_open_timer=${rnd_retry_time}
+    \    Add Node    ${node}    retry_open_timer=${num}
     \    BuiltIn.Wait Until Keyword Succeeds    20    1    Check Node Started    ${node}    system=${ODL_SYSTEM_IP}
 
 Check Node Started
@@ -316,15 +327,30 @@ Check Node Started
     [Documentation]    Verify that SxpNode has data writen to Operational datastore and is running
     ${resp} =    RequestsLibrary.Get Request    ${session}    /restconf/operational/network-topology:network-topology/topology/sxp/node/${node}/
     BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
-    ${rc} =    Utils.Run Command On Remote System    ${system}    netstat -tln | grep -q ${ip}:${port} && echo 0 || echo 1    ${ODL_SYSTEM_USER}    ${ODL_SYSTEM_PASSWORD}    prompt=${ODL_SYSTEM_PROMPT}
+    ${rc} =    Get Node Running Status    ${node}    ${port}    ${system}    ${session}    ${ip}
     BuiltIn.Should Be Equal As Strings    ${rc}    0
 
+Check Node Stopped
+    [Arguments]    ${node}    ${port}=64999    ${system}=${node}    ${session}=session    ${ip}=${node}
+    [Documentation]    Verify that SxpNode has data removed from Operational datastore and is not running
+    ${resp} =    RequestsLibrary.Get Request    ${session}    /restconf/operational/network-topology:network-topology/topology/sxp/node/${node}/
+    BuiltIn.Should Be Equal As Strings    ${resp.status_code}    404
+    ${rc} =    Get Node Running Status    ${node}    ${port}    ${system}    ${session}    ${ip}
+    BuiltIn.Should Be Equal As Strings    ${rc}    1
+
+Get Node Running Status
+    [Arguments]    ${node}    ${port}    ${system}    ${session}    ${ip}
+    [Documentation]    Get status if node is running by checking that netty server is running
+    ${rc} =    Utils.Run Command On Remote System    ${system}    netstat -tln | grep -q ${ip}:${port} && echo 0 || echo 1    ${ODL_SYSTEM_USER}    ${ODL_SYSTEM_PASSWORD}    prompt=${ODL_SYSTEM_PROMPT}
+    [Return]    ${rc}
+
 Clean SXP Environment
     [Arguments]    ${node_range}=1
     [Documentation]    Destroy created sessions
     : FOR    ${num}    IN RANGE    1    ${node_range}+1
     \    ${ip} =    Sxp.Get Ip From Number    ${num}
     \    Delete Node    ${ip}
+    \    BuiltIn.Wait Until Keyword Succeeds    12x    10s    Check Node Stopped    ${ip}    system=${ODL_SYSTEM_IP}
     RequestsLibrary.Delete All Sessions
 
 Get Routing Configuration From Controller