GENIUS-157: Fix typo in OF-Tunnels CSIT
[integration/test.git] / csit / suites / controller / Clustering_Datastore / car_failover_crud.robot
1 *** Settings ***
2 Documentation     Suite mixing basic operations with restart of car Leader.
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 ...               This test stops the current leader of the "car" shard and then executes CRD
12 ...               operations on the new leader and a new follower. The stopped member is brought back.
13 ...               This suite uses 3 different car sets, same size but different starting ID.
14 ...
15 ...               Other models and shards (people, car-people) are not accessed by this suite.
16 ...
17 ...               All data is deleted at the end of the suite.
18 ...               This suite expects car module to have a separate Shard.
19 Suite Setup       Setup
20 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
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/SetupUtils.robot
26 Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
27 Variables         ${CURDIR}/../../../variables/Variables.py
28
29 *** Variables ***
30 ${CAR_ITEMS}      30
31 ${FOLLOWER_2NODE_START_I}    300
32 ${LEADER_2NODE_START_I}    200
33 ${MEMBER_START_TIMEOUT}    300s
34 ${ORIGINAL_START_I}    100
35 @{SHARD_NAME_LIST}    car
36 ${VAR_DIR}        ${CURDIR}/../../../variables/carpeople/crud
37
38 *** Test Cases ***
39 Add_Original_Cars_On_Old_Leader_And_Verify
40     [Documentation]    Add initial cars on car Leader.
41     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_DIR}/cars    session=${car_leader_session}    iterations=${CAR_ITEMS}    iter_start=${ORIGINAL_START_I}
42     : FOR    ${session}    IN    @{ClusterManagement__session_list}
43     \    BuiltIn.Wait_Until_Keyword_Succeeds    10s    2s    TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/cars    session=${session}
44     \    ...    verify=True    iterations=${CAR_ITEMS}    iter_start=${ORIGINAL_START_I}
45
46 Stop_Original_Car_Leader
47     [Documentation]    Stop the car Leader to cause a new leader to get elected.
48     ClusterManagement.Stop_Single_Member    ${car_leader_index}    confirm=True
49
50 Wait_For_New_Leader
51     [Documentation]    Wait until new car Leader is elected.
52     BuiltIn.Wait_Until_Keyword_Succeeds    30s    2s    Set_Variables_For_Less_Nodes    member_index_list=${car_follower_indices}
53
54 See_Original_Cars_On_New_Leader
55     [Documentation]    GET cars from new Leader, should be the initial ones.
56     TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/cars    session=${new_leader_session}    verify=True    iterations=${CAR_ITEMS}    iter_start=${ORIGINAL_START_I}
57
58 See_Original_Cars_On_New_Followers
59     [Documentation]    The same check on other existing member(s).
60     : FOR    ${session}    IN    @{new_follower_sessions}
61     \    TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/cars    session=${session}    verify=True    iterations=${CAR_ITEMS}    iter_start=${ORIGINAL_START_I}
62
63 Delete_Original_Cars_On_New_Leader
64     [Documentation]    Delete cars on the new Leader.
65     TemplatedRequests.Delete_Templated    folder=${VAR_DIR}/cars    session=${new_leader_session}
66
67 Add_Leader_Cars_On_New_Leader
68     [Documentation]    Add cars on the new Leader.
69     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_DIR}/cars    session=${new_leader_session}    iterations=${CAR_ITEMS}    iter_start=${LEADER_2NODE_START_I}
70
71 See_Leader_Cars_On_New_Leader
72     [Documentation]    GET cars from new Leader, should be the new ones.
73     TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/cars    session=${new_leader_session}    verify=True    iterations=${CAR_ITEMS}    iter_start=${LEADER_2NODE_START_I}
74
75 See_Leader_Cars_On_New_Followers
76     [Documentation]    The same check on other existing members.
77     : FOR    ${session}    IN    @{new_follower_sessions}
78     \    TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/cars    session=${session}    verify=True    iterations=${CAR_ITEMS}    iter_start=${LEADER_2NODE_START_I}
79
80 Delete_Leader_Cars_On_New_First_Follower
81     [Documentation]    Delete cars in new first Follower.
82     TemplatedRequests.Delete_Templated    folder=${VAR_DIR}/cars    session=${new_first_follower_session}
83
84 Add_Follower_Cars_On_New_First_Follower
85     [Documentation]    Add cars on the new first Follower.
86     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_DIR}/cars    session=${new_first_follower_session}    iterations=${CAR_ITEMS}    iter_start=${FOLLOWER_2NODE_START_I}
87
88 See_Folower_Cars_On_New_Leader
89     [Documentation]    Get cars from the new Leader, should be the ones added on follower.
90     TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/cars    session=${new_leader_session}    verify=True    iterations=${CAR_ITEMS}    iter_start=${FOLLOWER_2NODE_START_I}
91
92 See_Follower_Cars_On_New_Followers
93     [Documentation]    The same check on other existing members.
94     : FOR    ${session}    IN    @{new_follower_sessions}
95     \    TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/cars    session=${session}    verify=True    iterations=${CAR_ITEMS}    iter_start=${FOLLOWER_2NODE_START_I}
96
97 Start_Old_Car_Leader
98     [Documentation]    Start the stopped member without deleting the persisted data.
99     ClusterManagement.Start_Single_Member    ${car_leader_index}    wait_for_sync=True    timeout=${MEMBER_START_TIMEOUT}
100     BuiltIn.Wait_Until_Keyword_Succeeds    30s    2s    ClusterManagement.Verify_Leader_Exists_For_Each_Shard    shard_name_list=${SHARD_NAME_LIST}    shard_type=config
101
102 See_Folower_Cars_On_Old_Leader
103     [Documentation]    GET cars from the restarted member, should be the ones added on follower.
104     TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/cars    session=${car_leader_session}    verify=True    iterations=${CAR_ITEMS}    iter_start=${FOLLOWER_2NODE_START_I}
105
106 Delete_Follower_Cars_On_New_Leader
107     [Documentation]    Delete cars on the last Leader.
108     TemplatedRequests.Delete_Templated    folder=${VAR_DIR}/cars    session=${new_leader_session}
109
110 *** Keywords ***
111 Setup
112     [Documentation]    Initialize resources, memorize car shard leader and followers.
113     SetupUtils.Setup_Utils_For_Setup_And_Teardown
114     CarPeople.Set_Variables_For_Shard    shard_name=car
115
116 Set_Variables_For_Less_Nodes
117     [Arguments]    ${member_index_list}
118     [Documentation]    Get current leader and followers for car shard, set additional suite variables.
119     ${leader}    ${follower_list} =    ClusterManagement.Get_Leader_And_Followers_For_Shard    shard_name=car    shard_type=config    member_index_list=${member_index_list}
120     ${leader_session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${leader}
121     BuiltIn.Set_Suite_Variable    \${new_leader_session}    ${leader_session}
122     ${sessions} =    BuiltIn.Create_List
123     : FOR    ${follower_index}    IN    @{follower_list}
124     \    ${follower_session} =    ClusterManagement.Resolve_Http_Session_For_Member    member_index=${follower_index}
125     \    Collections.Append_To_List    ${sessions}    ${follower_session}
126     BuiltIn.Set_Suite_Variable    \${new_follower_sessions}    ${sessions}
127     ${first_follower_session} =    Collections.Get_From_List    ${sessions}    0
128     BuiltIn.Set_Suite_Variable    \${new_first_follower_session}    ${first_follower_session}