SXP: Make cluster routing suite more readable
[integration/test.git] / csit / libraries / SxpLib.robot
index 2db5fbc60395147a0e2ecdb28ddc55e4c434f9af..6bb5b971337314b492a4a124cd9ae35b6b2eb75b 100644 (file)
@@ -28,7 +28,7 @@ Post To Controller
     BuiltIn.Should Be True    ${result}    RPC result is False
 
 Add Node
-    [Arguments]    ${node}    ${password}=${EMPTY}    ${version}=version4    ${port}=64999    ${session}=session    ${ip}=${EMPTY}
+    [Arguments]    ${node}    ${password}=${EMPTY}    ${version}=version4    ${port}=64999    ${session}=session    ${ip}=${node}
     ...    ${ssl_stores}=${EMPTY}    ${retry_open_timer}=1
     [Documentation]    Add node via RPC to ODL
     ${data} =    Sxp.Add Node Xml    ${node}    ${port}    ${password}    ${version}    ${ip}
@@ -191,7 +191,7 @@ Should Contain Connection
     [Documentation]    Test if data contains specified connection
     ${out} =    Sxp.Find Connection    ${resp}    ${version}    ${mode}    ${ip}    ${port}
     ...    ${state}
-    BuiltIn.Should Be True    ${out}    Doesn't have ${ip}:${port} ${mode} ${version}
+    BuiltIn.Should Be True    ${out}    Doesn't have ${ip}:${port} ${mode} ${version} in state ${state}
 
 Should Not Contain Connection
     [Arguments]    ${resp}    ${ip}    ${port}    ${mode}    ${version}    ${state}=none
@@ -248,26 +248,6 @@ Verify Snapshot Was Pushed
     ${output} =    Utils.Run Command On Controller    ${ODL_SYSTEM_IP}    cat ${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log* | grep -c 'Successfully pushed configuration snapshot.*${snapshot_string}'
     BuiltIn.Should Not Be Equal As Strings    ${output}    0
 
-Prepare SSH Keys On Karaf
-    [Arguments]    ${system}=${ODL_SYSTEM_IP}    ${user}=${ODL_SYSTEM_USER}    ${passwd}=${ODL_SYSTEM_PASSWORD}    ${prompt}=${ODL_SYSTEM_PROMPT}    ${system_workspace}=${WORKSPACE}
-    [Documentation]    Executes client login on karaf VM in so that SSH keys will be generated by defualt karaf callback,
-    ...    expecting echo affter succesfull login. TODO: test on multiple runs if this aproach reduce SSHExceptions in robotframework
-    ${stdout} =    Utils.Run Command On Remote System    ${system}    ${system_workspace}${/}${BUNDLEFOLDER}/bin/client echo READY    ${user}    ${passwd}    prompt=${prompt}
-    BuiltIn.Should Match    "${stdout}"    "*READY"
-
-Setup SXP Session
-    [Arguments]    ${session}=session    ${controller}=${ODL_SYSTEM_IP}
-    [Documentation]    Create session to Controller
-    KarafKeywords.Verify Feature Is Installed    odl-sxp-controller    ${controller}
-    RequestsLibrary.Create Session    ${session}    url=http://${controller}:${RESTCONFPORT}    auth=${AUTH}    headers=${HEADERS_XML}
-    ${resp} =    RequestsLibrary.Get Request    ${session}    ${MODULES_API}
-    BuiltIn.Should Be Equal As Strings    ${resp.status_code}    200
-    BuiltIn.Should Contain    ${resp.content}    ietf-restconf
-
-Clean SXP Session
-    [Documentation]    Destroy created sessions
-    RequestsLibrary.Delete All Sessions
-
 Add Domain
     [Arguments]    ${domain_name}    ${sgt}=None    ${prefixes}=None    ${origin}=LOCAL    ${node}=127.0.0.1    ${session}=session
     [Documentation]    Based on ODL version decide if domain's bindings will be added with or without origin type (introduced in Fluorine)
@@ -322,30 +302,30 @@ Check Binding Range Negative
     \    Should Not Contain Binding    ${resp}    ${sgt}    ${ip}/32
 
 Setup SXP Environment
-    [Arguments]    ${node_range}=2
-    [Documentation]    Create session to Controller, node_range parameter specifies number of nodes to be created plus one
-    Setup SXP Session
-    : FOR    ${num}    IN RANGE    1    ${node_range}
+    [Arguments]    ${node_range}=1
+    [Documentation]    Create session to Controller, ${node_range} parameter specifies number of nodes to be created
+    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
     \    ${ip} =    Sxp.Get Ip From Number    ${num}
     \    ${rnd_retry_time} =    BuiltIn.Evaluate    random.randint(1, 10)    modules=random
     \    Add Node    ${ip}    retry_open_timer=${rnd_retry_time}
     \    BuiltIn.Wait Until Keyword Succeeds    20    1    Check Node Started    ${ip}
 
 Check Node Started
-    [Arguments]    ${node}    ${port}=64999    ${system}=${ODL_SYSTEM_IP}    ${session}=session    ${ip}=${node}
-    [Documentation]    Verify that SxpNode has data writed to Operational datastore
+    [Arguments]    ${node}    ${port}=64999    ${system}=${node}    ${session}=session    ${ip}=${node}
+    [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}
     BuiltIn.Should Be Equal As Strings    ${rc}    0
 
 Clean SXP Environment
-    [Arguments]    ${node_range}=2
+    [Arguments]    ${node_range}=1
     [Documentation]    Destroy created sessions
-    : FOR    ${num}    IN RANGE    1    ${node_range}
+    : FOR    ${num}    IN RANGE    1    ${node_range}+1
     \    ${ip} =    Sxp.Get Ip From Number    ${num}
     \    Delete Node    ${ip}
-    Clean SXP Session
+    RequestsLibrary.Delete All Sessions
 
 Get Routing Configuration From Controller
     [Arguments]    ${session}