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