Refactor cluster car-people test to reduce test time in case of failure
[integration/test.git] / csit / suites / controller / Clustering_Datastore / 140_recovery_restart_follower.robot
1 *** Settings ***
2 Documentation     This test kills any of the followers and verifies that when that follower is restarted it can join the cluster
3 Default Tags      3-node-cluster
4 Library           Collections
5 Library           RequestsLibrary
6 Library           ../../../libraries/CrudLibrary.py
7 Resource          ../../../libraries/ClusterKeywords.robot
8 Resource          ../../../libraries/CarsAndPeople.robot
9 Variables         ../../../variables/Variables.py
10
11 *** Variables ***
12 ${CAR_SHARD}      shard-car-config
13 ${NUM_CARS}       ${60}
14 @{controllers}    ${CONTROLLER}    ${CONTROLLER1}    ${CONTROLLER2}
15 ${KARAF_HOME}     ${WORKSPACE}/${BUNDLEFOLDER}
16 ${START_TIMEOUT}    300s
17 ${STOP_TIMEOUT}    180s
18
19 *** Test Cases ***
20 Stop All Controllers
21     [Documentation]    Stop all the controllers in the cluster
22     Stop One Or More Controllers    @{controllers}
23     Wait For Cluster Down    ${STOP_TIMEOUT}    @{controllers}
24
25 Clean All Journals
26     [Documentation]    Clean the journals of all the controllers in the cluster
27     Clean One Or More Journals    @{controllers}
28
29 Start All Controllers
30     [Documentation]    Start all the controllers in the cluster
31     Start One Or More Controllers    @{controllers}
32     Wait For Cluster Sync    ${START_TIMEOUT}    @{controllers}
33
34 Get Car Leader And Followers
35     [Documentation]    Find leader and followers in the car shard
36     ${CURRENT_CAR_LEADER}    Get Leader And Verify    ${CAR_SHARD}
37     Set Suite Variable    ${CURRENT_CAR_LEADER}
38     ${CAR_FOLLOWERS}    Get All Followers    ${CAR_SHARD}
39     Set Suite Variable    ${CAR_FOLLOWERS}
40
41 Verify No Cars On Leader After Restart
42     [Documentation]    Verify no cars after restart
43     Wait Until Keyword Succeeds    ${START_TIMEOUT}    2s    Check Cars Deleted    ${CURRENT_CAR_LEADER}
44
45 Stop Both Of The Followers
46     [Documentation]    Stop car followers
47     @{followers} =    Create List    @{CAR_FOLLOWERS}[0]    @{CAR_FOLLOWERS}[1]
48     Stop One Or More Controllers    @{followers}
49     Wait For Cluster Down    ${STOP_TIMEOUT}    @{followers}
50
51 Attempt To Add A Car To The Leader
52     [Documentation]    Add car should fail as both followers are down
53     AddCar    ${CURRENT_CAR_LEADER}    ${RESTCONFPORT}    ${1}    500
54     Sleep    2
55     ${resp}    Getcars    ${CURRENT_CAR_LEADER}    ${RESTCONFPORT}    ${1}
56     Should Not Be Equal As Strings    ${resp.status_code}    200
57
58 Restart The First Follower
59     [Documentation]    Start one follower
60     Start One Or More Controllers    @{CAR_FOLLOWERS}[0]
61     Wait For Controller Sync    ${START_TIMEOUT}    @{CAR_FOLLOWERS}[0]
62
63 Add Cars To The First Follower
64     [Documentation]    Add cars to the follower and verify
65     Log    Adding ${NUM_CARS} cars to @{CAR_FOLLOWERS}[0]
66     Wait Until Keyword Succeeds    ${START_TIMEOUT}    2s    Add Cars And Verify Without Init    @{CAR_FOLLOWERS}[0]    ${NUM_CARS}
67
68 Restart The Second Follower
69     [Documentation]    Start another follower
70     Start One Or More Controllers    @{CAR_FOLLOWERS}[1]
71     Wait For Controller Sync    ${START_TIMEOUT}    @{CAR_FOLLOWERS}[1]
72
73 Get All The Cars From The Second Follower
74     [Documentation]    Add cars to the follower and verify
75     Wait Until Keyword Succeeds    ${START_TIMEOUT}    2s    Get Cars And Verify    @{CAR_FOLLOWERS}[1]    ${NUM_CARS}
76