2 Documentation Robot library to monitor shard stability.
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 ... This is a "stateful" library to monitor shard leaders and candidates. During the initial phase
11 ... all leaders and followeres are stored and then checked with new value on verify.
12 ... TODO: investigate whether pure stateless library would be easier or harder to use.
14 ... Requirements: ClusterManagement.ClusterManagement_Setup must be called before Shard_Stability_Init
16 ... It is possible to use it for stateless comparison.
17 ... Variable @{DEFAULT_SHARD_LIST} contains default module shards.
20 Resource ${CURDIR}/ClusterManagement.robot
24 @{DEFAULT_SHARD_LIST} default:config default:operational topology:config topology:operational inventory:config inventory:operational
27 Shards_Stability_Init_Details
28 [Arguments] ${shard_list} ${member_index_list}=${EMPTY}
29 [Documentation] Initialize data for given shards.
30 ... ${shard_list} should be initialized as @{list} shard_name1:shard_type1 shard_name2:shard..
31 ${shards_details} = Shards_Stability_Get_Details ${shard_list} member_index_list=${member_index_list}
32 BuiltIn.Set_Suite_Variable ${stored_details} ${shards_details}
34 Shards_Stability_Get_Details
35 [Arguments] ${shard_list} ${member_index_list}=${EMPTY} ${verify_restconf}=False ${http_timeout}=5
36 [Documentation] Return shard details stored in dictionary.
37 ... ${shard_list} should be initialized as @{list} shard_name1:shard_type1 shard_name2:shard..
38 &{shards_details} BuiltIn.Create_Dictionary
39 : FOR ${shard_details} IN @{shard_list}
40 \ ${shard_name} ${shard_type} String.Split_String ${shard_details} separator=:
41 \ ${leader} ${followers} ClusterManagement.Get_Leader_And_Followers_For_Shard shard_name=${shard_name} shard_type=${shard_type} member_index_list=${member_index_list}
42 \ ... verify_restconf=${verify_restconf} http_timeout=${http_timeout}
43 \ Collections.Sort_List ${followers}
44 \ Collections.Set_To_Dictionary ${shards_details} ${shard_name}_${shard_type}_leader=${leader}
45 \ Collections.Set_To_Dictionary ${shards_details} ${shard_name}_${shard_type}_followers=${followers}
46 BuiltIn.Return_From_Keyword ${shards_details}
48 Shards_Stability_Verify
49 [Arguments] ${shard_list} ${member_index_list}=${EMPTY}
50 [Documentation] Verify that present details as the same as the stored one from Shards_Stability_Init_Details
51 ${present_details} = Shards_Stability_Get_Details ${shard_list} member_index_list=${member_index_list}
52 Shards_Stability_Compare_Same ${present_details}
54 Shards_Stability_Compare_Same
55 [Arguments] ${details} ${stateless_details}=${EMPTY}
56 [Documentation] Compare two distionaries created by Shards_Stability_Get_Details
57 ${exp_details} = BuiltIn.Set_Variable_If "${stateless_details}" == "${EMPTY}" ${stored_details} ${stateless_details}
58 Collections.Log_Dictionary ${exp_details}
59 Collections.Log_Dictionary ${details}
60 Collections.Dictionaries_Should_Be_Equal ${exp_details} ${details}
63 [Arguments] ${requested_leader_idx}
64 [Documentation] Move default/topology config/operational shard location to local or remote node as requested
65 ... towards the given member.
66 ClusterAdmin.Make_Leader_Local ${requested_leader_idx} default config
67 ClusterAdmin.Make_Leader_Local ${requested_leader_idx} default operational
68 ClusterAdmin.Make_Leader_Local ${requested_leader_idx} topology config
69 ClusterAdmin.Make_Leader_Local ${requested_leader_idx} topology operational
71 Verify_Shard_Leader_Located_As_Expected
72 [Arguments] ${expected_leader_idx}
73 [Documentation] Verify default/topology config/operational shard leader location is as expected
74 ${leader} ${follower_list} = ClusterManagement.Get_Leader_And_Followers_For_Shard shard_name=default shard_type=config verify_restconf=False
75 BuiltIn.Should_Be_Equal_As_Numbers ${expected_leader_idx} ${leader}
76 ${leader} ${follower_list} = ClusterManagement.Get_Leader_And_Followers_For_Shard shard_name=default shard_type=operational verify_restconf=False
77 BuiltIn.Should_Be_Equal_As_Numbers ${expected_leader_idx} ${leader}
78 ${leader} ${follower_list} = ClusterManagement.Get_Leader_And_Followers_For_Shard shard_name=topology shard_type=config verify_restconf=False
79 BuiltIn.Should_Be_Equal_As_Numbers ${expected_leader_idx} ${leader}
80 ${leader} ${follower_list} = ClusterManagement.Get_Leader_And_Followers_For_Shard shard_name=topology shard_type=operational verify_restconf=False
81 BuiltIn.Should_Be_Equal_As_Numbers ${expected_leader_idx} ${leader}