Add a fix to update java version for VTN Coordinator Boron
[integration/test.git] / csit / libraries / Utils.robot
index 0f0ce259cd5ac98607849ee5a29d126919f38daa..13b1dd1b29db890d5f4c5de847c1a6e231ef6446 100644 (file)
@@ -232,12 +232,14 @@ Run Command On Remote System
     [Documentation]    Reduces the common work of running a command on a remote system to a single higher level
     ...    robot keyword, taking care to log in with a public key and. The command given is written
     ...    and the output returned. No test conditions are checked.
-    Log    Attempting to execute ${cmd} on ${system} by ${user} with ${keyfile_pass} and ${prompt}
+    ${current_ssh_connection}=    SSHLibrary.Get Connection
+    Log    Attempting to execute command "${cmd}" on remote system "${system}" by user "${user}" with keyfile pass "${keyfile_pass}" and prompt "${prompt}"
     ${conn_id}=    SSHLibrary.Open Connection    ${system}    prompt=${prompt}    timeout=${prompt_timeout}
     Flexible SSH Login    ${user}    ${password}
     ${stdout}    ${stderr}    SSHLibrary.Execute Command    ${cmd}    return_stderr=True
     SSHLibrary.Close Connection
     Log    ${stderr}
+    [Teardown]    KarafKeywords.Restore_Current_SSH_Connection_From_Index    ${current_ssh_connection.index}
     [Return]    ${stdout}
 
 Write_Bare_Ctrl_C
@@ -468,3 +470,32 @@ Set_User_Configurable_Variable_Default
     #    "pybot -v".
     ${value}=    BuiltIn.Get_Variable_Value    \${${name}}    ${value}
     BuiltIn.Set_Suite_Variable    \${${name}}    ${value}
+
+Convert_To_Minutes
+    [Arguments]    ${time}
+    [Documentation]    Convert a Robot time string to an integer expressing the time in minutes, rounded up
+    ...    This is a wrapper around DateTime.Convert_Time which does not
+    ...    provide this functionality directly nor is even able to produce
+    ...    an integer directly. It is needed for RestPerfClient which
+    ...    cannot accept floats for its --timeout parameter and interprets
+    ...    the value supplied in this parameter in minutes.
+    ${seconds}=    DateTime.Convert_Time    ${time}    result_format=number
+    ${minutes}=    BuiltIn.Evaluate    int(math.ceil(${seconds}/60.0))    modules=math
+    [Return]    ${minutes}
+
+Write Commands Until Expected Prompt
+    [Arguments]    ${cmd}    ${prompt}    ${timeout}=30s
+    [Documentation]    quick wrapper for Write and Read Until Prompt Keywords to make test cases more readable
+    SSHLibrary.Set Client Configuration    timeout=${timeout}
+    SSHLibrary.Write    ${cmd}
+    ${output}=    SSHLibrary.Read Until    ${prompt}
+    [Return]    ${output}
+
+Install Package On Ubuntu System
+    [Arguments]    ${package_name}    ${system}=${TOOLS_SYSTEM_IP}    ${user}=${TOOLS_SYSTEM_USER}    ${password}=${TOOLS_SYSTEM_PASSWORD}    ${prompt}=${DEFAULT_LINUX_PROMPT}    ${prompt_timeout}=30s
+    [Documentation]    Keyword to install packages for testing to Ubuntu Mininet VM
+    Log    Keyword to install package to Mininet Ubuntu VM
+    Open Connection    ${system}    prompt=${prompt}    timeout=${prompt_timeout}
+    Flexible Mininet Login    user=${user}    password=${password}
+    Write    sudo apt-get install -y ${package_name}
+    Read Until    ${prompt}