Rework of controller car/people cluster suite
[integration/test.git] / csit / suites / controller / Clustering_Datastore / carpeople_crud.robot
1 *** Settings ***
2 Documentation     Suite for performing basic car/people CRUD operations on leaders and followers.
3 ...
4 ...               Copyright (c) 2016 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 ...               More precisely, Update operation is not executed, but some operations
12 ...               are using specific RPCs which goes beyond "basic CRUD".
13 ...
14 ...               Cars are added by one big PUT to datastore on car Leader.
15 ...               People are added in a loop with add-person RPC on a people Follower.
16 ...               Cars are bought by chunks on each member, by loop with buy-car RPC.
17 ...
18 ...               All data is deleted at the end of the suite.
19 ...               This suite expects car, people and car-people modules to have separate Shards.
20 Suite Setup       Setup
21 Default Tags      clustering    carpeople    critical
22 Library           Collections
23 Resource          ${CURDIR}/../../../libraries/CarPeople.robot
24 Resource          ${CURDIR}/../../../libraries/ClusterManagement.robot
25 Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
26 Variables         ${CURDIR}/../../../variables/Variables.py
27
28 *** Variables ***
29 ${CARPEOPLE_ITEMS}    ${30}
30 ${VAR_DIR}        ${CURDIR}/../../../variables/carpeople/crud
31
32 *** Test Cases ***
33 Add_Cars_To_Leader
34     [Documentation]    Add ${CARPEOPLE_ITEMS} cars to car Leader by one big PUT.
35     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_DIR}/cars    session=${car_leader_session}    iterations=${CARPEOPLE_ITEMS}
36
37 See_Added_Cars_On_Leader
38     [Documentation]    GET response from Leader should match the PUT data.
39     TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/cars    session=${car_leader_session}    verify=True    iterations=${CARPEOPLE_ITEMS}
40
41 See_Added_Cars_On_Followers
42     [Documentation]    The same check on other members.
43     : FOR    ${session}    IN    @{car_follower_sessions}
44     \    TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/cars    session=${session}    verify=True    iterations=${CARPEOPLE_ITEMS}
45
46 Add_People_To_First_Follower
47     [Documentation]    Add ${CARPEOPLE_ITEMS} people to people first Follower, loop of add-person.
48     CarPeople.Add_Several_People    session=${people_first_follower_session}    iterations=${CARPEOPLE_ITEMS}
49
50 See_Added_People_On_Leader
51     [Documentation]    GET response from Leader should match the added people.
52     TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/people    session=${people_leader_session}    verify=True    iterations=${CARPEOPLE_ITEMS}
53
54 See_Added_People_On_Followers
55     [Documentation]    The same check on other members.
56     : FOR    ${session}    IN    @{people_follower_sessions}
57     \    TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/people    session=${session}    verify=True    iterations=${CARPEOPLE_ITEMS}
58
59 Buy_Cars_On_Leader
60     [Documentation]    Buy some cars on car-people Leader, loop of buy-car, ending segment of IDs.
61     # Cars are numbered, leader gets chunk at the end, as that is few keypresses shorter.
62     ${start_id} =    BuiltIn.Evaluate    (${NUM_ODL_SYSTEM} - 1) * ${items_per_follower} + 1
63     CarPeople.Buy_Several_Cars    session=${car-people_leader_session}    iterations=${items_per_leader}    iter_start=${start_id}
64
65 Buy_Cars_On_Followers
66     [Documentation]    On each Follower buy corresponding ID segment of cars in buy-car loop.
67     ${start_id} =    BuiltIn.Set_Variable    0
68     : FOR    ${session}    IN    @{car-people_follower_sessions}
69     \    CarPeople.Buy_Several_Cars    session=${session}    iterations=${items_per_follower}    iter_start=${start_id}
70     \    ${start_id} =    BuiltIn.Evaluate    ${start_id} + ${items_per_follower}
71
72 See_Added_CarPeople_On_Leader
73     [Documentation]    GET car-person mappings from Leader to see all entries.
74     TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/car-people    session=${car-people_leader_session}    verify=True    iterations=${CARPEOPLE_ITEMS}
75
76 See_Added_CarPeople_On_Followers
77     [Documentation]    The same check on other members.
78     : FOR    ${session}    IN    @{car-people_follower_sessions}
79     \    TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/car-people    session=${session}    verify=True    iterations=${CARPEOPLE_ITEMS}
80
81 Delete_All_CarPeople_On_Leader
82     [Documentation]    DELETE car-people container. No verification beyond http status.
83     TemplatedRequests.Delete_Templated    folder=${VAR_DIR}/car-people    session=${car-people_leader_session}
84
85 Delete_All_People_On_Leader
86     [Documentation]    DELETE people container. No verification beyond http status.
87     TemplatedRequests.Delete_Templated    folder=${VAR_DIR}/people    session=${people_leader_session}
88
89 Delete_All_Cars_On_Leader
90     [Documentation]    DELETE cars container. No verification beyond http status.
91     TemplatedRequests.Delete_Templated    folder=${VAR_DIR}/cars    session=${car_leader_session}
92
93 *** Keywords ***
94 Setup
95     [Documentation]    Initialize resources, memorize shard leaders, compute item distribution.
96     ClusterManagement.ClusterManagement_Setup
97     CarPeople.Set_Variables_For_Shard    shard_name=car
98     CarPeople.Set_Variables_For_Shard    shard_name=people
99     CarPeople.Set_Variables_For_Shard    shard_name=car-people
100     ${follower_number} =    BuiltIn.Evaluate    ${CARPEOPLE_ITEMS} / ${NUM_ODL_SYSTEM}
101     BuiltIn.Set_Suite_Variable    ${items_per_follower}    ${follower_number}
102     ${leader_number} =    BuiltIn.Evaluate    ${CARPEOPLE_ITEMS} - (${NUM_ODL_SYSTEM} - 1) * ${follower_number}
103     BuiltIn.Set_Suite_Variable    ${items_per_leader}    ${leader_number}