From 50127a8724b4e6ed61a1e19e5bea33863c396a18 Mon Sep 17 00:00:00 2001 From: Vratko Polak Date: Thu, 16 Mar 2017 14:23:56 +0100 Subject: [PATCH] ClusterManagement.List_Indices_Or_All Consumers of the old private name updated: BulkomaticKeywords, KarafKeywords, MininetKeywords, OVSDB, staggered_install, internal ClusterManagement calls. ClusterManagement__Given_Or_Empty_List removed as nobody calls that. Change-Id: I697c1ca7be8f3dc54fd076cd2c86083a469e04e0 Signed-off-by: Vratko Polak --- csit/libraries/BulkomaticKeywords.robot | 2 +- csit/libraries/ClusterManagement.robot | 64 ++++++++----------- csit/libraries/KarafKeywords.robot | 6 +- csit/libraries/MininetKeywords.robot | 2 +- csit/libraries/OVSDB.robot | 2 +- .../clusteringscale/staggered_install.robot | 3 +- 6 files changed, 35 insertions(+), 44 deletions(-) diff --git a/csit/libraries/BulkomaticKeywords.robot b/csit/libraries/BulkomaticKeywords.robot index d39090b90e..c76bc7e75a 100644 --- a/csit/libraries/BulkomaticKeywords.robot +++ b/csit/libraries/BulkomaticKeywords.robot @@ -77,7 +77,7 @@ Delete Bulk Flow In Node Get Bulk Flow And Verify Count In Cluster [Arguments] ${json_body_get} ${timeout} ${flow_count} ${controller_index_list}=${EMPTY} [Documentation] Get Bulk Flow and Verify Flow Count in ${controller_index_list} matches ${flow_count}. - ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${controller_index_list} + ${index_list} = ClusterManagement.List Indices Or All given_list=${controller_index_list} : FOR ${index} IN @{index_list} \ Get Bulk Flow ${json_body_get} ${index} : FOR ${index} IN @{index_list} diff --git a/csit/libraries/ClusterManagement.robot b/csit/libraries/ClusterManagement.robot index b394968579..6e46286909 100644 --- a/csit/libraries/ClusterManagement.robot +++ b/csit/libraries/ClusterManagement.robot @@ -71,7 +71,7 @@ ClusterManagement_Setup Check_Cluster_Is_In_Sync [Arguments] ${member_index_list}=${EMPTY} [Documentation] Fail if no-sync is detected on a member from list (or any). - ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list} + ${index_list} = List_Indices_Or_All given_list=${member_index_list} : FOR ${index} IN @{index_list} # usually: 1, 2, 3. \ ${status} = Get_Sync_Status_Of_Member member_index=${index} \ BuiltIn.Continue_For_Loop_If 'True' == '${status}' @@ -114,7 +114,7 @@ Get_State_Info_For_Shard ... If \${validate}, Fail if raft state is not Leader or Follower (for example on Candidate). ... The biggest difference from Get_Leader_And_Followers_For_Shard ... is that no check on number of Leaders is performed. - ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list} + ${index_list} = List_Indices_Or_All given_list=${member_index_list} Collections.Sort_List ${index_list} # to guarantee return values are also sorted lists # TODO: Support alternative capitalization of 'config'? ${ds_type} = BuiltIn.Set_Variable_If '${shard_type}' != 'config' operational config @@ -160,7 +160,7 @@ Verify_Owner_And_Successors_For_Device ... ${candidate_list} minus owner is returned as ${successor list}. ... Users can still use Get_Owner_And_Successors_For_Device if they are interested in downed candidates, ... or for testing heterogeneous clusters. - ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${candidate_list} + ${index_list} = List_Indices_Or_All given_list=${candidate_list} ${owner} ${successor_list} = Get_Owner_And_Successors_For_Device device_name=${device_name} device_type=${device_type} member_index=${member_index} Collections.List_Should_Contain_Value ${index_list} ${owner} Owner ${owner} is not in candidate list ${index_list} # In Beryllium or after stopping an instance, the removed instance does not show in the candidate list. @@ -335,8 +335,8 @@ Kill_Members_From_List_Or_All [Documentation] If the list is empty, kill all ODL instances. Otherwise, kill members based on \${kill_index_list} ... If \${confirm} is True, sleep 1 second and verify killed instances are not there anymore. ... The KW will return a list of available members: \${updated index_list}=\${original_index_list}-\${member_index_list} - ${kill_index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list} - ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${original_index_list} + ${kill_index_list} = List_Indices_Or_All given_list=${member_index_list} + ${index_list} = List_Indices_Or_All given_list=${original_index_list} Run_Bash_Command_On_List_Or_All command=${NODE_KILL_COMMAND} member_index_list=${member_index_list} ${updated_index_list} = BuiltIn.Create_List @{index_list} Collections.Remove_Values_From_List ${updated_index_list} @{kill_index_list} @@ -360,8 +360,8 @@ Stop_Members_From_List_Or_All [Documentation] If the list is empty, stops all ODL instances. Otherwise stop members based on \${stop_index_list} ... If \${confirm} is True, verify stopped instances are not there anymore. ... The KW will return a list of available members: \${updated index_list}=\${original_index_list}-\${member_index_list} - ${stop_index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list} - ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${original_index_list} + ${stop_index_list} = List_Indices_Or_All given_list=${member_index_list} + ${index_list} = List_Indices_Or_All given_list=${original_index_list} Run_Bash_Command_On_List_Or_All command=${NODE_STOP_COMMAND} member_index_list=${member_index_list} ${updated_index_list} = BuiltIn.Create_List @{index_list} Collections.Remove_Values_From_List ${updated_index_list} @{stop_index_list} @@ -405,13 +405,13 @@ Freeze_Or_Unfreeze_Members_From_List_Or_All [Arguments] ${command} ${member_index_list}=${EMPTY} [Documentation] If the list is empty, stops/runs all ODL instances. Otherwise stop/run members based on \${stop_index_list} ... For command parameter only ${NODE_FREEZE_COMMAND} and ${NODE_UNFREEZE_COMMAND} should be used - ${freeze_index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list} + ${freeze_index_list} = List_Indices_Or_All given_list=${member_index_list} Run_Bash_Command_On_List_Or_All command=${command} member_index_list=${member_index_list} Clean_Journals_And_Snapshots_On_List_Or_All [Arguments] ${member_index_list}=${EMPTY} ${karaf_home}=${KARAF_HOME} [Documentation] Delete journal and snapshots directories on every node listed (or all). - ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list} + ${index_list} = List_Indices_Or_All given_list=${member_index_list} ${command} = Set Variable rm -rf "${karaf_home}/journal" "${karaf_home}/snapshots" : FOR ${index} IN @{index_list} # usually: 1, 2, 3. \ Run_Bash_Command_On_Member command=${command} member_index=${index} @@ -439,7 +439,7 @@ Isolate_Member_From_List_Or_All [Arguments] ${isolate_member_index} ${member_index_list}=${EMPTY} [Documentation] If the list is empty, isolate member from all ODL instances. Otherwise, isolate member based on present indices. ... The KW will return a list of available members: \${updated index_list}=\${member_index_list}-\${isolate_member_index} - ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list} + ${index_list} = List_Indices_Or_All given_list=${member_index_list} ${source} = Collections.Get_From_Dictionary ${ClusterManagement__index_to_ip_mapping} ${isolate_member_index} : FOR ${index} IN @{index_list} \ ${destination} = Collections.Get_From_Dictionary ${ClusterManagement__index_to_ip_mapping} ${index} @@ -455,7 +455,7 @@ Isolate_Member_From_List_Or_All Rejoin_Member_From_List_Or_All [Arguments] ${rejoin_member_index} ${member_index_list}=${EMPTY} [Documentation] If the list is empty, rejoin member from all ODL instances. Otherwise, rejoin member based on present indices. - ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list} + ${index_list} = List_Indices_Or_All given_list=${member_index_list} ${source} = Collections.Get_From_Dictionary ${ClusterManagement__index_to_ip_mapping} ${rejoin_member_index} : FOR ${index} IN @{index_list} \ ${destination} = Collections.Get_From_Dictionary ${ClusterManagement__index_to_ip_mapping} ${index} @@ -474,7 +474,7 @@ Flush_Iptables_From_List_Or_All Run_Bash_Command_On_List_Or_All [Arguments] ${command} ${member_index_list}=${EMPTY} [Documentation] Cycle through indices (or all), run command on each. - ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list} + ${index_list} = List_Indices_Or_All given_list=${member_index_list} : FOR ${index} IN @{index_list} \ Run_Bash_Command_On_Member command=${command} member_index=${index} @@ -489,7 +489,7 @@ Run_Bash_Command_On_Member Run_Karaf_Command_On_List_Or_All [Arguments] ${command} ${member_index_list}=${EMPTY} ${timeout}=10s [Documentation] Cycle through indices (or all), run karaf command on each. - ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list} + ${index_list} = List_Indices_Or_All given_list=${member_index_list} : FOR ${index} IN @{index_list} \ ${member_ip} = Collections.Get_From_Dictionary dictionary=${ClusterManagement__index_to_ip_mapping} key=${index} \ KarafKeywords.Safe_Issue_Command_On_Karaf_Console ${command} ${member_ip} timeout=${timeout} @@ -505,7 +505,7 @@ Run_Karaf_Command_On_Member Install_Feature_On_List_Or_All [Arguments] ${feature_name} ${member_index_list}=${EMPTY} ${timeout}=60s [Documentation] Attempt installation on each member from list (or all). Then look for failures. - ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list} + ${index_list} = List_Indices_Or_All given_list=${member_index_list} ${status_list} = BuiltIn.Create_List : FOR ${index} IN @{index_list} \ ${status} ${text} = BuiltIn.Run_Keyword_And_Ignore_Error Install_Feature_On_Member feature_name=${feature_name} member_index=${index} @@ -530,7 +530,7 @@ With_Ssh_To_List_Or_All_Run_Keyword ... Beware that in order to avoid "got positional argument after named arguments", first two arguments in the call should not be named. BuiltIn.Comment This keyword is experimental and there is high risk of being replaced by another approach. # TODO: For_Index_From_List_Or_All_Run_Keyword applied to With_Ssh_To_Member_Run_Keyword? - ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list} + ${index_list} = List_Indices_Or_All given_list=${member_index_list} : FOR ${member_index} IN @{index_list} \ ${member_ip} = Resolve_IP_Address_For_Member ${member_index} \ SSHKeywords.Open_Connection_To_Odl_System ip_address=${member_ip} @@ -606,7 +606,7 @@ Check_Json_Member_List_Or_All [Arguments] ${uri} ${expected_data} ${member_index_list}=${EMPTY} [Documentation] Send a GET with the supplied uri to all or some members defined in ${member_index_list}. ... Then check received data is = ${expected data}. - ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list} + ${index_list} = List_Indices_Or_All given_list=${member_index_list} : FOR ${index} IN @{index_list} \ ${data} = Get_From_Member uri=${uri} member_index=${index} \ TemplatedRequests.Normalize_Jsons_And_Compare ${expected_data} ${data} @@ -615,7 +615,7 @@ Check_Item_Occurrence_Member_List_Or_All [Arguments] ${uri} ${dictionary} ${member_index_list}=${EMPTY} [Documentation] Send a GET with the supplied uri to all or some members defined in ${member_index_list}. ... Then check received for occurrences of items expressed in a dictionary ${dictionary}. - ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list} + ${index_list} = List_Indices_Or_All given_list=${member_index_list} : FOR ${index} IN @{index_list} \ ${data} = Get_From_Member uri=${uri} member_index=${index} \ Utils.Check Item Occurrence ${data} ${dictionary} @@ -624,7 +624,7 @@ Check_No_Content_Member_List_Or_All [Arguments] ${uri} ${member_index_list}=${EMPTY} [Documentation] Send a GET with the supplied uri to all or some members defined in ${member_index_list}. ... Then check there is no content. - ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${member_index_list} + ${index_list} = List_Indices_Or_All given_list=${member_index_list} : FOR ${index} IN @{index_list} \ ${session} = Resolve_Http_Session_For_Member member_index=${index} \ Utils.No_Content_From_URI ${session} ${uri} @@ -672,34 +672,24 @@ ClusterManagement__Parse_Sync_Status List_All_Indices [Documentation] Create a new list of all indices. - ${return_list_copy} = ClusterManagement__Given_Or_Internal_Index_List - BuiltIn.Return_From_Keyword ${return_list_copy} + BuiltIn.Return_Keyword_And_Return List_Indices_Or_All -List_Indices_Minus_Member - [Arguments] ${member_index} ${member_index_list}=${EMPTY} - [Documentation] Create a new list which contains indices from ${member_index_list} (or all) without ${member_index}. - ${index_list} = ClusterManagement__Given_Or_Internal_Index_List ${member_index_list} - Collections.Remove Values From List ${index_list} ${member_index} - [Return] ${index_list} - -ClusterManagement__Given_Or_Internal_Index_List +List_Indices_Or_All [Arguments] ${given_list}=${EMPTY} [Documentation] Utility to allow \${EMPTY} as default argument value, as the internal list is computed at runtime. - ... This keyword always return a (shallow) copy of given or default list, + ... This keyword always returns a (shallow) copy of given or default list, ... so operations with the returned list should not affect other lists. ... Also note that this keyword does not consider empty list to be \${EMPTY}. - ... TODO: This keyword is frequently used for obtaining copy of ${ClusterManagement__member_index_list}. Give this keyword public name. ${return_list_reference} = BuiltIn.Set_Variable_If """${given_list}""" != "" ${given_list} ${ClusterManagement__member_index_list} ${return_list_copy} = BuiltIn.Create_List @{return_list_reference} [Return] ${return_list_copy} -ClusterManagement__Given_Or_Empty_List - [Arguments] ${given_list}=${EMPTY} - [Documentation] Utility to allow \${EMPTY} as default argument value, as an empty list is computed at runtime. - ${empty_list} = BuiltIn.Create_List - ${given_length} = BuiltIn.Get_Length ${given_list} - ${return_list} = BuiltIn.Set_Variable_If ${given_length} > 0 ${given_list} ${empty_list} - [Return] ${return_list} +List_Indices_Minus_Member + [Arguments] ${member_index} ${member_index_list}=${EMPTY} + [Documentation] Create a new list which contains indices from ${member_index_list} (or all) without ${member_index}. + ${index_list} = List_Indices_Or_All ${member_index_list} + Collections.Remove Values From List ${index_list} ${member_index} + [Return] ${index_list} ClusterManagement__Compute_Derived_Variables [Arguments] ${int_of_members} diff --git a/csit/libraries/KarafKeywords.robot b/csit/libraries/KarafKeywords.robot index b7ea013fa3..8bbbd72fb3 100644 --- a/csit/libraries/KarafKeywords.robot +++ b/csit/libraries/KarafKeywords.robot @@ -129,7 +129,7 @@ Open Controller Karaf Console With Timeout 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 ${member_index} IN @{index_list} # usually: 1, 2, 3 \ ${karaf_connection_index}= Collections.Get From Dictionary ${connection_index_dict} ${member_index} @@ -164,7 +164,7 @@ Log Message To Controller Karaf [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). ... By default, failure while processing a node is silently ignored, unless ${tolerate_failure} is False. - ${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. \ ${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} @@ -183,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} diff --git a/csit/libraries/MininetKeywords.robot b/csit/libraries/MininetKeywords.robot index 0c7b89917a..2b4155c9d8 100644 --- a/csit/libraries/MininetKeywords.robot +++ b/csit/libraries/MininetKeywords.robot @@ -31,7 +31,7 @@ Start Mininet Single Controller Start Mininet Multiple Controllers [Arguments] ${mininet} ${controller_index_list}=${EMPTY} ${options}=--topo tree,1 --switch ovsk,protocols=OpenFlow13 ${custom}=${EMPTY} ${ofport}=${ODL_OF_PORT} ${timeout}=${DEFAULT_TIMEOUT} [Documentation] Start Mininet with custom topology and connect to list of controllers in ${controller_index_list} or all if no list is provided. - ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${controller_index_list} + ${index_list} = ClusterManagement.List Indices Or All given_list=${controller_index_list} Log Clear any existing mininet Utils.Clean Mininet System ${mininet} ${mininet_conn_id}= SSHLibrary.Open Connection ${mininet} prompt=${TOOLS_SYSTEM_PROMPT} timeout=${timeout} diff --git a/csit/libraries/OVSDB.robot b/csit/libraries/OVSDB.robot index cdf23e71cd..8dc367e36b 100644 --- a/csit/libraries/OVSDB.robot +++ b/csit/libraries/OVSDB.robot @@ -137,7 +137,7 @@ Check OVS OpenFlow Connections Add Multiple Managers to OVS [Arguments] ${tools_system}=${TOOLS_SYSTEM_IP} ${controller_index_list}=${EMPTY} ${ovs_mgr_port}=6640 [Documentation] Connect OVS to the list of controllers in the ${controller_index_list} or all if no list is provided. - ${index_list} = ClusterManagement__Given_Or_Internal_Index_List given_list=${controller_index_list} + ${index_list} = ClusterManagement.List Indices Or All given_list=${controller_index_list} Log Clear any existing mininet Utils.Clean Mininet System ${tools_system} ${ovs_opt}= Set Variable diff --git a/csit/suites/netconf/clusteringscale/staggered_install.robot b/csit/suites/netconf/clusteringscale/staggered_install.robot index 3b4aa88cd5..d2ea097395 100644 --- a/csit/suites/netconf/clusteringscale/staggered_install.robot +++ b/csit/suites/netconf/clusteringscale/staggered_install.robot @@ -110,8 +110,9 @@ Single_Locate_Owner_Attempt ... For the first member listed: Get the actual owner, check candidates, store owner to suite variable. ... (If the list has less then one item, this Keyword will fail.) ... For other nodes: Get actual owner, check candidates, compare to the first listed member results. + ... TODO: Move to an appropriate Resource. BuiltIn.Comment FIXME: Work with sorted candidte list instead of candidate list length. - ${index_list} = ClusterManagement.ClusterManagement__Given_Or_Internal_Index_List ${member_index_list} + ${index_list} = ClusterManagement.List_Indices_Or_All ${member_index_list} ${require_candidate_list} = BuiltIn.Create_List @{index_list} ${first_index_listed} = Collections.Remove_From_List ${index_list} ${0} # Now ${index_list} contains only the rest of indices. -- 2.36.6