Use test tools from release that is under test
[integration/test.git] / csit / libraries / SSHKeywords.robot
index d49ce199cec893f5f2ffbd2cd37824b58a821c24..f3f79a2d6a8051da1cbefd9335629be4a1a92bad 100644 (file)
@@ -13,8 +13,22 @@ Documentation     Resource enhancing SSHLibrary with Keywords used in multiple s
 ...               and if the Keywords do not fit into a more specific Resource,
 ...               you can place them here.
 Library           SSHLibrary
+Resource          ${CURDIR}/Utils.robot
 
 *** Keywords ***
+Open_Connection_To_ODL_System
+    [Documentation]    Open a connection to the ODL system and return its identifier.
+    ...    On clustered systems this opens the connection to the first node.
+    ${odl}=    SSHLibrary.Open_Connection    ${ODL_SYSTEM_IP}    prompt=${ODL_SYSTEM_PROMPT}    timeout=10s
+    Utils.Flexible_Controller_Login
+    [Return]    ${odl}
+
+Open_Connection_To_Tools_System
+    [Documentation]    Open a connection to the tools system and return its identifier.
+    ${tools}=    SSHLibrary.Open_Connection    ${TOOLS_SYSTEM_IP}    prompt=${TOOLS_SYSTEM_PROMPT}
+    Utils.Flexible_Mininet_Login
+    [Return]    ${tools}
+
 Execute_Command_Passes
     [Arguments]    ${command}
     [Documentation]    Execute command via SSH. If RC is nonzero, log everything. Retrun bool string of command success.
@@ -45,3 +59,9 @@ Assure_Library_Counter
     # TODO: Move the bash-cd wrapper to separate keyword?
     BuiltIn.Return_From_Keyword_If    ${passed}
     SSHLibrary.Put_File    ${CURDIR}/Counter.py    ${target_dir}/
+
+Count_Port_Occurences
+    [Arguments]    ${port}    ${state}    ${name}
+    [Documentation]    Run 'netstat' on the remote machine and count occurences of given port in the given state connected to process with the given name.
+    ${output}=    SSHLibrary.Execute_Command    netstat -natp 2> /dev/null | grep -E ":${port} .+ ${state} .+${name}" | wc -l
+    [Return]    ${output}