Migrate Get Requests invocations(libraries)
[integration/test.git] / csit / suites / controller / Clustering_Datastore / buycar_failover_isolation.robot
1 *** Settings ***
2 Documentation       This test focuses on testing buy-car RPC over the Leader isolation.
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 ...                 All purchases are against the same node, which is the first one to get isolated.
12 ...
13 ...                 All data is deleted at the end of the suite.
14 ...                 This suite expects car, people and car-people modules to have separate Shards.
15
16 Library             Collections
17 Resource            ${CURDIR}/../../../libraries/CarPeople.robot
18 Resource            ${CURDIR}/../../../libraries/ClusterManagement.robot
19 Resource            ${CURDIR}/../../../libraries/SetupUtils.robot
20 Resource            ${CURDIR}/../../../libraries/TemplatedRequests.robot
21 Variables           ${CURDIR}/../../../variables/Variables.py
22
23 Suite Setup         Setup
24 Test Setup          SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
25
26 Default Tags        clustering    carpeople    critical
27
28
29 *** Variables ***
30 ${CARPEOPLE_ITEMS}          ${100}
31 ${MEMBER_START_TIMEOUT}     300s
32 @{SHARD_NAME_LIST}          car    people    car-people
33 ${VAR_DIR}                  ${CURDIR}/../../../variables/carpeople/crud
34
35
36 *** Test Cases ***
37 Add_Cars_To_Leader_And_Verify
38     [Documentation]    Add all needed cars to car Leader, verify on each member.
39     ${car_items} =    BuiltIn.Evaluate    ${CARPEOPLE_ITEMS} * 4
40     TemplatedRequests.Put_As_Json_Templated
41     ...    folder=${VAR_DIR}/cars
42     ...    session=${car_leader_session}
43     ...    iterations=${car_items}
44     FOR    ${session}    IN    @{ClusterManagement__session_list}
45         BuiltIn.Wait_Until_Keyword_Succeeds
46         ...    10s
47         ...    2s
48         ...    TemplatedRequests.Get_As_Json_Templated
49         ...    folder=${VAR_DIR}/cars
50         ...    session=${session}
51         ...    verify=True
52         ...    iterations=${car_items}
53     END
54
55 Add_People_To_First_Follower_And_Verify
56     [Documentation]    Add all needed people to people first Follower, verify on each member.
57     ${people_items} =    BuiltIn.Evaluate    ${CARPEOPLE_ITEMS} * 4
58     CarPeople.Add_Several_People    session=${people_first_follower_session}    iterations=${people_items}
59     FOR    ${session}    IN    @{ClusterManagement__session_list}
60         BuiltIn.Wait_Until_Keyword_Succeeds
61         ...    10s
62         ...    2s
63         ...    TemplatedRequests.Get_As_Json_Templated
64         ...    folder=${VAR_DIR}/people
65         ...    session=${session}
66         ...    verify=True
67         ...    iterations=${people_items}
68     END
69
70 Buy_Cars_On_Leader_And_Verify
71     [Documentation]    Buy some cars on the leader member.
72     ${iter_start} =    BuiltIn.Evaluate    0 * ${CARPEOPLE_ITEMS} + 1
73     CarPeople.Buy_Several_Cars
74     ...    session=${car-people_leader_session}
75     ...    iterations=${CARPEOPLE_ITEMS}
76     ...    iter_start=${iter_start}
77     ${total_iterations} =    BuiltIn.Evaluate    1 * ${CARPEOPLE_ITEMS}
78     FOR    ${session}    IN    @{ClusterManagement__session_list}
79         BuiltIn.Wait_Until_Keyword_Succeeds
80         ...    10s
81         ...    2s
82         ...    TemplatedRequests.Get_As_Json_Templated
83         ...    folder=${VAR_DIR}/car-people
84         ...    session=${session}
85         ...    verify=True
86         ...    iterations=${total_iterations}
87     END
88
89 Buy_Cars_On_Follower_And_Verify
90     [Documentation]    Buy some cars on the first follower member.
91     ${iter_start} =    BuiltIn.Evaluate    1 * ${CARPEOPLE_ITEMS} + 1
92     CarPeople.Buy_Several_Cars
93     ...    session=${car-people_first_follower_session}
94     ...    iterations=${CARPEOPLE_ITEMS}
95     ...    iter_start=${iter_start}
96     ${total_iterations} =    BuiltIn.Evaluate    2 * ${CARPEOPLE_ITEMS}
97     FOR    ${session}    IN    @{ClusterManagement__session_list}
98         BuiltIn.Wait_Until_Keyword_Succeeds
99         ...    10s
100         ...    2s
101         ...    TemplatedRequests.Get_As_Json_Templated
102         ...    folder=${VAR_DIR}/car-people
103         ...    session=${session}
104         ...    verify=True
105         ...    iterations=${total_iterations}
106     END
107
108 Isolate_and_Rejoin_People_Leader
109     [Documentation]    Previous people Leader is isolated. We should never stop the people first follower, this is where people are registered.
110     ClusterManagement.Isolate_Member_From_List_Or_All    ${people_leader_index}
111     BuiltIn.Wait_Until_Keyword_Succeeds
112     ...    10x
113     ...    2s
114     ...    ClusterManagement.Verify_Shard_Leader_Elected
115     ...    people
116     ...    config
117     ...    ${True}
118     ...    ${people_leader_index}
119     ...    ${people_follower_indices}
120     ClusterManagement.Rejoin_Member_From_List_Or_All    ${people_leader_index}
121     BuiltIn.Wait_Until_Keyword_Succeeds
122     ...    30s
123     ...    2s
124     ...    ClusterManagement.Verify_Leader_Exists_For_Each_Shard
125     ...    shard_name_list=${SHARD_NAME_LIST}
126     ...    shard_type=config
127
128 Buy_Cars_On_Leader_After_Rejoin_And_Verify
129     [Documentation]    Buy some cars on the leader member.
130     ${iter_start} =    BuiltIn.Evaluate    2 * ${CARPEOPLE_ITEMS} + 1
131     CarPeople.Buy_Several_Cars
132     ...    session=${car-people_leader_session}
133     ...    iterations=${CARPEOPLE_ITEMS}
134     ...    iter_start=${iter_start}
135     ${total_iterations} =    BuiltIn.Evaluate    3 * ${CARPEOPLE_ITEMS}
136     FOR    ${session}    IN    @{ClusterManagement__session_list}
137         BuiltIn.Wait_Until_Keyword_Succeeds
138         ...    10s
139         ...    2s
140         ...    TemplatedRequests.Get_As_Json_Templated
141         ...    folder=${VAR_DIR}/car-people
142         ...    session=${session}
143         ...    verify=True
144         ...    iterations=${total_iterations}
145     END
146
147 Buy_Cars_On_Follower_After_Rejoin_And_Verify
148     [Documentation]    Buy some cars on the first follower member.
149     ${iter_start} =    BuiltIn.Evaluate    3 * ${CARPEOPLE_ITEMS} + 1
150     CarPeople.Buy_Several_Cars
151     ...    session=${car-people_first_follower_session}
152     ...    iterations=${CARPEOPLE_ITEMS}
153     ...    iter_start=${iter_start}
154     ${total_iterations} =    BuiltIn.Evaluate    4 * ${CARPEOPLE_ITEMS}
155     FOR    ${session}    IN    @{ClusterManagement__session_list}
156         BuiltIn.Wait_Until_Keyword_Succeeds
157         ...    10s
158         ...    2s
159         ...    TemplatedRequests.Get_As_Json_Templated
160         ...    folder=${VAR_DIR}/car-people
161         ...    session=${session}
162         ...    verify=True
163         ...    iterations=${total_iterations}
164     END
165
166 Delete_All_CarPeople
167     [Documentation]    DELETE car-people container. No verification beyond http status.
168     TemplatedRequests.Delete_Templated    folder=${VAR_DIR}/car-people    session=${car-people_leader_session}
169
170 Delete_All_People
171     [Documentation]    DELETE people container. No verification beyond http status.
172     TemplatedRequests.Delete_Templated    folder=${VAR_DIR}/people    session=${people_leader_session}
173
174 Delete_All_Cars
175     [Documentation]    DELETE cars container. No verification beyond http status.
176     TemplatedRequests.Delete_Templated    folder=${VAR_DIR}/cars    session=${car_leader_session}
177
178
179 *** Keywords ***
180 Setup
181     [Documentation]    Initialize resources, memorize shard leaders, compute item distribution.
182     SetupUtils.Setup_Utils_For_Setup_And_Teardown
183     Set_Variables_For_Shard    shard_name=car
184     Set_Variables_For_Shard    shard_name=people
185     Set_Variables_For_Shard    shard_name=car-people
186     ${leader_list} =    BuiltIn.Create_List    ${car-people_leader_index}