Refactor action proveder suites 15/57915/4
authorPeter Gubka <pgubka@cisco.com>
Fri, 26 May 2017 15:48:37 +0000 (17:48 +0200)
committerVratko Polák <vrpolak@cisco.com>
Fri, 26 May 2017 19:48:55 +0000 (19:48 +0000)
Change-Id: I739f121c4a9bded6bc52b0152dd5fa09bde5b856
Signed-off-by: Peter Gubka <pgubka@cisco.com>
csit/libraries/controller/DrbCommons.robot
csit/suites/controller/dom_rpc_broker/action_provider_partition_and_heal.robot
csit/suites/controller/dom_rpc_broker/action_provider_precedence.robot

index 9fbcd4ed30e00057c854a0448fa9a81f7a849da2..54dedd0f73f9ac58e31728f4993fcdef09658106 100644 (file)
@@ -27,6 +27,7 @@ Resource          ${CURDIR}/../ShardStability.robot
 
 *** Variables ***
 ${CONSTANT_PREFIX}    constant-
+${CONTEXT}        context
 
 *** Keywords ***
 DrbCommons_Init
@@ -57,6 +58,20 @@ Unregister_Rpc_And_Update_Possible_Constants
     DrbCommons__Rem_Possible_Constant    ${member_index}
     DrbCommons__Deregister_Index    ${member_index}
 
+Register_Action_And_Update_Possible_Constants
+    [Arguments]    ${member_index}
+    [Documentation]    Register routed rpc on given node of the cluster.
+    MdsalLowlevel.Register_Bound_Constant    ${member_index}    ${CONTEXT}    ${CONSTANT_PREFIX}${member_index}
+    DrbCommons__Add_Possible_Constant    ${member_index}
+    DrbCommons__Register_Index    ${member_index}
+
+Unregister_Action_And_Update_Possible_Constants
+    [Arguments]    ${member_index}
+    [Documentation]    Unregister routed rpc on given node of the cluster.
+    MdsalLowlevel.Unregister_Bound_Constant    ${member_index}    ${CONTEXT}
+    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.
@@ -69,6 +84,18 @@ Unregister_Rpc_On_Nodes
     : FOR    ${index}    IN    @{index_list}
     \    Unregister_Rpc_And_Update_Possible_Constants    ${index}
 
+Register_Action_On_Nodes
+    [Arguments]    ${index_list}
+    [Documentation]    Register global rpc on given nodes of the cluster.
+    : FOR    ${index}    IN    @{index_list}
+    \    Register_Action_And_Update_Possible_Constants    ${index}
+
+Unregister_Action_On_Nodes
+    [Arguments]    ${index_list}
+    [Documentation]    Unregister global rpc on given nodes of the cluster.
+    : FOR    ${index}    IN    @{index_list}
+    \    Unregister_Action_And_Update_Possible_Constants    ${index}
+
 Verify_Constant_On_Registered_Node
     [Arguments]    ${member_index}
     [Documentation]    Verify that the rpc response comes from the local node.
@@ -84,12 +111,33 @@ Verify_Constant_On_Unregistered_Node
     Collections.List_Should_Contain_Value    ${possible_constants}    ${constant}
     BuiltIn.Return_From_Keyword    ${constant}
 
+Verify_Contexted_Constant_On_Registered_Node
+    [Arguments]    ${member_index}
+    [Documentation]    Verify that the rpc response comes from the local node.
+    ${constant} =    MdsalLowlevel.Get_Contexted_Constant    ${member_index}    ${CONTEXT}
+    BuiltIn.Should_Be_Equal_As_Strings    ${CONSTANT_PREFIX}${member_index}    ${constant}
+    BuiltIn.Return_From_Keyword    ${constant}
+
+Verify_Contexted_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_Contexted_Constant    ${member_index}    ${CONTEXT}
+    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_Contexted_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_Contexted_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.
@@ -102,6 +150,12 @@ Verify_Constant_On_Active_Nodes
     \    BuiltIn.Run_Keyword_If    ${index} in ${registered_indices}    Verify_Constant_On_Registered_Node    ${index}
     \    ...    ELSE    Verify_Constant_On_Unregistered_Node    ${index}
 
+Verify_Contexted_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_Contexted_Constant_On_Registered_Node    ${index}
+    \    ...    ELSE    Verify_Contexted_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.
@@ -118,6 +172,15 @@ Get_Constant_Index_From_Node
     ${index} =    BuiltIn.Convert_To_Integer    ${index}
     BuiltIn.Return_From_Keyword    ${index}
 
+Get_Contexted_Constant_Index_From_Node
+    [Arguments]    ${member_index}
+    [Documentation]    Ivoke get-contexted-constant rpc on given member index. Returns the index of
+    ...    the node where the constant came from.
+    ${constant} =    MdsalLowlevel.Get_Contexted_Constant    ${member_index}    ${CONTEXT}
+    ${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.
index 908087c71fb47c392e166253a18ce1e6329193c8..fa243092d4eaeae22b5f2dac48dd6aaaed38fd4a 100644 (file)
@@ -15,25 +15,19 @@ Suite Teardown    SSHLibrary.Close_All_Connections
 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
 Resource          ${CURDIR}/../../../libraries/WaitForFailure.robot
 
 *** Variables ***
 @{INSTALLED_RPC_MEMEBER_IDX_LIST}    ${1}    ${2}
 ${TESTED_MEMBER_WITHOUT_RPC_IDX}    ${3}
-${CONSTANT_PREFIX}    member-
-${CONTEXT}        context
 
 *** 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_Bound_Constant    ${index}    ${CONTEXT}    ${CONSTANT_PREFIX}${index}
+    DrbCommons.Register_Action_On_Nodes    ${INSTALLED_RPC_MEMEBER_IDX_LIST}
 
 Invoke_Rpc_On_Each_Node
     [Documentation]    Invoke get-contexted-constant rpc on every node of the cluster. When requested on the node with
@@ -41,68 +35,35 @@ Invoke_Rpc_On_Each_Node
     ...    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}}
+    DrbCommons.Verify_Contexted_Constant_On_Active_Nodes
 
 Isolate_One_Node
     [Documentation]    Isolate one node with registered rpc.
-    ClusterManagement.Isolate_Member_From_List_Or_All    ${isolated_idx}
+    ${isolated_idx} =    DrbCommons.Get_Contexted_Constant_Index_From_Node    ${TESTED_MEMBER_WITHOUT_RPC_IDX}
+    BuiltIn.Set_Suite_Variable    ${isolated_idx}
+    DrbCommons.Isolate_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} =    BuiltIn.Wait_Until_Keyword_Succeeds    60s    5s    Verify_Any_Remote_Rpc_Invoked    ${index}
-    \    BuiltIn.Should_Not_Be_Equal_As_Strings    ${CONSTANT_PREFIX}${isolated_idx}    ${constant}
+    BuiltIn.Wait_Until_Keyword_Succeeds    60s    5s    DrbCommons.Verify_Contexted_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-contexted-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_Contexted_Constant_On_Active_Nodes
 
 Unregister_Rpc_On_Each_Node
     [Documentation]    Inregister rpc on both nodes.
-    : FOR    ${index}    IN    @{INSTALLED_RPC_MEMEBER_IDX_LIST}
-    \    MdsalLowlevel.Unregister_Bound_Constant    ${index}    ${CONTEXT}
+    DrbCommons.Unregister_Action_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    http_timeout=30
-    ${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_Contexted_Constant    ${member_index}    ${CONTEXT}
-    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_Contexted_Constant    ${member_index}    ${CONTEXT}
-    Collections.List_Should_Contain_Value    ${possible_constants}    ${constant}
-    BuiltIn.Return_From_Keyword    ${constant}
+    DrbCommons.DrbCommons_Init
index 7fab9bb6627f0f0dcf5c3750da18ea6c61df2268..ebeae20dfcd726c3a09480257f299ad4d7b4d141 100644 (file)
@@ -15,70 +15,49 @@ Suite Teardown    SSHLibrary.Close_All_Connections
 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}
-${CONTEXT}        context
-${CONSTANT_PREFIX}    constant-
 
 *** Test Cases ***
 Register_Rpc_On_Each_Node
     [Documentation]    Register routed rpc on each node of the cluster.
-    : FOR    ${index}    IN    @{full_cluster_index_list}
-    \    MdsalLowlevel.Register_Bound_Constant    ${index}    ${CONTEXT}    ${CONSTANT_PREFIX}${index}
+    DrbCommons.Register_Action_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_Contexted_Constant    ${index}    ${CONTEXT}
-    \    BuiltIn.Should_Be_Equal_As_Strings    ${CONSTANT_PREFIX}${index}    ${constant}
+    DrbCommons.Verify_Contexted_Constant_On_Registered_Nodes    ${all_indices}
 
 Unregister_Rpc_On_Node
     [Documentation]    Unregister the rpc on one of the cluster nodes.
-    MdsalLowlevel.Unregister_Bound_Constant    ${UNREGISTERED_RPC_NODE}    ${CONTEXT}
+    DrbCommons.Unregister_Action_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_Contexted_Constant    ${UNREGISTERED_RPC_NODE}    ${CONTEXT}
-    Collections.List_Should_Contain_Value    ${allowed_values}    ${constant}
+    DrbCommons.Verify_Contexted_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_Contexted_Constant    ${index}    ${CONTEXT}
-    \    BuiltIn.Should_Be_Equal_As_Strings    ${CONSTANT_PREFIX}${index}    ${constant}
+    DrbCommons.Verify_Contexted_Constant_On_Registered_Nodes    ${registered_indices}
 
 Reregister_Rpc_On_Node
     [Documentation]    Reregister the rpc.
-    MdsalLowlevel.Register_Bound_Constant    ${UNREGISTERED_RPC_NODE}    ${CONTEXT}    ${CONSTANT_PREFIX}${UNREGISTERED_RPC_NODE}
+    DrbCommons.Register_Action_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_Contexted_Constant    ${index}    ${CONTEXT}
-    \    BuiltIn.Should_Be_Equal_As_Strings    ${CONSTANT_PREFIX}${index}    ${constant}
+    DrbCommons.Verify_Contexted_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_Bound_Constant    ${index}    ${CONTEXT}
+    DrbCommons.Unregister_Action_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    http_timeout=30
-    ${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