Upgrade RF syntax for v3.2 compatibility
[integration/test.git] / csit / suites / controller / Clustering_Datastore / buycar_failover.robot
1 *** Settings ***
2 Documentation     This test focuses on testing buy-car RPC over 3 Leader reboots.
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 ...               All purchases are against the same node, which is the first one to get rebooted.
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 Suite Setup       Setup
16 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
17 Default Tags      clustering    carpeople    critical
18 Library           Collections
19 Resource          ${CURDIR}/../../../libraries/CarPeople.robot
20 Resource          ${CURDIR}/../../../libraries/ClusterManagement.robot
21 Resource          ${CURDIR}/../../../libraries/SetupUtils.robot
22 Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
23 Variables         ${CURDIR}/../../../variables/Variables.py
24
25 *** Variables ***
26 ${CARPEOPLE_ITEMS}    ${100}
27 ${MEMBER_START_TIMEOUT}    300s
28 @{SHARD_NAME_LIST}    car    people    car-people
29 ${VAR_DIR}        ${CURDIR}/../../../variables/carpeople/crud
30
31 *** Test Cases ***
32 Add_Cars_To_Leader_And_Verify
33     [Documentation]    Add all needed cars to car Leader, verify on each member.
34     ${car_items} =    BuiltIn.Evaluate    ${CARPEOPLE_ITEMS} * 4
35     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_DIR}/cars    session=${car_leader_session}    iterations=${car_items}
36     FOR    ${session}    IN    @{ClusterManagement__session_list}
37         BuiltIn.Wait_Until_Keyword_Succeeds    10s    2s    TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/cars    session=${session}
38         ...    verify=True    iterations=${car_items}
39     END
40
41 Add_People_To_First_Follower_And_Verify
42     [Documentation]    Add all needed people to people first Follower, verify on each member.
43     ${people_items} =    BuiltIn.Evaluate    ${CARPEOPLE_ITEMS} * 4
44     CarPeople.Add_Several_People    session=${people_first_follower_session}    iterations=${people_items}
45     FOR    ${session}    IN    @{ClusterManagement__session_list}
46         BuiltIn.Wait_Until_Keyword_Succeeds    10s    2s    TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/people    session=${session}
47         ...    verify=True    iterations=${people_items}
48     END
49
50 Buy_Cars_On_Leader_And_Verify
51     [Documentation]    Buy some cars on the leader member.
52     ${iter_start} =    BuiltIn.Evaluate    0 * ${CARPEOPLE_ITEMS} + 1
53     CarPeople.Buy_Several_Cars    session=${car-people_leader_session}    iterations=${CARPEOPLE_ITEMS}    iter_start=${iter_start}
54     ${total_iterations} =    BuiltIn.Evaluate    1 * ${CARPEOPLE_ITEMS}
55     FOR    ${session}    IN    @{ClusterManagement__session_list}
56         BuiltIn.Wait_Until_Keyword_Succeeds    10s    2s    TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/car-people    session=${session}
57         ...    verify=True    iterations=${total_iterations}
58     END
59
60 Buy_Cars_On_Follower_And_Verify
61     [Documentation]    Buy some cars on the first follower member.
62     ${iter_start} =    BuiltIn.Evaluate    1 * ${CARPEOPLE_ITEMS} + 1
63     CarPeople.Buy_Several_Cars    session=${car-people_first_follower_session}    iterations=${CARPEOPLE_ITEMS}    iter_start=${iter_start}
64     ${total_iterations} =    BuiltIn.Evaluate    2 * ${CARPEOPLE_ITEMS}
65     FOR    ${session}    IN    @{ClusterManagement__session_list}
66         BuiltIn.Wait_Until_Keyword_Succeeds    10s    2s    TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/car-people    session=${session}
67         ...    verify=True    iterations=${total_iterations}
68     END
69
70 Reboot_People_Leader
71     [Documentation]    Previous people Leader is rebooted. We should never stop the people first follower, this is where people are registered.
72     ClusterManagement.Stop_Single_Member    ${people_leader_index}    confirm=True
73     ClusterManagement.Start_Single_Member    ${people_leader_index}    wait_for_sync=True    timeout=${MEMBER_START_TIMEOUT}
74     BuiltIn.Wait_Until_Keyword_Succeeds    30s    2s    ClusterManagement.Verify_Leader_Exists_For_Each_Shard    shard_name_list=${SHARD_NAME_LIST}    shard_type=config
75
76 Buy_Cars_On_Leader_After_Reboot_And_Verify
77     [Documentation]    Buy some cars on the leader member.
78     ${iter_start} =    BuiltIn.Evaluate    2 * ${CARPEOPLE_ITEMS} + 1
79     CarPeople.Buy_Several_Cars    session=${car-people_leader_session}    iterations=${CARPEOPLE_ITEMS}    iter_start=${iter_start}
80     ${total_iterations} =    BuiltIn.Evaluate    3 * ${CARPEOPLE_ITEMS}
81     FOR    ${session}    IN    @{ClusterManagement__session_list}
82         BuiltIn.Wait_Until_Keyword_Succeeds    10s    2s    TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/car-people    session=${session}
83         ...    verify=True    iterations=${total_iterations}
84     END
85
86 Buy_Cars_On_Follower_After_Reboot_And_Verify
87     [Documentation]    Buy some cars on the first follower member.
88     ${iter_start} =    BuiltIn.Evaluate    3 * ${CARPEOPLE_ITEMS} + 1
89     CarPeople.Buy_Several_Cars    session=${car-people_first_follower_session}    iterations=${CARPEOPLE_ITEMS}    iter_start=${iter_start}
90     ${total_iterations} =    BuiltIn.Evaluate    4 * ${CARPEOPLE_ITEMS}
91     FOR    ${session}    IN    @{ClusterManagement__session_list}
92         BuiltIn.Wait_Until_Keyword_Succeeds    10s    2s    TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/car-people    session=${session}
93         ...    verify=True    iterations=${total_iterations}
94     END
95
96 Delete_All_CarPeople
97     [Documentation]    DELETE car-people container. No verification beyond http status.
98     TemplatedRequests.Delete_Templated    folder=${VAR_DIR}/car-people    session=${car-people_leader_session}
99
100 Delete_All_People
101     [Documentation]    DELETE people container. No verification beyond http status.
102     TemplatedRequests.Delete_Templated    folder=${VAR_DIR}/people    session=${people_leader_session}
103
104 Delete_All_Cars
105     [Documentation]    DELETE cars container. No verification beyond http status.
106     TemplatedRequests.Delete_Templated    folder=${VAR_DIR}/cars    session=${car_leader_session}
107
108 *** Keywords ***
109 Setup
110     [Documentation]    Initialize resources, memorize shard leaders, compute item distribution.
111     SetupUtils.Setup_Utils_For_Setup_And_Teardown
112     Set_Variables_For_Shard    shard_name=car
113     Set_Variables_For_Shard    shard_name=people
114     Set_Variables_For_Shard    shard_name=car-people
115     ${leader_list} =    BuiltIn.Create_List    ${car-people_leader_index}
116     ${reboot_list} =    Collections.Combine_Lists    ${leader_list}    ${car-people_follower_indices}
117     BuiltIn.Set_Suite_Variable    \${list_to_reboot}    ${reboot_list}