Enhancements to 3-node cluster tests
[integration/test.git] / test / csit / suites / clustering / datastore / 140_recovery_restart_follower.txt
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 Library           Collections
4 Library           ../../../libraries/RequestsLibrary.py
5 Library           ../../../libraries/Common.py
6 Library           ../../../libraries/CrudLibrary.py
7 Library           ../../../libraries/SettingsLibrary.py
8 Library           ../../../libraries/UtilLibrary.py
9 Library           ../../../libraries/ClusterStateLibrary.py
10 Variables         ../../../variables/Variables.py
11
12 *** Variables ***
13 ${REST_CONTEXT}    /restconf/config/
14 ${CAR_SHARD}       shard-car-config
15 ${NUM_CARS}     ${60}
16
17 *** Test Cases *** 
18 Stop All Controllers
19     [Documentation]    Stop all the controllers in the cluster
20     StopAllControllers    ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}    ${MEMBER1}    ${MEMBER2}    ${MEMBER3}
21
22
23 Clean All Journals
24     [Documentation]    Clean the journals of all the controllers in the cluster
25     CleanJournal    ${MEMBER1}    ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}
26     CleanJournal    ${MEMBER2}    ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}
27     CleanJournal    ${MEMBER3}    ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}
28     Sleep    5
29
30 Start All Controllers
31     [Documentation]    Start all the controllers in the cluster
32     ${rc}   StartAllControllers    ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}    ${RESTCONFPORT}
33     ...    ${MEMBER1}    ${MEMBER2}    ${MEMBER3}
34     Should Be True    ${rc}
35     Sleep    3
36
37 Get car leader and followers
38     ${CURRENT_CAR_LEADER}   GetLeader   ${CAR_SHARD}   ${3}    ${3}    ${1}    ${PORT}     ${MEMBER1}   ${MEMBER2}    ${MEMBER3}
39     Set Suite Variable    ${CURRENT_CAR_LEADER}
40     ${CAR_FOLLOWERS}  GetFollowers  ${CAR_SHARD}  ${3}  ${3}  ${1}  ${PORT}  ${MEMBER1}  ${MEMBER2}  ${MEMBER3}
41     Set Suite Variable    ${CAR_FOLLOWERS}
42
43 Stop both of the followers
44     StopAllControllers    ${USER_NAME}   ${PASSWORD}   ${KARAF_HOME}   @{CAR_FOLLOWERS}[0]    @{CAR_FOLLOWERS}[1]
45
46 Attempt to add a car from the leader
47     [Documentation]    Should fail as both followers are down
48     ${resp}   AddCar  ${CURRENT_CAR_LEADER}    ${PORT}    ${1}
49     ${resp}    Getcars    ${CURRENT_CAR_LEADER}    ${PORT}    ${1}
50     Should Be Equal As Strings    ${resp.status_code}    404
51
52 Restart the first follower
53     Startcontroller    @{CAR_FOLLOWERS}[0]   ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}    ${PORT}
54     Sleep    3
55
56 Add cars from the first follower
57     ${resp}             AddCar  @{CAR_FOLLOWERS}[0]     ${PORT}    ${NUM_CARS}
58     Should Be Equal As Strings    ${resp.status_code}    204
59     ${resp}             Getcars  @{CAR_FOLLOWERS}[0]   ${PORT}   ${0}
60     Should Be Equal As Strings    ${resp.status_code}    200
61     :FOR    ${i}    IN RANGE    1    ${NUM_CARS}
62     \    Should Contain     ${resp.content}   manufacturer${i}
63
64 Restart the second follower
65     Startcontroller    @{CAR_FOLLOWERS}[1]   ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}    ${PORT}
66     Sleep    3
67
68 Get all the cars from the second follower
69     ${resp}    Getcars    @{CAR_FOLLOWERS}[1]    ${PORT}    ${0}
70     Should Be Equal As Strings    ${resp.status_code}    200
71     :FOR    ${i}    IN RANGE    1    ${NUM_CARS}
72     \    Should Contain     ${resp.content}   manufacturer${i}
73
74 Cleanup All Controllers 
75     [Documentation]    Stop all the controllers in the cluster
76     StopAllControllers    ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}    ${MEMBER1}    ${MEMBER2}    ${MEMBER3}