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 entity-ownership: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}=${EMPTY}
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 CompareStream.Run_Keyword_If_At_Least_Phosphorus Collections.Remove_Values_From_List ${shard_list} entity-ownership:operational
40 FOR ${shard_details} IN @{shard_list}
41 ${shard_name} ${shard_type} String.Split_String ${shard_details} separator=:
42 ${leader} ${followers} ClusterManagement.Get_Leader_And_Followers_For_Shard shard_name=${shard_name} shard_type=${shard_type} member_index_list=${member_index_list}
43 ... verify_restconf=${verify_restconf} http_timeout=${http_timeout}
44 Collections.Sort_List ${followers}
45 Collections.Set_To_Dictionary ${shards_details} ${shard_name}_${shard_type}_leader=${leader}
46 Collections.Set_To_Dictionary ${shards_details} ${shard_name}_${shard_type}_followers=${followers}
48 BuiltIn.Return_From_Keyword ${shards_details}
50 Shards_Stability_Verify
51 [Arguments] ${shard_list} ${member_index_list}=${EMPTY}
52 [Documentation] Verify that present details as the same as the stored one from Shards_Stability_Init_Details
53 ${present_details} = Shards_Stability_Get_Details ${shard_list} member_index_list=${member_index_list}
54 Shards_Stability_Compare_Same ${present_details}
56 Shards_Stability_Compare_Same
57 [Arguments] ${details} ${stateless_details}=${EMPTY}
58 [Documentation] Compare two distionaries created by Shards_Stability_Get_Details
59 ${exp_details} = BuiltIn.Set_Variable_If "${stateless_details}" == "${EMPTY}" ${stored_details} ${stateless_details}
60 Collections.Log_Dictionary ${exp_details}
61 Collections.Log_Dictionary ${details}
62 Collections.Dictionaries_Should_Be_Equal ${exp_details} ${details}
65 [Arguments] ${requested_leader_idx}
66 [Documentation] Move default/topology config/operational shard location to local or remote node as requested
67 ... towards the given member.
68 ClusterAdmin.Make_Leader_Local ${requested_leader_idx} default config
69 ClusterAdmin.Make_Leader_Local ${requested_leader_idx} default operational
70 ClusterAdmin.Make_Leader_Local ${requested_leader_idx} topology config
71 ClusterAdmin.Make_Leader_Local ${requested_leader_idx} topology operational
73 Verify_Shard_Leader_Located_As_Expected
74 [Arguments] ${expected_leader_idx} ${http_timeout}=${EMPTY}
75 [Documentation] Verify default/topology config/operational shard leader location is as expected
76 ${leader} ${follower_list} = ClusterManagement.Get_Leader_And_Followers_For_Shard shard_name=default shard_type=config verify_restconf=False http_timeout=${http_timeout}
77 BuiltIn.Should_Be_Equal_As_Numbers ${expected_leader_idx} ${leader}
78 ${leader} ${follower_list} = ClusterManagement.Get_Leader_And_Followers_For_Shard shard_name=default shard_type=operational verify_restconf=False http_timeout=${http_timeout}
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=config verify_restconf=False http_timeout=${http_timeout}
81 BuiltIn.Should_Be_Equal_As_Numbers ${expected_leader_idx} ${leader}
82 ${leader} ${follower_list} = ClusterManagement.Get_Leader_And_Followers_For_Shard shard_name=topology shard_type=operational verify_restconf=False http_timeout=${http_timeout}
83 BuiltIn.Should_Be_Equal_As_Numbers ${expected_leader_idx} ${leader}