Rework of controller car/people cluster suite
[integration/test.git] / csit / suites / controller / Clustering_Datastore / car_outage_corners.robot
1 *** Settings ***
2 Documentation     Cluster suite for testing minimal and sum-minimal member population behavior.
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 kills majority of the followers and verifies car addition is not possible,
12 ...               then resumes single follower (first from original list) and checks that addition works.
13 ...               Then remaining members are brought up.
14 ...               Leader member is always up and assumed to remain Leading during the whole suite run.
15 ...
16 ...               TODO: Use initial data to check more operations.
17 ...               TODO: Perhaps merge with car_failover_crud suite.
18 ...
19 ...               Other modules and Shards (people, car-people) are not accessed by this suite.
20 ...
21 ...               All data is deleted at the end of the suite.
22 ...               This suite expects car module to have a separate Shard.
23 Suite Setup       Setup
24 Default Tags      clustering    carpeople    critical
25 Library           Collections
26 Resource          ${CURDIR}/../../../libraries/CarPeople.robot
27 Resource          ${CURDIR}/../../../libraries/ClusterManagement.robot
28 Resource          ${CURDIR}/../../../libraries/TemplatedRequests.robot
29 Variables         ${CURDIR}/../../../variables/Variables.py
30
31 *** Variables ***
32 ${CAR_ITEMS}      50
33 ${MINORITY_START_I}    300
34 ${MAJORITY_START_I}    200
35 ${MEMBER_START_TIMEOUT}    300s
36 @{SHARD_NAME_LIST}    car
37 ${VAR_DIR}        ${CURDIR}/../../../variables/carpeople/crud
38
39 *** Test Cases ***
40 Kill_Majority_Of_The_Followers
41     [Documentation]    Kill half plus one car Follower members.
42     ClusterManagement.Kill_Members_From_List_Or_All    member_index_list=${list_of_killing}    confirm=True
43
44 Attempt_To_Add_Cars_To_Leader
45     [Documentation]    Adding cars should fail, as majority of Followers are down.
46     ${status}    ${message} =    BuiltIn.Run_Keyword_And_Ignore_Error    TemplatedRequests.Put_As_Json_Templated    folder=${VAR_DIR}/cars    session=${car_leader_session}    iterations=${CAR_ITEMS}
47     ...    iter_start=${MINORITY_START_I}
48     # TODO: Is there a specific status and mesage to require in this scenario?
49     BuiltIn.Should_Contain    ${message}    '50
50
51 Clean_And_Start_Tipping_Follower
52     [Documentation]    Start one Follower member without persisted data.
53     ClusterManagement.Clean_Journals_And_Snapshots_On_List_Or_All    member_index_list=${list_of_tipping}
54     ClusterManagement.Start_Members_From_List_Or_All    member_index_list=${list_of_tipping}    wait_for_sync=True    timeout=${MEMBER_START_TIMEOUT}
55     BuiltIn.Wait_Until_Keyword_Succeeds    30s    2s    ClusterManagement.Verify_Leader_Exists_For_Each_Shard    shard_name_list=${SHARD_NAME_LIST}    shard_type=config    member_index_list=${list_of_majority}
56
57 Add_Cars_On_Tipping_Follower
58     [Documentation]    Add cars on the tipping Follower.
59     TemplatedRequests.Put_As_Json_Templated    folder=${VAR_DIR}/cars    session=${car_first_follower_session}    iterations=${CAR_ITEMS}    iter_start=${MAJORITY_START_I}
60
61 See_Cars_On_Existing_Members
62     [Documentation]    On each up member: GET cars, should match the ones added on tipping Follower.
63     : FOR    ${session}    IN    @{list_of_majority}
64     \    TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/cars    session=${session}    verify=True    iterations=${CAR_ITEMS}    iter_start=${MAJORITY_START_I}
65
66 Clean_And_Start_Other_Followers
67     [Documentation]    Start other followers without persisted data.
68     ClusterManagement.Start_Members_From_List_Or_All    member_index_list=${list_of_reviving}    wait_for_sync=True    timeout=${MEMBER_START_TIMEOUT}
69     BuiltIn.Wait_Until_Keyword_Succeeds    30s    2s    ClusterManagement.Verify_Leader_Exists_For_Each_Shard    shard_name_list=${SHARD_NAME_LIST}    shard_type=config
70
71 See_Cars_On_New_Follower_Leader
72     [Documentation]    GET cars from a new follower to see that the current state was replicated.
73     TemplatedRequests.Get_As_Json_Templated    folder=${VAR_DIR}/cars    session=${car_last_follower_session}    verify=True    iterations=${CAR_ITEMS}    iter_start=${MAJORITY_START_I}
74
75 Delete_Cars_On_Leader
76     [Documentation]    Delete cars on Leader.
77     TemplatedRequests.Delete_Templated    folder=${VAR_DIR}/cars    session=${car_leader_session}
78
79 *** Keywords ***
80 Setup
81     [Documentation]    Initialize resources, memorize shard leaders, pre-compute member lists.
82     ClusterManagement.ClusterManagement_Setup
83     CarPeople.Set_Variables_For_Shard    shard_name=car
84     Set_Additional_Variables
85
86 Set_Additional_Variables
87     [Documentation]    Compute various lists useful for test cases in this suite.
88     # TODO: Migrate this Keyword to CarPeople Resource if more suites want that.
89     ${last_follower_session} =    Collections.Get_From_List    ${car_follower_sessions}    -1
90     BuiltIn.Set_Suite_Variable    \${car_last_follower_session}    ${last_follower_session}
91     ${number_followers} =    BuiltIn.Get_Length    ${car_follower_indices}
92     ${half_followers} =    BuiltIn.Evaluate    ${number_followers} / 2
93     ${majority_follower_list} =    Collections.Get_Slice_From_List    ${car_follower_indices}    0    ${half_followers}
94     ${leader_list} =    BuiltIn.Create_List    ${car_leader_index}
95     ${majority_list} =    Collections.Combine_Lists    ${leader_list}    ${majority_follower_list}
96     BuiltIn.Set_Suite_Variable    \${list_of_majority}    ${majority_list}
97     ${tipping_list} =    Collections.Get_Slice_From_List    ${majority_follower_list}    0    1
98     BuiltIn.Set_Suite_Variable    \${list_of_tipping}    ${tipping_list}
99     ${revive_list} =    Collections.Get_Slice_From_List    ${car_follower_indices}    ${half_followers}    ${number_followers}
100     BuiltIn.Set_Suite_Variable    \${list_of_reviving}    ${revive_list}
101     ${kill_list} =    Collections.Combine_Lists    ${tipping_list}    ${revive_list}
102     BuiltIn.Set_Suite_Variable    \${list_of_killing}    ${kill_list}