--- /dev/null
+*** Settings ***
+Documentation DOMRpcBroker testing: Common keywords
+...
+... Copyright (c) 2017 Cisco Systems, Inc. and others. All rights reserved.
+...
+... This program and the accompanying materials are made available under the
+... terms of the Eclipse Public License v1.0 which accompanies this distribution,
+... and is available at http://www.eclipse.org/legal/epl-v10.html
+...
+... The aim of this resource is to groups reusable blocks of commands into
+... keywords. It should be initiated by DrbCommons_Init. It creates
+... ${all_indices}, ${registered_indices}, ${nonregistered_indices} and
+... ${possible_constants} suite variables.
+... ${registered_indices} - list of indexes where rpc is registered; including
+... isolated mebers; exluding killed/stopped members
+... ${nonregistered_indices} - list of indexes where rpc is not registrated;
+... including isolated mebers; exluding killed/stopped
+... members
+... ${possible_constants} - list of valid constants responded from the cluster;
+... constant from isolated node with regirered rpc is
+... invalid
+... ${active_indices} - list of indexes of non-isolated, non-stopped/killed nodes
+Library Collections
+Resource ${CURDIR}/../ClusterManagement.robot
+Resource ${CURDIR}/../MdsalLowlevel.robot
+
+*** Variables ***
+${CONSTANT_PREFIX} constant-
+
+*** Keywords ***
+DrbCommons_Init
+ [Documentation] Resouce initial keyword. Creates several suite variables which are
+ ... used in other keywords and should be used im the test suites.
+ ${all_indices} = ClusterManagement.List_All_Indices
+ BuiltIn.Set_Suite_Variable ${all_indices}
+ ${nonregistered_indices} = ClusterManagement.List_All_Indices
+ BuiltIn.Set_Suite_Variable ${nonregistered_indices}
+ ${active_indices} = ClusterManagement.List_All_Indices
+ BuiltIn.Set_Suite_Variable ${active_indices}
+ ${possible_constants} = BuiltIn.Create_List
+ BuiltIn.Set_Suite_Variable ${possible_constants}
+ ${registered_indices} = BuiltIn.Create_List
+ BuiltIn.Set_Suite_Variable ${registered_indices}
+
+Register_Rpc_And_Update_Possible_Constants
+ [Arguments] ${member_index}
+ [Documentation] Register global rpc on given node of the cluster.
+ MdsalLowlevel.Register_Constant ${member_index} ${CONSTANT_PREFIX}${member_index}
+ DrbCommons__Add_Possible_Constant ${member_index}
+ DrbCommons__Register_Index ${member_index}
+
+Unregister_Rpc_And_Update_Possible_Constants
+ [Arguments] ${member_index}
+ [Documentation] Unregister global rpc on given node of the cluster.
+ MdsalLowlevel.Unregister_Constant ${member_index}
+ DrbCommons__Rem_Possible_Constant ${member_index}
+ DrbCommons__Deregister_Index ${member_index}
+
+Register_Rpc_On_Nodes
+ [Arguments] ${index_list}
+ [Documentation] Register global rpc on given nodes of the cluster.
+ : FOR ${index} IN @{index_list}
+ \ Register_Rpc_And_Update_Possible_Constants ${index}
+
+Unregister_Rpc_On_Nodes
+ [Arguments] ${index_list}
+ [Documentation] Unregister global rpc on given nodes of the cluster.
+ : FOR ${index} IN @{index_list}
+ \ Unregister_Rpc_And_Update_Possible_Constants ${index}
+
+Verify_Constant_On_Registered_Node
+ [Arguments] ${member_index}
+ [Documentation] Verify that the rpc response comes from the local node.
+ ${constant} = MdsalLowlevel.Get_Constant ${member_index}
+ BuiltIn.Should_Be_Equal_As_Strings ${CONSTANT_PREFIX}${member_index} ${constant}
+ BuiltIn.Return_From_Keyword ${constant}
+
+Verify_Constant_On_Unregistered_Node
+ [Arguments] ${member_index}
+ [Documentation] Verify that the response comes from other nodes with rpc registered. Verification
+ ... passes for registered nodes too.
+ ${constant} = MdsalLowlevel.Get_Constant ${member_index}
+ Collections.List_Should_Contain_Value ${possible_constants} ${constant}
+ BuiltIn.Return_From_Keyword ${constant}
+
+Verify_Constant_On_Registered_Nodes
+ [Arguments] ${index_list}
+ [Documentation] Verify that the rpc response comes from the local node for every node in the list.
+ : FOR ${index} IN @{index_list}
+ \ Verify_Constant_On_Registered_Node ${index}
+
+Verify_Constant_On_Unregistered_Nodes
+ [Arguments] ${index_list}
+ [Documentation] Verify that the rpc response comes from the remote node for every node in the list.
+ : FOR ${index} IN @{index_list}
+ \ Verify_Constant_On_Unregistered_Node ${index}
+
+Verify_Constant_On_Active_Nodes
+ [Documentation] Verify that the rpc response comes from the local node for every node in the list.
+ : FOR ${index} IN @{active_indices}
+ \ BuiltIn.Run_Keyword_If ${index} in ${registered_indices} Verify_Constant_On_Registered_Node ${index}
+ \ ... ELSE Verify_Constant_On_Unregistered_Node ${index}
+
+Verify_Expected_Constant_On_Nodes
+ [Arguments] ${index_list} ${exp_constant}
+ [Documentation] Verify that the rpc response comes only from one node only for every node in the list.
+ : FOR ${index} IN @{index_list}
+ \ ${const_index} = Get_Constant_Index_From_Node ${index}
+ \ BuiltIn.Should_Be_Equal_As_Strings ${exp_constant} ${CONSTANT_PREFIX}${const_index}
+
+Get_Constant_Index_From_Node
+ [Arguments] ${member_index}
+ [Documentation] Ivoke get-constant rpc on given member index. Returns the index of
+ ... the node where the constant came from.
+ ${constant} = MdsalLowlevel.Get_Constant ${member_index}
+ ${index} = String.Replace_String ${constant} ${CONSTANT_PREFIX} ${EMPTY}
+ ${index} = BuiltIn.Convert_To_Integer ${index}
+ BuiltIn.Return_From_Keyword ${index}
+
+Isolate_Node
+ [Arguments] ${member_index}
+ [Documentation] Isolate a member and update appropriate suite variables.
+ ClusterManagement.Isolate_Member_From_List_Or_All ${member_index}
+ DrbCommons__Upadte_Active_Nodes_List deactivate_idx=${member_index}
+ BuiltIn.Return_From_Keyword_If ${member_index} not in ${registered_indices}
+ DrbCommons__Rem_Possible_Constant ${member_index}
+
+Rejoin_Node
+ [Arguments] ${member_index}
+ [Documentation] Rejoin a member and update appropriate suite variables.
+ ClusterManagement.Rejoin_Member_From_List_Or_All ${member_index}
+ DrbCommons__Upadte_Active_Nodes_List activate_idx=${member_index}
+ BuiltIn.Return_From_Keyword_If ${member_index} not in ${registered_indices}
+ DrbCommons__Add_Possible_Constant ${member_index}
+
+DrbCommons__Upadte_Active_Nodes_List
+ [Arguments] ${activate_idx}=${EMPTY} ${deactivate_idx}=${EMPTY}
+ [Documentation] Add or remove member index to/from the list of active nodes.
+ BuiltIn.Run_Keyword_If "${activate_idx}" != "${EMPTY}" Collections.Append_To_List ${active_indices} ${activate_idx}
+ BuiltIn.Run_Keyword_If "${deactivate_idx}" != "${EMPTY}" Collections.Remove_Values_From_List ${active_indices} ${deactivate_idx}
+ Collections.Sort_List ${active_indices}
+
+DrbCommons__Register_Index
+ [Arguments] ${member_index}
+ [Documentation] Add member index to the list of indices with registered rpc.
+ ... Isolated nodes are included in the list.
+ Collections.Append_To_List ${registered_indices} ${member_index}
+ Collections.Remove_Values_From_List ${nonregistered_indices} ${member_index}
+ Collections.Sort_List ${registered_indices}
+ Collections.Sort_List ${nonregistered_indices}
+
+DrbCommons__Deregister_Index
+ [Arguments] ${member_index}
+ [Documentation] Remove member index from the list of indices with registered rpc.
+ ... Isolated nodes are included in the list.
+ Collections.Remove_Values_From_List ${registered_indices} ${member_index}
+ Collections.Append_To_List ${nonregistered_indices} ${member_index}
+ Collections.Sort_List ${registered_indices}
+ Collections.Sort_List ${nonregistered_indices}
+
+DrbCommons__Add_Possible_Constant
+ [Arguments] ${member_index}
+ [Documentation] Add a constant to the ${possible_constants} list. The list is about to maintain
+ ... all valid constants possibly responded from the odl cluster (excluding isolated nodes).
+ Collections.Append_To_List ${possible_constants} ${CONSTANT_PREFIX}${member_index}
+ Collections.Sort_List ${possible_constants}
+
+DrbCommons__Rem_Possible_Constant
+ [Arguments] ${member_index}
+ [Documentation] Remove a constant from the ${possible_constants} list. The list is about to maintain
+ ... all valid constants possibly responded from the odl cluster (excluding isolated nodes).
+ Collections.Remove_Values_From_List ${possible_constants} ${CONSTANT_PREFIX}${member_index}
Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
Test Teardown SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
Default Tags critical
-Library Collections
Library SSHLibrary
-Resource ${CURDIR}/../../../libraries/MdsalLowlevel.robot
+Resource ${CURDIR}/../../../libraries/controller/DrbCommons.robot
Resource ${CURDIR}/../../../libraries/SetupUtils.robot
-Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot
Resource ${CURDIR}/../../../libraries/WaitForFailure.robot
*** Variables ***
@{INSTALLED_RPC_MEMEBER_IDX_LIST} ${1} ${2}
${TESTED_MEMBER_WITHOUT_RPC_IDX} ${3}
-${CONSTANT_PREFIX} member-
@{NON_WORKING_RPC_STATUS_CODE} ${501}
*** Test Cases ***
Register_Rpc_On_Two_Nodes
[Documentation] Register rpc on two nodes of the odl cluster.
- : FOR ${index} IN @{INSTALLED_RPC_MEMEBER_IDX_LIST}
- \ MdsalLowlevel.Register_Constant ${index} ${CONSTANT_PREFIX}${index}
+ DrbCommons.Register_Rpc_On_Nodes ${INSTALLED_RPC_MEMEBER_IDX_LIST}
Invoke_Rpc_On_Each_Node
[Documentation] Invoke get-constant rpc on every node of the cluster. When requested on the node with
... local instance the local value is expected. If invoked on the node with no local instance, any remote
- ... value is expected. From the constant returned from the ${TESTED_MEMBER_WITHOUT_RPC_IDX} node (with no rpc instance) an index of
- ... the node to be isolated is derived. And in the tc Invoke_Rpc_On_Remaining_Nodes a different constant
- ... is expected. The second for loop makes the suite suitable for more that 3 nodes cluster.
- : FOR ${index} IN @{INSTALLED_RPC_MEMEBER_IDX_LIST}
- \ Verify_Local_Rpc_Invoked ${index}
- : FOR ${index} IN @{non_installed_rpc_member_idx_list}
- \ ${constant} = Verify_Any_Remote_Rpc_Invoked ${index}
- \ BuiltIn.Run_Keyword_If "${index}" == "${TESTED_MEMBER_WITHOUT_RPC_IDX}" BuiltIn.Set_Suite_Variable ${initial_const_on_tested_non_rpc_member} ${constant}
- ${isolated_idx} = String.Replace_String ${initial_const_on_tested_non_rpc_member} ${CONSTANT_PREFIX} ${EMPTY}
- BuiltIn.Set_Suite_Variable ${isolated_idx} ${${isolated_idx}}
+ ... value is expected.
+ DrbCommons.Verify_Constant_On_Active_Nodes
Isolate_One_Node
[Documentation] Isolate one node with registered rpc.
- ClusterManagement.Isolate_Member_From_List_Or_All ${isolated_idx}
+ ... From the constant returned from the ${TESTED_MEMBER_WITHOUT_RPC_IDX} node (with no rpc instance) an index of
+ ... the node to be isolated is derived. And in the tc Invoke_Rpc_On_Remaining_Nodes a different constant
+ ... is expected.
+ ${isolated_idx} = DrbCommons.Get_Constant_Index_From_Node ${TESTED_MEMBER_WITHOUT_RPC_IDX}
+ BuiltIn.Set_Suite_Variable ${isolated_idx}
+ DrbCommons.Isolate_Node ${isolated_idx}
Invoke_Rpc_On_Isolated_Node
[Documentation] Invoke rpc on isolated node. Because rpc is registered on this node, local constant
... is expected.
- BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s Verify_Local_Rpc_Invoked ${isolated_idx}
+ BuiltIn.Wait_Until_Keyword_Succeeds 3x 2s DrbCommons.Verify_Constant_On_Registered_Node ${isolated_idx}
Invoke_Rpc_On_Remaining_Nodes
- [Documentation] Invoke rpc on non-islolated nodes. As the only instance of rpc remained in the non-isolated
- ... cluster nodes, only this value is expected.
- ${index_list} = ClusterManagement.List_Indices_Minus_Member ${isolated_idx} ${all_indices}
- : FOR ${index} IN @{index_list}
- \ ${constant} = Verify_Any_Remote_Rpc_Invoked ${index}
- \ BuiltIn.Should_Not_Be_Equal_As_Strings ${CONSTANT_PREFIX}${isolated_idx} ${constant}
+ [Documentation] Invoke rpc on non-islolated nodes.
+ DrbCommons.Verify_Constant_On_Active_Nodes
Rejoin_Isolated_Member
[Documentation] Rejoin isolated node
- ClusterManagement.Rejoin_Member_From_List_Or_All ${isolated_idx}
+ DrbCommons.Rejoin_Node ${isolated_idx}
Invoke_Rpc_On_Each_Node_Again
[Documentation] Invoke rpc get-constant on every node. When requested on the node with
... local instance the local value is expected. If invoked on the node with no local instance, any remote
... value is expected.
- : FOR ${index} IN @{all_indices}
- \ BuiltIn.Run_Keyword_If ${index} in ${INSTALLED_RPC_MEMEBER_IDX_LIST} Verify_Local_Rpc_Invoked ${index}
- \ BuiltIn.Run_Keyword_Unless ${index} in ${INSTALLED_RPC_MEMEBER_IDX_LIST} WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout 20s 3s Verify_Any_Remote_Rpc_Invoked
- \ ... ${index}
+ WaitForFailure.Verify_Keyword_Does_Not_Fail_Within_Timeout 20s 3s DrbCommons.Verify_Constant_On_Active_Nodes
Isolate_Member_Without_Registered_Rpc
[Documentation] Isolate one node with unregistered rpc.
- ClusterManagement.Isolate_Member_From_List_Or_All ${TESTED_MEMBER_WITHOUT_RPC_IDX}
+ DrbCommons.Isolate_Node ${TESTED_MEMBER_WITHOUT_RPC_IDX}
Verify_Rpc_Fails_On_Isolated_Member_Without_Rpc
[Documentation] Rpc should fail as it is requested on isolated node without rpc instance.
Rejoin_Isolated_Member_Without_Registered_Rpc
[Documentation] Rejoin isolated node.
- ClusterManagement.Rejoin_Member_From_List_Or_All ${TESTED_MEMBER_WITHOUT_RPC_IDX}
+ DrbCommons.Rejoin_Node ${TESTED_MEMBER_WITHOUT_RPC_IDX}
Verify_Rpc_Again_Passes_On_Member_Without_Rpc
[Documentation] Verify rpc works after the node rejoin.
- ${constant} = BuiltIn.Wait_Until_Keyword_Succeeds 10x 3s MdsalLowlevel.Get_Constant ${TESTED_MEMBER_WITHOUT_RPC_IDX}
- Collections.List_Should_Contain_Value ${possible_constants} ${constant}
+ BuiltIn.Wait_Until_Keyword_Succeeds 10x 3s DrbCommons.Verify_Constant_On_Unregistered_Node ${TESTED_MEMBER_WITHOUT_RPC_IDX}
Unregister_Rpc_On_Each_Node
[Documentation] Inregister rpc on both nodes.
- : FOR ${index} IN @{INSTALLED_RPC_MEMEBER_IDX_LIST}
- \ MdsalLowlevel.Unregister_Constant ${index}
+ DrbCommons.Unregister_Rpc_On_Nodes ${INSTALLED_RPC_MEMEBER_IDX_LIST}
*** Keywords ***
Setup_Kw
[Documentation] Setup keyword. Create ${possible_constants} list with possible variables of remote constants.
SetupUtils.Setup_Utils_For_Setup_And_Teardown
- ${all_indices} = ClusterManagement.List_All_Indices
- BuiltIn.Set_Suite_Variable ${all_indices}
- ${non_installed_rpc_member_idx_list} = ClusterManagement.List_All_Indices
- ${possible_constants} = BuiltIn.Create_List
- : FOR ${index} IN @{INSTALLED_RPC_MEMEBER_IDX_LIST}
- \ Collections.Append_To_List ${possible_constants} ${CONSTANT_PREFIX}${index}
- \ ${non_installed_rpc_member_idx_list} = ClusterManagement.List_Indices_Minus_Member ${index} ${non_installed_rpc_member_idx_list}
- BuiltIn.Set_Suite_Variable ${possible_constants}
- BuiltIn.Set_Suite_Variable ${non_installed_rpc_member_idx_list}
-
-Verify_Local_Rpc_Invoked
- [Arguments] ${member_index}
- [Documentation] Verify that local constant is received.
- ${constant} = MdsalLowlevel.Get_Constant ${member_index}
- BuiltIn.Should_Be_Equal_As_Strings ${CONSTANT_PREFIX}${member_index} ${constant}
- BuiltIn.Return_From_Keyword ${constant}
-
-Verify_Any_Remote_Rpc_Invoked
- [Arguments] ${member_index}
- [Documentation] Verify that any valid constant is received.
- ${constant} = MdsalLowlevel.Get_Constant ${member_index}
- Collections.List_Should_Contain_Value ${possible_constants} ${constant}
- BuiltIn.Return_From_Keyword ${constant}
+ DrbCommons.DrbCommons_Init
Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
Test Teardown SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
Default Tags critical
-Library Collections
Library SSHLibrary
-Resource ${CURDIR}/../../../libraries/ClusterManagement.robot
-Resource ${CURDIR}/../../../libraries/MdsalLowlevel.robot
+Resource ${CURDIR}/../../../libraries/controller/DrbCommons.robot
Resource ${CURDIR}/../../../libraries/SetupUtils.robot
-Resource ${CURDIR}/../../../libraries/TemplatedRequests.robot
*** Variables ***
${UNREGISTERED_RPC_NODE} ${1}
-${CONSTANT_PREFIX} constant-
*** Test Cases ***
Register_Rpc_On_Each_Node
[Documentation] Register global rpc on each node of the cluster.
- : FOR ${index} IN @{full_cluster_index_list}
- \ MdsalLowlevel.Register_Constant ${index} ${CONSTANT_PREFIX}${index}
+ DrbCommons.Register_Rpc_On_Nodes ${all_indices}
Invoke_Rpc_On_Each_Node
[Documentation] Verify that the rpc response comes from the local node.
- : FOR ${index} IN @{full_cluster_index_list}
- \ ${constant} = MdsalLowlevel.Get_Constant ${index}
- \ BuiltIn.Should_Be_Equal_As_Strings ${CONSTANT_PREFIX}${index} ${constant}
+ DrbCommons.Verify_Constant_On_Registered_Nodes ${all_indices}
Unregister_Rpc_On_Node
[Documentation] Unregister the rpc on one of the cluster nodes.
- MdsalLowlevel.Unregister_Constant ${UNREGISTERED_RPC_NODE}
+ DrbCommons.Unregister_Rpc_And_Update_Possible_Constants ${UNREGISTERED_RPC_NODE}
Invoke_Rpc_On_Node_With_Unregistered_Rpc
[Documentation] Invoke rcp on the node with unregistered rpc. The response is expected
... to come from other nodes where the rpc remained registered.
- ${constant} = MdsalLowlevel.Get_Constant ${UNREGISTERED_RPC_NODE}
- Collections.List_Should_Contain_Value ${allowed_values} ${constant}
+ DrbCommons.Verify_Constant_On_Unregistered_Node ${UNREGISTERED_RPC_NODE}
Invoke_Rpc_On_Remaining_Nodes
[Documentation] Verify that the rpc response comes from the local node.
- : FOR ${index} IN @{allowed_index_list}
- \ ${constant} = MdsalLowlevel.Get_Constant ${index}
- \ BuiltIn.Should_Be_Equal_As_Strings ${CONSTANT_PREFIX}${index} ${constant}
+ DrbCommons.Verify_Constant_On_Registered_Nodes ${registered_indices}
Reregister_Rpc_On_Node
[Documentation] Reregister the rpc.
- MdsalLowlevel.Register_Constant ${UNREGISTERED_RPC_NODE} ${CONSTANT_PREFIX}${UNREGISTERED_RPC_NODE}
+ DrbCommons.Register_Rpc_And_Update_Possible_Constants ${UNREGISTERED_RPC_NODE}
Invoke_Rpc_On_Each_Node_Again
[Documentation] Verify that the rpc response comes from the local node.
- : FOR ${index} IN @{full_cluster_index_list}
- \ ${constant} = MdsalLowlevel.Get_Constant ${index}
- \ BuiltIn.Should_Be_Equal_As_Strings ${CONSTANT_PREFIX}${index} ${constant}
+ DrbCommons.Verify_Constant_On_Registered_Nodes ${all_indices}
Unregister_Rpc_On_Each_Node
[Documentation] Unregister rpc on every node.
- : FOR ${index} IN @{full_cluster_index_list}
- \ MdsalLowlevel.Unregister_Constant ${index}
+ DrbCommons.Unregister_Rpc_On_Nodes ${all_indices}
*** Keywords ***
Setup_Keyword
[Documentation] Create a list of possible constant responses on the node with unregistered rpc.
SetupUtils.Setup_Utils_For_Setup_And_Teardown
- ${full_cluster_index_list} = ClusterManagement.List_All_Indices
- BuiltIn.Set_Suite_Variable ${full_cluster_index_list}
- ${allowed_values} = BuiltIn.Create_List
- ${allowed_index_list} = ClusterManagement.List_Indices_Minus_Member ${UNREGISTERED_RPC_NODE} ${full_cluster_index_list}
- : FOR ${index} IN @{allowed_index_list}
- \ Collections.Append_To_List ${allowed_values} ${CONSTANT_PREFIX}${index}
- BuiltIn.Set_Suite_Variable ${allowed_index_list}
- BuiltIn.Set_Suite_Variable ${allowed_values}
+ DrbCommons.DrbCommons_Init