2 Documentation DOMDataBroker testing: Module based shards sanity suite
4 ... Copyright (c) 2017 Cisco Systems, Inc. and others. All rights reserved.
6 ... This program and the accompanying materials are made available under the
7 ... terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 ... and is available at http://www.eclipse.org/legal/epl-v10.html
10 ... The goal is to call several basic rpc form ClusterAdmin.robot and
11 ... MdsalLowlevel.robot to ensute that those rpcs can be safely used in
13 ... It also verify the ability of the odl-controller-test-app to perform
14 ... several activities.
15 Suite Setup SetupUtils.Setup_Utils_For_Setup_And_Teardown http_timeout=30
16 Suite Teardown SSHLibrary.Close_All_Connections
17 Test Setup SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
18 Test Teardown SetupUtils.Teardown_Test_Show_Bugs_If_Test_Failed
21 Library ${CURDIR}/../../../libraries/MdsalLowlevelPy.py
22 Resource ${CURDIR}/../../../libraries/ClusterAdmin.robot
23 Resource ${CURDIR}/../../../libraries/ClusterManagement.robot
24 Resource ${CURDIR}/../../../libraries/controller/DdbCommons.robot
25 Resource ${CURDIR}/../../../libraries/SetupUtils.robot
30 ${TRANSACTION_RATE_1K} ${1000}
34 ${MODULE_SHARD_PREFIX} prefix-
38 [Documentation] Get shard role.
39 ${all_indices} = ClusterManagement.List_All_Indices
40 : FOR ${index} IN @{all_indices}
41 \ ${role} = ClusterAdmin.Get_Shard_Role ${index} ${SHARD_NAME} ${SHARD_TYPE}
43 Write_Transactions_One_Node_Leader
44 [Documentation] Write transactions.
45 ${all_indices} = ClusterManagement.List_All_Indices
46 ${leader} ${follower_list} = ClusterManagement.Get_Leader_And_Followers_For_Shard shard_name=${SHARD_NAME} shard_type=${SHARD_TYPE} member_index_list=${all_indices} verify_restconf=False
47 ${leader_idx_as_list} = BuiltIn.Create_List ${leader}
48 ${leader_ip_as_list} = ClusterManagement.Resolve_IP_Address_For_Members ${leader_idx_as_list}
49 MdsalLowlevelPy.Start_Write_Transactions_On_Nodes ${leader_ip_as_list} ${leader_idx_as_list} ${MODULE_SHARD_PREFIX} ${DURATION} ${TRANSACTION_RATE_1K} chained_flag=${CHAINED_TX}
50 ${resp_list} = MdsalLowlevelPy.Wait_For_Transactions
51 : FOR ${resp} IN @{resp_list}
52 \ TemplatedRequests.Check_Status_Code ${resp}
54 Write_Transactions_One_Node_Follower
55 [Documentation] Write transactions.
56 ${all_indices} = ClusterManagement.List_All_Indices
57 ${leader} ${follower_list} = ClusterManagement.Get_Leader_And_Followers_For_Shard shard_name=${SHARD_NAME} shard_type=${SHARD_TYPE} member_index_list=${all_indices} verify_restconf=False
58 ${follower_idx} = Collections.Get_From_List ${follower_list} ${0}
59 ${follower_idx_as_list} = BuiltIn.Create_List ${follower_idx}
60 ${follower_ip_as_list} = ClusterManagement.Resolve_IP_Address_For_Members ${follower_idx_as_list}
61 MdsalLowlevelPy.Start_Write_Transactions_On_Nodes ${follower_ip_as_list} ${follower_idx_as_list} ${MODULE_SHARD_PREFIX} ${DURATION} ${TRANSACTION_RATE_1K} chained_flag=${CHAINED_TX}
62 ${resp_list} = MdsalLowlevelPy.Wait_For_Transactions
63 : FOR ${resp} IN @{resp_list}
64 \ TemplatedRequests.Check_Status_Code ${resp}
67 [Documentation] Make the loeader local and verify.
68 ${shard_name} = BuiltIn.Set_Variable ${SHARD_NAME}
69 ${shard_type} = BuiltIn.Set_Variable ${SHARD_TYPE}
70 ${all_indices} = ClusterManagement.List_All_Indices
71 ${old_leader} ${follower_list} = ClusterManagement.Get_Leader_And_Followers_For_Shard shard_name=${SHARD_NAME} shard_type=${SHARD_TYPE} member_index_list=${all_indices} verify_restconf=False
72 ${follower1} = Collections.Get_From_List ${follower_list} ${0}
73 ClusterAdmin.Make_Leader_Local ${follower1} ${shard_name} ${shard_type}
74 ${leader} ${follower_list} = BuiltIn.Wait_Until_Keyword_Succeeds 30s 3s ClusterManagement.Verify_Shard_Leader_Elected ${shard_name}
75 ... ${shard_type} ${True} ${old_leader} member_index_list=${EMPTY}
76 BuiltIn.Should_Be_Equal_As_Numbers ${follower1} ${leader}
78 Remove_Leader_Shard_Replica_And_Add_It_Back
79 [Documentation] Remove and add shard replica adn verify it.
80 ${shard_name} = BuiltIn.Set_Variable ${SHARD_NAME}
81 ${shard_type} = BuiltIn.Set_Variable ${SHARD_TYPE}
82 ${all_indices} = ClusterManagement.List_All_Indices
83 ${old_leader} ${follower_list} = ClusterManagement.Get_Leader_And_Followers_For_Shard shard_name=${shard_name} shard_type=${shard_type} member_index_list=${all_indices} verify_restconf=False
84 ClusterAdmin.Remove_Shard_Replica ${old_leader} ${shard_name} member-${old_leader} ${shard_type}
85 BuiltIn.Wait_Until_Keyword_Succeeds 60s 3s DdbCommons.Verify_Shard_Replica_Removed ${old_leader} ${shard_name} ${shard_type}
86 ${actual_leader} ${actual_follower_list} = BuiltIn.Wait_Until_Keyword_Succeeds 60s 3s ClusterManagement.Get_Leader_And_Followers_For_Shard shard_name=${shard_name}
87 ... verify_restconf=False shard_type=${shard_type} member_index_list=${follower_list}
88 BuiltIn.Should_Not_Be_Equal_As_Numbers ${old_leader} ${actual_leader}
89 ClusterAdmin.Add_Shard_Replica ${old_leader} ${shard_name} ${shard_type}
90 BuiltIn.Wait_Until_Keyword_Succeeds 60s 3s ClusterManagement.Get_Leader_And_Followers_For_Shard shard_name=${shard_name} shard_type=${shard_type} member_index_list=${all_indices}
91 ... verify_restconf=False
93 Remove_Follower_Shard_Replica_And_Add_It_Back
94 [Documentation] Remove and add shard replica adn verify it.
95 ${shard_name} = BuiltIn.Set_Variable ${SHARD_NAME}
96 ${shard_type} = BuiltIn.Set_Variable ${SHARD_TYPE}
97 ${all_indices} = ClusterManagement.List_All_Indices
98 ${leader} ${follower_list} = ClusterManagement.Get_Leader_And_Followers_For_Shard shard_name=${shard_name} shard_type=${shard_type} member_index_list=${all_indices} verify_restconf=False
99 ${follower1} = Collections.Get_From_List ${follower_list} ${0}
100 ClusterAdmin.Remove_Shard_Replica ${follower1} ${shard_name} member-${follower1} ${shard_type}
101 BuiltIn.Wait_Until_Keyword_Succeeds 60s 3s DdbCommons.Verify_Shard_Replica_Removed ${follower1} ${shard_name} ${shard_type}
102 ${new_indices_list} = ClusterManagement.List_Indices_Minus_Member ${follower1}
103 ClusterManagement.Verify_Shard_Leader_Elected ${shard_name} ${shard_type} ${False} ${leader} member_index_list=${new_indices_list}
104 ClusterAdmin.Add_Shard_Replica ${follower1} ${shard_name} ${shard_type}
105 BuiltIn.Wait_Until_Keyword_Succeeds 60s 3s ClusterManagement.Get_Leader_And_Followers_For_Shard shard_name=${shard_name} shard_type=${shard_type} member_index_list=${all_indices}
106 ... verify_restconf=False
108 Write_Transactions_All_Nodes
109 [Documentation] Write transactions.
110 ${all_indices} = ClusterManagement.List_All_Indices
111 ${all_ip_list} = ClusterManagement.Resolve_IP_Address_For_Members ${all_indices}
112 MdsalLowlevelPy.Start_Write_Transactions_On_Nodes ${all_ip_list} ${all_indices} ${MODULE_SHARD_PREFIX} ${DURATION} ${TRANSACTION_RATE_1K} chained_flag=${CHAINED_TX}
113 ${resp_list} = MdsalLowlevelPy.Wait_For_Transactions
114 : FOR ${resp} IN @{resp_list}
115 \ TemplatedRequests.Check_Status_Code ${resp}
117 Subscribe_Listener_To_Leader
118 [Documentation] Subscribe listener to leader.
119 ${all_indices} = ClusterManagement.List_All_Indices
120 ${leader} ${follower_list} = ClusterManagement.Get_Leader_And_Followers_For_Shard shard_name=${SHARD_NAME} shard_type=${SHARD_TYPE} member_index_list=${all_indices} verify_restconf=False
121 MdsalLowlevel.Subscribe_Dtcl ${leader}
123 ${copy_matches} = MdsalLowlevel.Unsubscribe_Dtcl ${leader}
124 BuiltIn.Should_Be_True ${copy_matches}
126 Subscribe_Listener_To_Follower
127 [Documentation] Subscribe listener to follower.
128 ${all_indices} = ClusterManagement.List_All_Indices
129 ${leader} ${follower_list} = ClusterManagement.Get_Leader_And_Followers_For_Shard shard_name=${SHARD_NAME} shard_type=${SHARD_TYPE} member_index_list=${all_indices} verify_restconf=False
130 ${follower_idx} = Collections.Get_From_List ${follower_list} ${0}
131 MdsalLowlevel.Subscribe_Dtcl ${follower_idx}
133 ${copy_matches} = MdsalLowlevel.Unsubscribe_Dtcl ${follower_idx}
134 BuiltIn.Should_Be_True ${copy_matches}