Add resiliency to 3-node cluster tests
[integration/test.git] / test / csit / libraries / ClusterKeywords.txt
1 *** Settings ***
2
3 *** Variables ***
4
5 *** Keywords ***
6 Get Leader And Verify
7     [Arguments]   ${shard_name}  ${old_leader}=${EMPTY}
8     ${leader}   GetLeader   ${shard_name}  ${3}  ${3}  ${1}  ${PORT}  ${MEMBER1}  ${MEMBER2}  ${MEMBER3}
9     Should Not Be Equal As Strings   ${leader}   None
10     Run Keyword If  '${old_leader}'!='${EMPTY}'  Should Not Be Equal  ${old_leader}  ${leader}
11     [Return]   ${leader}
12
13 Wait For Leader
14     [Arguments]   ${shard_name}
15     ${leader}   Wait Until Keyword Succeeds   60s  2s  Get Leader And Verify  ${shard_name}
16     Log   ${leader}
17     [Return]   ${leader}
18
19 Switch Leader
20     [Arguments]   ${shard_name}  ${current_leader}
21     StopController  ${current_leader}  ${USERNAME}  ${PASSWORD}  ${KARAFHOME}
22     ${new_leader}  Wait Until Keyword Succeeds   60s  2s  Get Leader And Verify  ${shard_name}  ${current_leader}
23     Log   ${new_leader}
24     [Return]   ${new_leader}
25
26 Get All Followers
27     [Arguments]   ${shard_name}
28     ${followers}  GetFollowers  ${shard_name}  ${3}  ${3}  ${1}  ${PORT}  ${MEMBER1}  ${MEMBER2}  ${MEMBER3}
29     Log  ${followers}
30     Should Not Be Empty  ${followers}
31     [Return]  ${followers}
32
33 Add Cars And Verify
34     [Arguments]    ${controller_ip}    ${num_cars}  ${timeout}=60s
35     ${resp}   AddCar   ${controller_ip}   ${PORT}   ${num_cars}
36     Should Be Equal As Strings    ${resp.status_code}    204
37     Wait Until Keyword Succeeds   ${timeout}  2s  Get Cars And Verify   ${controller_ip}  ${num_cars}
38
39 Get Cars And Verify
40     [Arguments]    ${controller_ip}    ${num_cars}
41     ${resp}     Getcars  ${controller_ip}   ${PORT}  ${0}
42     Should Be Equal As Strings    ${resp.status_code}    200
43     :FOR    ${i}    IN RANGE    1    ${num_cars}
44     \    Should Contain     ${resp.content}   manufacturer${i}
45
46 Add People And Verify
47     [Arguments]    ${controller_ip}    ${num_people}
48     [Documentation]  Note: The first AddPerson call passed with 0 posts directly to the data store to get
49     [Documentation]  the people container created so the subsequent AddPerson RPC calls that put 
50     [Documentation]  to the person list will succeed.
51     ${resp}  AddPerson  ${controller_ip}  ${PORT}  ${0}
52     Should Be Equal As Strings  ${resp.status_code}  204
53     Wait Until Keyword Succeeds   60s  2s  Get One Person And Verify  ${controller_ip}  ${0}
54     ${resp}  AddPerson   ${controller_ip}    ${PORT}  ${num_people}
55     Wait Until Keyword Succeeds   60s  2s  Get People And Verify  ${controller_ip}  ${num_people}
56
57 Get One Person And Verify
58     [Arguments]    ${controller_ip}    ${number}
59     ${resp}     GetPersons  ${controller_ip}    ${PORT}  ${0}
60     Should Be Equal As Strings    ${resp.status_code}    200
61     Should Contain   ${resp.content}   user${number}
62
63 Get People And Verify
64     [Arguments]    ${controller_ip}    ${num_people}
65     ${resp}     GetPersons  ${controller_ip}    ${PORT}  ${0}
66     Should Be Equal As Strings    ${resp.status_code}    200
67     :FOR    ${i}    IN RANGE    1    ${num_people}
68     \    Should Contain     ${resp.content}   user${i}
69
70 Add Car Person And Verify
71     [Arguments]    ${controller_ip}
72     [Documentation]  Add a car-person via the data store and get the car-person from Leader.
73     [Documentation]  Note: This is done to get the car-people container created so subsequent BuyCar
74     [Documentation]  RPC puts to the car-person list will succeed.
75     AddCarPerson    ${controller_ip}   ${PORT}     ${0}
76     Wait Until Keyword Succeeds   60s  2s  Get One Car-Person Mapping And Verify  ${controller_ip}   ${0}
77
78 Get One Car-Person Mapping And Verify
79     [Arguments]    ${controller_ip}    ${number}
80     ${resp}     GetCarPersonMappings    ${controller_ip}   ${PORT}     ${0}
81     Should Be Equal As Strings    ${resp.status_code}    200
82     Should Contain     ${resp.content}   user${number}
83
84 Get Car-Person Mappings And Verify
85     [Arguments]    ${controller_ip}    ${num_entries}
86     ${resp}     GetCarPersonMappings    ${controller_ip}    ${PORT}  ${0}
87     Should Be Equal As Strings    ${resp.status_code}    200
88     :FOR    ${i}    IN RANGE    1    ${num_entries}
89     \    Should Contain     ${resp.content}   user${i}
90
91 Buy Cars And Verify
92     [Arguments]    ${controller_ip}    ${num_entries}   ${start}=${0}
93     Wait Until Keyword Succeeds   60s  2s  BuyCar  ${controller_ip}   ${PORT}    ${num_entries}   ${start}
94
95 Check Cars Deleted
96     [Arguments]    ${controller_ip}
97     ${resp}    Getcars    ${controller_ip}    ${PORT}    ${0}
98     Should Be Equal As Strings    ${resp.status_code}    404
99
100 Delete All Cars And Verify
101     [Arguments]    ${controller_ip}
102     DeleteAllCars    ${controller_ip}    ${PORT}    ${0}
103     Wait Until Keyword Succeeds   60s  2s  Check Cars Deleted  ${controller_ip}
104
105 Check People Deleted
106     [Arguments]    ${controller_ip}
107     ${resp}    GetPersons    ${controller_ip}    ${PORT}    ${0}
108     Should Be Equal As Strings    ${resp.status_code}    404
109
110 Delete All People And Verify
111     [Arguments]    ${controller_ip}
112     DeleteAllPersons    ${controller_ip}    ${PORT}    ${0}
113     Wait Until Keyword Succeeds   60s  2s  Check People Deleted  ${controller_ip}
114
115 Check Cars-Persons Deleted
116     [Arguments]    ${controller_ip}
117     ${resp}    GetCarPersonMappings    ${controller_ip}    ${PORT}    ${0}
118     Should Be Equal As Strings    ${resp.status_code}    404
119
120 Delete All Cars-Persons And Verify
121     [Arguments]    ${controller_ip}
122     DeleteAllCarsPersons    ${controller_ip}    ${PORT}    ${0}
123     Wait Until Keyword Succeeds   60s  2s  Check Cars-Persons Deleted  ${controller_ip}