ClusterManagement.List_Indices_Or_All
[integration/test.git] / csit / libraries / KarafKeywords.robot
index a8d97841de2efa92ae40082387a954199bdaa531..8bbbd72fb32cb5444e4004439382cfdbd8884bc5 100644 (file)
@@ -18,7 +18,7 @@ Setup Karaf Keywords
     ClusterManagement.ClusterManagement_Setup
     BuiltIn.Comment    First connections to Karaf console may fail, so WUKS is used. TODO: Track as a Bug.
     : FOR    ${index}    IN    @{ClusterManagement__member_index_list}
-    \    BuiltIn.Wait_Until_Keyword_Succeeds    3x    0.2s    Open Controller Karaf Console On Background    member_index=${index}
+    \    BuiltIn.Wait_Until_Keyword_Succeeds    10x    0.2s    Open Controller Karaf Console On Background    member_index=${index}
 
 Verify Feature Is Installed
     [Arguments]    ${feature_name}    ${controller}=${ODL_SYSTEM_IP}    ${karaf_port}=${KARAF_SHELL_PORT}
@@ -28,7 +28,7 @@ Verify Feature Is Installed
     [Return]    ${output}
 
 Issue Command On Karaf Console
-    [Arguments]    ${cmd}    ${controller}=${ODL_SYSTEM_IP}    ${karaf_port}=${KARAF_SHELL_PORT}    ${timeout}=5    ${loglevel}=INFO
+    [Arguments]    ${cmd}    ${controller}=${ODL_SYSTEM_IP}    ${karaf_port}=${KARAF_SHELL_PORT}    ${timeout}=10    ${loglevel}=INFO
     [Documentation]    Will execute the given ${cmd} by ssh'ing to the karaf console running on ${controller}
     ...    Note that this keyword will open&close new SSH connection, without switching back to previously current session.
     Open Connection    ${controller}    port=${karaf_port}    prompt=${KARAF_PROMPT}    timeout=${timeout}
@@ -40,7 +40,7 @@ Issue Command On Karaf Console
     [Return]    ${output}
 
 Safe_Issue_Command_On_Karaf_Console
-    [Arguments]    ${cmd}    ${controller}=${ODL_SYSTEM_IP}    ${karaf_port}=${KARAF_SHELL_PORT}    ${timeout}=5    ${loglevel}=INFO
+    [Arguments]    ${cmd}    ${controller}=${ODL_SYSTEM_IP}    ${karaf_port}=${KARAF_SHELL_PORT}    ${timeout}=10    ${loglevel}=INFO
     [Documentation]    Run Issue_Command_On_Karaf_Console but restore previous connection afterwards.
     BuiltIn.Run_Keyword_And_Return    SSHKeywords.Run_Keyword_Preserve_Connection    Issue_Command_On_Karaf_Console    ${cmd}    ${controller}    ${karaf_port}    ${timeout}
     ...    ${loglevel}
@@ -83,6 +83,15 @@ Install a Feature
     Log    ${output}
     [Return]    ${output}
 
+Install a Feature Using Active Connection
+    [Arguments]    ${feature_name}
+    [Documentation]    Will Install the given ${feature_name} using active connection
+    ${cmd}=    BuiltIn.Set_Variable    feature:install ${feature_name}
+    Write    ${cmd}
+    ${output}    SSHLibrary.Read_Until    ${KARAF_PROMPT}
+    Log    ${output}
+    [Return]    ${output}
+
 Uninstall a Feature
     [Arguments]    ${feature_name}    ${controller}=${ODL_SYSTEM_IP}    ${karaf_port}=${KARAF_SHELL_PORT}    ${timeout}=180
     [Documentation]    Will UnInstall the given ${feature_name}
@@ -91,7 +100,7 @@ Uninstall a Feature
     [Return]    ${output}
 
 Open Controller Karaf Console On Background
-    [Arguments]    ${member_index}=${1}
+    [Arguments]    ${member_index}=${1}    ${timeout}=10    ${loglevel}=INFO
     [Documentation]    If there is a stored ssh connection index of connection to the controller's karaf console for ${member_index},
     ...    close the previous connection. In any case create a new connection
     ...    to karaf console for ${member_index}, set correct prompt set and login to karaf console.
@@ -103,18 +112,26 @@ Open Controller Karaf Console On Background
     BuiltIn.Run Keyword If    '${status}'=='PASS'    BuiltIn.Run Keywords    SSHLibrary.Switch Connection    ${old_connection_index}
     ...    AND    SSHLibrary.Close Connection
     ${odl_ip}=    ClusterManagement.Resolve_IP_Address_For_Member    ${member_index}
-    SSHLibrary.Open Connection    ${odl_ip}    port=${KARAF_SHELL_PORT}    prompt=${KARAF_DETAILED_PROMPT}
+    SSHLibrary.Open Connection    ${odl_ip}    port=${KARAF_SHELL_PORT}    prompt=${KARAF_DETAILED_PROMPT}    timeout=${timeout}
     ${karaf_connection_object}=    SSHLibrary.Get Connection
     Collections.Set To Dictionary    ${connection_index_dict}    ${member_index}    ${karaf_connection_object.index}
-    SSHLibrary.Login    ${KARAF_USER}    ${KARAF_PASSWORD}
+    SSHLibrary.Login    ${KARAF_USER}    ${KARAF_PASSWORD}    loglevel=${loglevel}
     [Teardown]    SSHKeywords.Restore Current SSH Connection From Index    ${current_ssh_connection_object.index}
 
+Open Controller Karaf Console With Timeout
+    [Arguments]    ${member_index}=${1}    ${timeout}=3s
+    [Documentation]    Open new connection to karaf console for member index with specified timeout.
+    BuiltIn.Log    ${member_index}
+    ${odl_ip}=    ClusterManagement.Resolve_IP_Address_For_Member    ${member_index}
+    SSHLibrary.Open Connection    ${odl_ip}    port=${KARAF_SHELL_PORT}    prompt=${KARAF_DETAILED_PROMPT}    timeout=${timeout}
+    SSHLibrary.Login    ${KARAF_USER}    ${KARAF_PASSWORD}
+
 Configure Timeout For Karaf Console
     [Arguments]    ${timeout}    ${member_index_list}=${EMPTY}
     [Documentation]    Configure a different timeout for each Karaf console.
-    ${index_list} =    ClusterManagement.ClusterManagement__Given_Or_Internal_Index_List    given_list=${member_index_list}
+    ${index_list} =    ClusterManagement.List Indices Or All    given_list=${member_index_list}
     ${current_connection_object}=    SSHLibrary.Get Connection
-    : FOR    ${index}    IN    @{index_list}    # usually: 1, 2, 3.
+    : FOR    ${member_index}    IN    @{index_list}    # usually: 1, 2, 3
     \    ${karaf_connection_index}=    Collections.Get From Dictionary    ${connection_index_dict}    ${member_index}
     \    SSHLibrary.Switch Connection    ${karaf_connection_index}
     \    SSHLibrary.Set_Client_Configuration    timeout=${timeout}
@@ -144,11 +161,13 @@ Execute Controller Karaf Command With Retry On Background
     [Return]    ${message}
 
 Log Message To Controller Karaf
-    [Arguments]    ${message}    ${member_index_list}=${EMPTY}
+    [Arguments]    ${message}    ${member_index_list}=${EMPTY}    ${tolerate_failure}=True
     [Documentation]    Make sure this resource is initialized. Send a message into the controller's karaf log file on every node listed (or all).
-    ${index_list} =    ClusterManagement.ClusterManagement__Given_Or_Internal_Index_List    given_list=${member_index_list}
+    ...    By default, failure while processing a node is silently ignored, unless ${tolerate_failure} is False.
+    ${index_list} =    ClusterManagement.List Indices Or All    given_list=${member_index_list}
     : FOR    ${index}    IN    @{index_list}    # usually: 1, 2, 3.
-    \    Execute Controller Karaf Command With Retry On Background    log:log "ROBOT MESSAGE: ${message}"    member_index=${index}
+    \    ${status}    ${output}=    BuiltIn.Run Keyword And Ignore Error    Execute Controller Karaf Command With Retry On Background    log:log "ROBOT MESSAGE: ${message}"    member_index=${index}
+    \    BuiltIn.Run_Keyword_Unless    ${tolerate_failure} or "${status}" == "PASS"    BuiltIn.Fail    ${output}
 
 Log Test Suite Start To Controller Karaf
     [Arguments]    ${member_index_list}=${EMPTY}
@@ -164,7 +183,7 @@ Set Bgpcep Log Levels
     [Arguments]    ${bgpcep_level}=${DEFAULT_BGPCEP_LOG_LEVEL}    ${protocol_level}=${DEFAULT_PROTOCOL_LOG_LEVEL}    ${member_index_list}=${EMPTY}
     [Documentation]    Assuming OCKCOB was used, set logging level on bgpcep and protocol loggers without affecting current SSH session.
     # FIXME: Move to appropriate Resource
-    ${index_list} =    ClusterManagement.ClusterManagement__Given_Or_Internal_Index_List    given_list=${member_index_list}
+    ${index_list} =    ClusterManagement.List Indices Or All    given_list=${member_index_list}
     : FOR    ${index}    IN    @{index_list}    # usually: 1, 2, 3.
     \    Execute Controller Karaf Command On Background    log:set ${bgpcep_level} org.opendaylight.bgpcep    member_index=${index}
     \    Execute Controller Karaf Command On Background    log:set ${protocol_level} org.opendaylight.protocol    member_index=${index}