Upgrade RF syntax for v3.2 compatibility
[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 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
22 Default Tags      clustering    carpeople    critical
23 Library           Collections
24 Resource          ${CURDIR}/../../../libraries/CarPeople.robot
25 Resource          ${CURDIR}/../../../libraries/ClusterManagement.robot
26 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
27 Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
28 Variables         ${CURDIR}/../../../variables/Variables.py
29
30 *** Variables ***
31 ${CARPEOPLE_ITEMS}    ${30}
32 ${VAR_DIR}        ${CURDIR}/../../../variables/carpeople/crud
33
34 *** Test Cases ***
35 Add_Cars_To_Leader
36     [Documentation]    Add ${CARPEOPLE_ITEMS} cars to car Leader by one big PUT.
37     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_DIR}/cars    session=${car_leader_session}    iterations=${CARPEOPLE_ITEMS}
38
39 See_Added_Cars_On_Leader
40     [Documentation]    GET response from Leader should match the PUT data.
41     TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/cars    session=${car_leader_session}    verify=True    iterations=${CARPEOPLE_ITEMS}
42
43 See_Added_Cars_On_Followers
44     [Documentation]    The same check on other members.
45     FOR    ${session}    IN    @{car_follower_sessions}
46         TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/cars    session=${session}    verify=True    iterations=${CARPEOPLE_ITEMS}
47     END
48
49 Add_People_To_First_Follower
50     [Documentation]    Add ${CARPEOPLE_ITEMS} people to people first Follower, loop of add-person.
51     CarPeople.Add_Several_People    session=${people_first_follower_session}    iterations=${CARPEOPLE_ITEMS}
52
53 See_Added_People_On_Leader
54     [Documentation]    GET response from Leader should match the added people.
55     TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/people    session=${people_leader_session}    verify=True    iterations=${CARPEOPLE_ITEMS}
56
57 See_Added_People_On_Followers
58     [Documentation]    The same check on other members.
59     FOR    ${session}    IN    @{people_follower_sessions}
60         TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/people    session=${session}    verify=True    iterations=${CARPEOPLE_ITEMS}
61     END
62
63 Buy_Cars_On_Leader
64     [Documentation]    Buy some cars on car-people Leader, loop of buy-car, ending segment of IDs.
65     # Cars are numbered, leader gets chunk at the end, as that is few keypresses shorter.
66     ${start_id} =    BuiltIn.Evaluate    (${NUM_ODL_SYSTEM} - 1) * ${items_per_follower} + 1
67     CarPeople.Buy_Several_Cars    session=${car-people_leader_session}    iterations=${items_per_leader}    iter_start=${start_id}
68
69 Buy_Cars_On_Followers
70     [Documentation]    On each Follower buy corresponding ID segment of cars in buy-car loop.
71     ${start_id} =    BuiltIn.Set_Variable    1
72     FOR    ${session}    IN    @{car-people_follower_sessions}
73         CarPeople.Buy_Several_Cars    session=${session}    iterations=${items_per_follower}    iter_start=${start_id}
74         ${start_id} =    BuiltIn.Evaluate    ${start_id} + ${items_per_follower}
75     END
76
77 See_Added_CarPeople_On_Leader
78     [Documentation]    GET car-person mappings from Leader to see all entries.
79     TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/car-people    session=${car-people_leader_session}    verify=True    iterations=${CARPEOPLE_ITEMS}
80
81 See_Added_CarPeople_On_Followers
82     [Documentation]    The same check on other members.
83     FOR    ${session}    IN    @{car-people_follower_sessions}
84         TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/car-people    session=${session}    verify=True    iterations=${CARPEOPLE_ITEMS}
85     END
86
87 Delete_All_CarPeople_On_Leader
88     [Documentation]    DELETE car-people container. No verification beyond http status.
89     TemplatedRequests.Delete_Templated    folder=${VAR_DIR}/car-people    session=${car-people_leader_session}
90
91 Delete_All_People_On_Leader
92     [Documentation]    DELETE people container. No verification beyond http status.
93     TemplatedRequests.Delete_Templated    folder=${VAR_DIR}/people    session=${people_leader_session}
94
95 Delete_All_Cars_On_Leader
96     [Documentation]    DELETE cars container. No verification beyond http status.
97     TemplatedRequests.Delete_Templated    folder=${VAR_DIR}/cars    session=${car_leader_session}
98
99 *** Keywords ***
100 Setup
101     [Documentation]    Initialize resources, memorize shard leaders, compute item distribution.
102     SetupUtils.Setup_Utils_For_Setup_And_Teardown
103     CarPeople.Set_Variables_For_Shard    shard_name=car
104     CarPeople.Set_Variables_For_Shard    shard_name=people
105     CarPeople.Set_Variables_For_Shard    shard_name=car-people
106     ${follower_number} =    BuiltIn.Evaluate    ${CARPEOPLE_ITEMS} / ${NUM_ODL_SYSTEM}
107     BuiltIn.Set_Suite_Variable    ${items_per_follower}    ${follower_number}
108     ${leader_number} =    BuiltIn.Evaluate    ${CARPEOPLE_ITEMS} - (${NUM_ODL_SYSTEM} - 1) * ${follower_number}
109     BuiltIn.Set_Suite_Variable    ${items_per_leader}    ${leader_number}