Update Robot Framework format - step 5
[integration/test.git] / csit / suites / controller / Clustering_Datastore / car_failover_crud_isolation.robot
1 *** Settings ***
2 Documentation       Suite mixing basic operations with isolation of car Leader.
3 ...
4 ...                 Copyright (c) 2017 Cisco Systems, Inc. and others. All rights reserved.
5 ...
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
9 ...
10 ...
11 ...                 This test isolates the current leader of the "car" shard and then executes CRD
12 ...                 operations on the new leader and a new follower. The isolated member is brought back.
13 ...                 This suite uses 3 different car sets, same size but different starting ID.
14 ...
15 ...                 Other models and shards (people, car-people) are not accessed by this suite.
16 ...
17 ...                 All data is deleted at the end of the suite.
18 ...                 This suite expects car module to have a separate Shard.
19
20 Library             Collections
21 Resource            ${CURDIR}/../../../libraries/CarPeople.robot
22 Resource            ${CURDIR}/../../../libraries/ClusterManagement.robot
23 Resource            ${CURDIR}/../../../libraries/SetupUtils.robot
24 Resource            ${CURDIR}/../../../libraries/TemplatedRequests.robot
25 Variables           ${CURDIR}/../../../variables/Variables.py
26
27 Suite Setup         Setup
28 Test Setup          SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
29
30 Default Tags        clustering    carpeople    critical
31
32
33 *** Variables ***
34 ${CAR_ITEMS}                    30
35 ${FOLLOWER_2NODE_START_I}       300
36 ${LEADER_2NODE_START_I}         200
37 ${MEMBER_START_TIMEOUT}         300s
38 ${ORIGINAL_START_I}             100
39 ${SHARD_TYPE}                   config
40 ${SHARD_NAME}                   car
41 @{SHARD_NAME_LIST}              ${SHARD_NAME}
42 ${VAR_DIR}                      ${CURDIR}/../../../variables/carpeople/crud
43
44
45 *** Test Cases ***
46 Add_Original_Cars_On_Old_Leader_And_Verify
47     [Documentation]    Add initial cars on car Leader.
48     TemplatedRequests.Put_As_Json_Templated
49     ...    folder=${VAR_DIR}/cars
50     ...    session=${car_leader_session}
51     ...    iterations=${CAR_ITEMS}
52     ...    iter_start=${ORIGINAL_START_I}
53     FOR    ${session}    IN    @{ClusterManagement__session_list}
54         BuiltIn.Wait_Until_Keyword_Succeeds
55         ...    10s
56         ...    2s
57         ...    TemplatedRequests.Get_As_Json_Templated
58         ...    folder=${VAR_DIR}/cars
59         ...    session=${session}
60         ...    verify=True
61         ...    iterations=${CAR_ITEMS}
62         ...    iter_start=${ORIGINAL_START_I}
63     END
64
65 Isolate_Original_Car_Leader
66     [Documentation]    Isolate the car Leader to cause a new leader to get elected.
67     ClusterManagement.Isolate_Member_From_List_Or_All    ${car_leader_index}
68
69 Wait_For_New_Leader
70     [Documentation]    Wait until new car Leader is elected.
71     BuiltIn.Wait_Until_Keyword_Succeeds
72     ...    30s
73     ...    2s
74     ...    ClusterManagement.Verify_Shard_Leader_Elected
75     ...    ${SHARD_NAME}
76     ...    ${SHARD_TYPE}
77     ...    ${True}
78     ...    ${car_leader_index}
79     ...    member_index_list=${car_follower_indices}
80     CarPeople.Set_Tmp_Variables_For_Shard_For_Nodes
81     ...    member_index_list=${car_follower_indices}
82     ...    shard_name=${SHARD_NAME}
83     ...    shard_type=${SHARD_TYPE}
84
85 See_Original_Cars_On_New_Leader
86     [Documentation]    GET cars from new Leader, should be the initial ones.
87     TemplatedRequests.Get_As_Json_Templated
88     ...    folder=${VAR_DIR}/cars
89     ...    session=${new_leader_session}
90     ...    verify=True
91     ...    iterations=${CAR_ITEMS}
92     ...    iter_start=${ORIGINAL_START_I}
93
94 See_Original_Cars_On_New_Followers
95     [Documentation]    The same check on other existing member(s).
96     FOR    ${session}    IN    @{new_follower_sessions}
97         TemplatedRequests.Get_As_Json_Templated
98         ...    folder=${VAR_DIR}/cars
99         ...    session=${session}
100         ...    verify=True
101         ...    iterations=${CAR_ITEMS}
102         ...    iter_start=${ORIGINAL_START_I}
103     END
104
105 Delete_Original_Cars_On_New_Leader
106     [Documentation]    Delete cars on the new Leader.
107     TemplatedRequests.Delete_Templated    folder=${VAR_DIR}/cars    session=${new_leader_session}
108
109 Add_Leader_Cars_On_New_Leader
110     [Documentation]    Add cars on the new Leader.
111     TemplatedRequests.Put_As_Json_Templated
112     ...    folder=${VAR_DIR}/cars
113     ...    session=${new_leader_session}
114     ...    iterations=${CAR_ITEMS}
115     ...    iter_start=${LEADER_2NODE_START_I}
116
117 See_Leader_Cars_On_New_Leader
118     [Documentation]    GET cars from new Leader, should be the new ones.
119     TemplatedRequests.Get_As_Json_Templated
120     ...    folder=${VAR_DIR}/cars
121     ...    session=${new_leader_session}
122     ...    verify=True
123     ...    iterations=${CAR_ITEMS}
124     ...    iter_start=${LEADER_2NODE_START_I}
125
126 See_Leader_Cars_On_New_Followers
127     [Documentation]    The same check on other existing members.
128     FOR    ${session}    IN    @{new_follower_sessions}
129         TemplatedRequests.Get_As_Json_Templated
130         ...    folder=${VAR_DIR}/cars
131         ...    session=${session}
132         ...    verify=True
133         ...    iterations=${CAR_ITEMS}
134         ...    iter_start=${LEADER_2NODE_START_I}
135     END
136
137 Delete_Leader_Cars_On_New_First_Follower
138     [Documentation]    Delete cars in new first Follower.
139     TemplatedRequests.Delete_Templated    folder=${VAR_DIR}/cars    session=${new_first_follower_session}
140
141 Add_Follower_Cars_On_New_First_Follower
142     [Documentation]    Add cars on the new first Follower.
143     TemplatedRequests.Put_As_Json_Templated
144     ...    folder=${VAR_DIR}/cars
145     ...    session=${new_first_follower_session}
146     ...    iterations=${CAR_ITEMS}
147     ...    iter_start=${FOLLOWER_2NODE_START_I}
148
149 See_Folower_Cars_On_New_Leader
150     [Documentation]    Get cars from the new Leader, should be the ones added on follower.
151     TemplatedRequests.Get_As_Json_Templated
152     ...    folder=${VAR_DIR}/cars
153     ...    session=${new_leader_session}
154     ...    verify=True
155     ...    iterations=${CAR_ITEMS}
156     ...    iter_start=${FOLLOWER_2NODE_START_I}
157
158 See_Follower_Cars_On_New_Followers
159     [Documentation]    The same check on other existing members.
160     FOR    ${session}    IN    @{new_follower_sessions}
161         TemplatedRequests.Get_As_Json_Templated
162         ...    folder=${VAR_DIR}/cars
163         ...    session=${session}
164         ...    verify=True
165         ...    iterations=${CAR_ITEMS}
166         ...    iter_start=${FOLLOWER_2NODE_START_I}
167     END
168
169 Rejoin_Old_Car_Leader
170     [Documentation]    Rejoin the isolated member without deleting the persisted data.
171     ClusterManagement.Rejoin_Member_From_List_Or_All    ${car_leader_index}
172     BuiltIn.Wait_Until_Keyword_Succeeds
173     ...    30s
174     ...    2s
175     ...    ClusterManagement.Verify_Leader_Exists_For_Each_Shard
176     ...    shard_name_list=${SHARD_NAME_LIST}
177     ...    shard_type=config
178
179 See_Folower_Cars_On_Old_Leader
180     [Documentation]    GET cars from the restarted member, should be the ones added on follower.
181     TemplatedRequests.Get_As_Json_Templated
182     ...    folder=${VAR_DIR}/cars
183     ...    session=${car_leader_session}
184     ...    verify=True
185     ...    iterations=${CAR_ITEMS}
186     ...    iter_start=${FOLLOWER_2NODE_START_I}
187
188 Delete_Follower_Cars_On_New_Leader
189     [Documentation]    Delete cars on the last Leader.
190     TemplatedRequests.Delete_Templated    folder=${VAR_DIR}/cars    session=${new_leader_session}
191
192
193 *** Keywords ***
194 Setup
195     [Documentation]    Initialize resources, memorize car shard leader and followers.
196     SetupUtils.Setup_Utils_For_Setup_And_Teardown
197     CarPeople.Set_Variables_For_Shard    shard_name=car