Step 1: Move vm scripts to the right place
[integration/test.git] / test / csit / suites / controller / Clustering_Routedrpc / 023_routed_rpc_crud_test.robot
1 *** Settings ***
2 Documentation     Test suite for Routed RPC.
3 Library           Collections
4 Library           RequestsLibrary
5 Library           ../../../libraries/Common.py
6 Library           ../../../libraries/CrudLibrary.py
7 Library           ../../../libraries/SettingsLibrary.py
8 Library           ../../../libraries/UtilLibrary.py
9 Resource          ../../../libraries/ClusterKeywords.robot
10 Variables         ../../../variables/Variables.py
11
12 *** Variables ***
13 @{controllers}    ${CONTROLLER}    ${CONTROLLER1}    ${CONTROLLER2}
14 ${SHARD_CAR_NAME}    shard-car-config
15 ${SHARD_PEOPLE_NAME}    shard-people-config
16 ${SHARD_CAR_PERSON_NAME}    shard-car-people-config
17 ${KARAF_HOME}     ${WORKSPACE}/${BUNDLEFOLDER}
18
19 *** Test Cases ***
20 Delete all entries from shards
21     [Documentation]    Make sure the shards are cleared for testing.
22     : FOR    ${ip}    IN    @{controllers}
23     \    Delete All Cars And Verify    ${ip}
24     : FOR    ${ip}    IN    @{controllers}
25     \    Delete All People And Verify    ${ip}
26     : FOR    ${ip}    IN    @{controllers}
27     \    Delete All Cars-Persons And Verify    ${ip}
28
29 Get Car Leader And Followers
30     ${CURRENT_CAR_LEADER}    Wait For Leader To Be Found    ${SHARD_CAR_NAME}
31     Set Suite Variable    ${CURRENT_CAR_LEADER}
32     @{CAR_FOLLOWERS}    Get All Followers    ${SHARD_CAR_NAME}
33     Set Suite Variable    ${CAR_FOLLOWERS}
34
35 Add cars and get cars from Leader
36     [Documentation]    Add 100 cars and get added cars from Leader
37     ${resp}=    InitCar    ${CURRENT_CAR_LEADER}    ${PORT}
38     ${resp}=    AddCar    ${CURRENT_CAR_LEADER}    ${PORT}    ${100}
39     ${resp}=    Getcars    ${CURRENT_CAR_LEADER}    ${PORT}    ${0}
40     Should Be Equal As Strings    ${resp.status_code}    200
41     Should Contain    ${resp.content}    manufacturer1    cars not added!
42
43 Add persons and get persons from Leader
44     [Documentation]    Add 100 persons and get persons Note: There should be one person added first to enable rpc
45     ${resp}    AddPerson    ${CURRENT_CAR_LEADER}    ${PORT}    ${0}
46     ${resp}    AddPerson    ${CURRENT_CAR_LEADER}    ${PORT}    ${100}
47     ${resp}    GetPersons    ${CURRENT_CAR_LEADER}    ${PORT}    ${0}
48     Should Be Equal As Strings    ${resp.status_code}    200
49     Should Contain    ${resp.content}    user5    people not added!
50
51 Add car-person mapping and get car-person mapping from Follower1
52     [Documentation]    Add car-person and get car-person from Leader Note: This is done to enable working of rpc
53     Log    @{CAR_FOLLOWERS}[0]
54     ${resp}    AddCarPerson    @{CAR_FOLLOWERS}[0]    ${PORT}    ${0}
55     Should Be Equal As Strings    ${resp.status_code}    204
56     ${resp}    GetCarPersonMappings    @{CAR_FOLLOWERS}[0]    ${PORT}    ${0}
57     Should Be Equal As Strings    ${resp.status_code}    200
58     Should Contain    ${resp.content}    user0    car-person not initialized!
59
60 Purchase 100 cars using Follower1
61     [Documentation]    Purchase 100 cars using Follower1
62     BuyCar    @{CAR_FOLLOWERS}[0]    ${PORT}    ${100}
63
64 Check Contents of Leader Shards
65     [Documentation]    Check all content using Leader
66     wait until keyword succeeds    30    1    Check Cars    ${CURRENT_CAR_LEADER}    ${PORT}    100
67     wait until keyword succeeds    30    1    Check People    ${CURRENT_CAR_LEADER}    ${PORT}    100
68     wait until keyword succeeds    30    1    Check CarPeople    ${CURRENT_CAR_LEADER}    ${PORT}    100
69
70 Check Contents of First Follower Shards
71     [Documentation]    Check all content using first follower
72     wait until keyword succeeds    30    1    Check Cars    @{CAR_FOLLOWERS}[0]    ${PORT}    100
73     wait until keyword succeeds    30    1    Check People    @{CAR_FOLLOWERS}[0]    ${PORT}    100
74     wait until keyword succeeds    30    1    Check CarPeople    @{CAR_FOLLOWERS}[0]    ${PORT}    100
75
76 Check Contents of Second Follower Shards
77     [Documentation]    Check all content using second follower
78     wait until keyword succeeds    30    1    Check Cars    @{CAR_FOLLOWERS}[1]    ${PORT}    100
79     wait until keyword succeeds    30    1    Check People    @{CAR_FOLLOWERS}[1]    ${PORT}    100
80     wait until keyword succeeds    30    1    Check CarPeople    @{CAR_FOLLOWERS}[1]    ${PORT}    100
81
82 Switch Car leader
83     [Documentation]    Stop the leader to cause a new leader to be elected
84     ${OLD_CAR_LEADER}=    Set Variable    ${CURRENT_CAR_LEADER}
85     Set Suite Variable    ${OLD_CAR_LEADER}
86     ${NEW_CAR_LEADER}    Switch Leader    ${SHARD_CAR_NAME}    ${CURRENT_CAR_LEADER}
87     Set Suite Variable    ${NEW_CAR_LEADER}
88
89 Get New Car Follower
90     [Documentation]    Find the new leader for the car shard.
91     @{CAR_FOLLOWERS}    Get All Followers    ${SHARD_CAR_NAME}
92     Set Suite Variable    ${CAR_FOLLOWERS}
93     Log    @{CAR_FOLLOWERS}[0]
94
95 Overwrite cars and get cars from New Leader
96     [Documentation]    Overwrite 100 cars and get added cars from Leader
97     ${resp}=    AddCar    ${NEW_CAR_LEADER}    ${PORT}    ${100}
98     ${resp}=    Getcars    ${NEW_CAR_LEADER}    ${PORT}    ${0}
99     Should Be Equal As Strings    ${resp.status_code}    200
100     Should Contain    ${resp.content}    manufacturer1    cars not added!
101
102 Overwrite persons and get persons from New Leader
103     [Documentation]    Overwrite 100 persons and get persons Note: There should be one person added first to enable rpc
104     ${resp}    AddPerson    ${NEW_CAR_LEADER}    ${PORT}    ${100}
105     ${resp}    GetPersons    ${NEW_CAR_LEADER}    ${PORT}    ${0}
106     Should Be Equal As Strings    ${resp.status_code}    200
107     Should Contain    ${resp.content}    user5    people not added!
108
109 RePurchase 100 cars using New Follower1
110     [Documentation]    RePurchase 100 cars using Follower1
111     BuyCar    @{CAR_FOLLOWERS}[0]    ${PORT}    ${100}
112
113 Check Contents of New Leader Shards
114     [Documentation]    Check all content using Leader
115     Log    ${NEW_CAR_LEADER}
116     wait until keyword succeeds    30    1    Check Cars    ${NEW_CAR_LEADER}    ${PORT}    100
117     wait until keyword succeeds    30    1    Check People    ${NEW_CAR_LEADER}    ${PORT}    100
118     wait until keyword succeeds    30    1    Check CarPeople    ${NEW_CAR_LEADER}    ${PORT}    100
119
120 Check Contents of New First Follower Shards
121     [Documentation]    Check all content using first follower
122     wait until keyword succeeds    30    1    Check Cars    @{CAR_FOLLOWERS}[0]    ${PORT}    100
123     wait until keyword succeeds    30    1    Check People    @{CAR_FOLLOWERS}[0]    ${PORT}    100
124     wait until keyword succeeds    30    1    Check CarPeople    @{CAR_FOLLOWERS}[0]    ${PORT}    100
125
126 Start Leader
127     [Documentation]    Start Leader controller
128     Start One Or More Controllers    ${OLD_CAR_LEADER}