Merge "Changed the body of flows."
authorLuis Gomez <ecelgp@gmail.com>
Mon, 5 Jan 2015 01:52:22 +0000 (01:52 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 5 Jan 2015 01:52:22 +0000 (01:52 +0000)
test/csit/libraries/ClusterKeywords.txt [new file with mode: 0644]
test/csit/libraries/CrudLibrary.py
test/csit/suites/clustering/datastore/001_start_cluster.txt
test/csit/suites/clustering/datastore/010_crud_on_leader.txt
test/csit/suites/clustering/datastore/020_crud_on_any_follower.txt
test/csit/suites/clustering/datastore/030_car_failover_crud_on_new_leader.txt
test/csit/suites/clustering/datastore/040_people_failover_crud_on_new_leader.txt
test/csit/suites/clustering/datastore/050_car_persistence_recovery.txt
test/csit/suites/clustering/datastore/140_recovery_restart_follower.txt
test/csit/suites/clustering/datastore/999_cleanup.txt [new file with mode: 0644]

diff --git a/test/csit/libraries/ClusterKeywords.txt b/test/csit/libraries/ClusterKeywords.txt
new file mode 100644 (file)
index 0000000..6e87be5
--- /dev/null
@@ -0,0 +1,123 @@
+*** Settings ***
+
+*** Variables ***
+
+*** Keywords ***
+Get Leader And Verify
+    [Arguments]   ${shard_name}  ${old_leader}=${EMPTY}
+    ${leader}   GetLeader   ${shard_name}  ${3}  ${3}  ${1}  ${PORT}  ${MEMBER1}  ${MEMBER2}  ${MEMBER3}
+    Should Not Be Equal As Strings   ${leader}   None
+    Run Keyword If  '${old_leader}'!='${EMPTY}'  Should Not Be Equal  ${old_leader}  ${leader}
+    [Return]   ${leader}
+
+Wait For Leader
+    [Arguments]   ${shard_name}
+    ${leader}   Wait Until Keyword Succeeds   60s  2s  Get Leader And Verify  ${shard_name}
+    Log   ${leader}
+    [Return]   ${leader}
+
+Switch Leader
+    [Arguments]   ${shard_name}  ${current_leader}
+    StopController  ${current_leader}  ${USERNAME}  ${PASSWORD}  ${KARAFHOME}
+    ${new_leader}  Wait Until Keyword Succeeds   60s  2s  Get Leader And Verify  ${shard_name}  ${current_leader}
+    Log   ${new_leader}
+    [Return]   ${new_leader}
+
+Get All Followers
+    [Arguments]   ${shard_name}
+    ${followers}  GetFollowers  ${shard_name}  ${3}  ${3}  ${1}  ${PORT}  ${MEMBER1}  ${MEMBER2}  ${MEMBER3}
+    Log  ${followers}
+    Should Not Be Empty  ${followers}
+    [Return]  ${followers}
+
+Add Cars And Verify
+    [Arguments]    ${controller_ip}    ${num_cars}  ${timeout}=60s
+    ${resp}   AddCar   ${controller_ip}   ${PORT}   ${num_cars}
+    Should Be Equal As Strings    ${resp.status_code}    204
+    Wait Until Keyword Succeeds   ${timeout}  2s  Get Cars And Verify   ${controller_ip}  ${num_cars}
+
+Get Cars And Verify
+    [Arguments]    ${controller_ip}    ${num_cars}
+    ${resp}     Getcars  ${controller_ip}   ${PORT}  ${0}
+    Should Be Equal As Strings    ${resp.status_code}    200
+    :FOR    ${i}    IN RANGE    1    ${num_cars}
+    \    Should Contain     ${resp.content}   manufacturer${i}
+
+Add People And Verify
+    [Arguments]    ${controller_ip}    ${num_people}
+    [Documentation]  Note: The first AddPerson call passed with 0 posts directly to the data store to get
+    [Documentation]  the people container created so the subsequent AddPerson RPC calls that put 
+    [Documentation]  to the person list will succeed.
+    ${resp}  AddPerson  ${controller_ip}  ${PORT}  ${0}
+    Should Be Equal As Strings  ${resp.status_code}  204
+    Wait Until Keyword Succeeds   60s  2s  Get One Person And Verify  ${controller_ip}  ${0}
+    ${resp}  AddPerson   ${controller_ip}    ${PORT}  ${num_people}
+    Wait Until Keyword Succeeds   60s  2s  Get People And Verify  ${controller_ip}  ${num_people}
+
+Get One Person And Verify
+    [Arguments]    ${controller_ip}    ${number}
+    ${resp}     GetPersons  ${controller_ip}    ${PORT}  ${0}
+    Should Be Equal As Strings    ${resp.status_code}    200
+    Should Contain   ${resp.content}   user${number}
+
+Get People And Verify
+    [Arguments]    ${controller_ip}    ${num_people}
+    ${resp}     GetPersons  ${controller_ip}    ${PORT}  ${0}
+    Should Be Equal As Strings    ${resp.status_code}    200
+    :FOR    ${i}    IN RANGE    1    ${num_people}
+    \    Should Contain     ${resp.content}   user${i}
+
+Add Car Person And Verify
+    [Arguments]    ${controller_ip}
+    [Documentation]  Add a car-person via the data store and get the car-person from Leader.
+    [Documentation]  Note: This is done to get the car-people container created so subsequent BuyCar
+    [Documentation]  RPC puts to the car-person list will succeed.
+    AddCarPerson    ${controller_ip}   ${PORT}     ${0}
+    Wait Until Keyword Succeeds   60s  2s  Get One Car-Person Mapping And Verify  ${controller_ip}   ${0}
+
+Get One Car-Person Mapping And Verify
+    [Arguments]    ${controller_ip}    ${number}
+    ${resp}     GetCarPersonMappings    ${controller_ip}   ${PORT}     ${0}
+    Should Be Equal As Strings    ${resp.status_code}    200
+    Should Contain     ${resp.content}   user${number}
+
+Get Car-Person Mappings And Verify
+    [Arguments]    ${controller_ip}    ${num_entries}
+    ${resp}     GetCarPersonMappings    ${controller_ip}    ${PORT}  ${0}
+    Should Be Equal As Strings    ${resp.status_code}    200
+    :FOR    ${i}    IN RANGE    1    ${num_entries}
+    \    Should Contain     ${resp.content}   user${i}
+
+Buy Cars And Verify
+    [Arguments]    ${controller_ip}    ${num_entries}   ${start}=${0}
+    Wait Until Keyword Succeeds   60s  2s  BuyCar  ${controller_ip}   ${PORT}    ${num_entries}   ${start}
+
+Check Cars Deleted
+    [Arguments]    ${controller_ip}
+    ${resp}    Getcars    ${controller_ip}    ${PORT}    ${0}
+    Should Be Equal As Strings    ${resp.status_code}    404
+
+Delete All Cars And Verify
+    [Arguments]    ${controller_ip}
+    DeleteAllCars    ${controller_ip}    ${PORT}    ${0}
+    Wait Until Keyword Succeeds   60s  2s  Check Cars Deleted  ${controller_ip}
+
+Check People Deleted
+    [Arguments]    ${controller_ip}
+    ${resp}    GetPersons    ${controller_ip}    ${PORT}    ${0}
+    Should Be Equal As Strings    ${resp.status_code}    404
+
+Delete All People And Verify
+    [Arguments]    ${controller_ip}
+    DeleteAllPersons    ${controller_ip}    ${PORT}    ${0}
+    Wait Until Keyword Succeeds   60s  2s  Check People Deleted  ${controller_ip}
+
+Check Cars-Persons Deleted
+    [Arguments]    ${controller_ip}
+    ${resp}    GetCarPersonMappings    ${controller_ip}    ${PORT}    ${0}
+    Should Be Equal As Strings    ${resp.status_code}    404
+
+Delete All Cars-Persons And Verify
+    [Arguments]    ${controller_ip}
+    DeleteAllCarsPersons    ${controller_ip}    ${PORT}    ${0}
+    Wait Until Keyword Succeeds   60s  2s  Check Cars-Persons Deleted  ${controller_ip}
index 62fd4d5a60f26cf55e3b27cabe1d3f250d714587..1d8d54999fc78dcac682c6515cd1f42181ec6a69 100644 (file)
@@ -119,23 +119,23 @@ def addCarPerson(hostname,port,numberOfCarPersons):
 # </note>
 #
 
-def buyCar(hostname,port,numberOfCarBuyers):
-    for x in range(1, numberOfCarBuyers+1):
-        strId = str(x)
+def buyCar(hostname,port,numberOfCarBuyers,start=0):
+    for x in range(start, start+numberOfCarBuyers):
+        strId = str(x+1)
 
         payload = SettingsLibrary.buy_car_rpc_template.substitute(personId="user"+strId,carId=strId)
 
         # Send the POST request using RPC
         resp = UtilLibrary.post(SettingsLibrary.getBuyCarRpcUrl(hostname,port),"admin", "admin",payload)
 
-        print("payload formed after template substitution=")
-        print(payload)
-
-        print("the response of the POST to buycar=")
         print(resp)
+        print(resp.text)
+        
+        if (resp.status_code != 204):
+            return False
 
-    print("getting the car_persons for verification")
-    resp=getCarPersonMappings(hostname,port,0)
+
+    return True
 
 
 #
index 910230ec2a496e434422eec0685b73f8ab92c813..fdfcbed013609eb75c622a97fff492793c8d495a 100644 (file)
@@ -1,5 +1,7 @@
 *** Settings ***
 Documentation     Start the controllers
+Default Tags  3-node-cluster
+
 Library           Collections
 Library           ../../../libraries/RequestsLibrary.py
 Library           ../../../libraries/Common.py
index e929c86a8fa42f655123462a99db3e87e61c7783..795f2298ade208d40374acb81f42cb90f54a6d25 100644 (file)
@@ -1,5 +1,6 @@
 *** Settings ***
 Documentation     This test finds the leader for shards in a 3-Node cluster and executes CRUD operations on them
+Default Tags  3-node-cluster
 
 Library           Collections
 Library           ../../../libraries/RequestsLibrary.py
@@ -8,6 +9,7 @@ Library           ../../../libraries/CrudLibrary.py
 Library           ../../../libraries/SettingsLibrary.py
 Library           ../../../libraries/UtilLibrary.py
 Library           ../../../libraries/ClusterStateLibrary.py
+Resource           ../../../libraries/ClusterKeywords.txt
 Variables         ../../../variables/Variables.py
 
 
@@ -19,83 +21,78 @@ ${SHARD_CAR_PERSON_NAME}      shard-car-people-config
 ${NUM_ENTRIES}  ${30}
 
 *** Test Cases ***
+Get Car Leader And Followers
+    ${CURRENT_CAR_LEADER}   Wait For Leader   ${SHARD_CAR_NAME}
+    Set Suite Variable  ${CURRENT_CAR_LEADER}
+    ${CAR_FOLLOWERS}   Get All Followers   ${SHARD_CAR_NAME}
+    Set Suite Variable  ${CAR_FOLLOWERS}
+
 Add cars and get cars from Leader
     [Documentation]    Add some cars and get added cars from Leader
-    ${CURRENT_CAR_LEADER}   GetLeader   ${SHARD_CAR_NAME}   ${3}    ${3}    ${1}    ${PORT}     ${MEMBER1}   ${MEMBER2}    ${MEMBER3}
-    Log    CURRENT_CAR_SHARD_LEADER ${CURRENT_CAR_LEADER}
-    Should Not Be Equal As Strings   ${CURRENT_CAR_LEADER}   None
-    Set Suite Variable  ${CURRENT_CAR_LEADER}
-    ${resp}            AddCar  ${CURRENT_CAR_LEADER}   ${PORT} ${NUM_ENTRIES}
-    ${resp}            Getcars ${CURRENT_CAR_LEADER}   ${PORT} ${0}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    :FOR    ${i}    IN RANGE    1    ${NUM_ENTRIES}
-    \    Should Contain     ${resp.content}   manufacturer${i}
-    
-Get added cars using Follower1
-   [Documentation]   Get added cars using Follower1 
-   ${FOLLOWERS}   GetFollowers   ${SHARD_CAR_PERSON_NAME}   ${3}    ${3}    ${1}    ${PORT}     ${MEMBER1}   ${MEMBER2}    ${MEMBER3}
-   Log          ${FOLLOWERS}
-   SET SUITE VARIABLE  ${FOLLOWERS}
-   ${resp}             Getcars  @{FOLLOWERS}[0]  ${PORT}  ${0}
-   Should Be Equal As Strings    ${resp.status_code}    200
-   :FOR    ${i}    IN RANGE    1    ${NUM_ENTRIES}
-   \    Should Contain     ${resp.content}   manufacturer${i}
-
-Get added cars using Follower2
-   [Documentation]   Get added cars using Follower2
-   ${resp}             Getcars  @{FOLLOWERS}[1]  ${PORT}  ${0}
-   Should Be Equal As Strings    ${resp.status_code}    200
-   :FOR    ${i}    IN RANGE    1    ${NUM_ENTRIES}
-   \    Should Contain     ${resp.content}   manufacturer${i}
-
-Add persons and get persons from Leader
-    [Documentation]    Add some persons and get persons
-    [Documentation]    Note: There should be one person added first to enable rpc
-    ${CURRENT_PEOPLE_LEADER}   GetLeader   ${SHARD_PEOPLE_NAME}   ${3}    ${3}    ${1}    ${PORT}     ${MEMBER1}   ${MEMBER2}    ${MEMBER3}
-    Log    CURRENT_PEOPLE_SHARD_LEADER ${CURRENT_PEOPLE_LEADER}
-    Should Not Be Equal As Strings   ${CURRENT_PEOPLE_LEADER}   None
+    Add Cars And Verify   ${CURRENT_CAR_LEADER}  ${NUM_ENTRIES}
+
+Get added cars from Follower1
+    [Documentation]   Get added cars from Follower1 
+    Wait Until Keyword Succeeds   60s  2s  Get Cars And Verify   @{CAR_FOLLOWERS}[0]   ${NUM_ENTRIES}
+
+Get added cars from Follower2
+    [Documentation]   Get added cars from Follower2
+    Wait Until Keyword Succeeds   60s  2s  Get Cars And Verify   @{CAR_FOLLOWERS}[1]    ${NUM_ENTRIES}
+
+Get People Leader And Followers
+    ${CURRENT_PEOPLE_LEADER}   Wait For Leader   ${SHARD_PEOPLE_NAME}
     Set Suite Variable  ${CURRENT_PEOPLE_LEADER}
-    ${resp}            AddPerson       ${CURRENT_PEOPLE_LEADER}        ${PORT} ${0}
-    Should Be Equal As Strings    ${resp.status_code}    204
-    ${resp}            AddPerson       ${CURRENT_PEOPLE_LEADER}        ${PORT} ${NUM_ENTRIES}
-    ${resp}            GetPersons      ${CURRENT_PEOPLE_LEADER}        ${PORT} ${0}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    :FOR    ${i}    IN RANGE    1    ${NUM_ENTRIES}
-    \    Should Contain     ${resp.content}   user${i}
+    ${PEOPLE_FOLLOWERS}   Get All Followers   ${SHARD_PEOPLE_NAME}
+    Set Suite Variable  ${PEOPLE_FOLLOWERS}
 
-Add car-person mapping and get car-person mapping from Leader
-    [Documentation]    Add car-person and get car-person from Leader
-    [Documentation]  Note: This is done to enable working of rpc
-    ${CURRENT_CAR_PERSON_LEADER}   GetLeader   ${SHARD_CAR_PERSON_NAME}   ${3}    ${3}    ${1}    ${PORT}     ${MEMBER1}   ${MEMBER2}  ${MEMBER3}
+Add people and get people from Leader
+    [Documentation]    Add some people and get people from Leader.
+    Add People And Verify   ${CURRENT_PEOPLE_LEADER}   ${NUM_ENTRIES}
+
+Get added people from Follower1
+   [Documentation]   Get added people from Follower1
+   Wait Until Keyword Succeeds   60s  2s  Get People And Verify   @{PEOPLE_FOLLOWERS}[0]    ${NUM_ENTRIES}
+
+Get added people from Follower2
+   [Documentation]   Get added people from Follower2
+   Wait Until Keyword Succeeds   60s  2s  Get People And Verify   @{PEOPLE_FOLLOWERS}[1]    ${NUM_ENTRIES}
+
+Get Car-Person Leader And Followers
+    ${CURRENT_CAR_PERSON_LEADER}   Wait For Leader   ${SHARD_CAR_PERSON_NAME}
     Set Suite Variable  ${CURRENT_CAR_PERSON_LEADER}
-       ${resp}         AddCarPerson    ${CURRENT_CAR_PERSON_LEADER}   ${PORT}     ${0}
-       Sleep       5
-       ${resp}         GetCarPersonMappings    ${CURRENT_CAR_PERSON_LEADER}   ${PORT}     ${0}
-       Should Be Equal As Strings    ${resp.status_code}    200
-       Should Contain     ${resp.content}   user0
-
-Purchase cars using Leader
-    [Documentation]  Purchase some cars using Leader
-    ${resp}            BuyCar  ${CURRENT_CAR_PERSON_LEADER}    ${PORT} ${NUM_ENTRIES}
-    Sleep       5
-
-Get car-person mappings using Leader
-   [Documentation]     Get car-person mappings using Leader to see 100 entry
-   ${resp}             GetCarPersonMappings    ${CURRENT_CAR_PERSON_LEADER}    ${PORT} ${0}
-   Should Be Equal As Strings    ${resp.status_code}    200
-   :FOR    ${i}    IN RANGE    1    ${NUM_ENTRIES}
-   \    Should Contain     ${resp.content}   user${i}
-
-Get car-person mappings using Follower1
-   [Documentation]     Get car-person mappings using Follower1 to see 100 entry
-   ${resp}             GetCarPersonMappings    @{FOLLOWERS}[0]     ${PORT}     ${0}
-   Should Be Equal As Strings    ${resp.status_code}    200
-   :FOR    ${i}    IN RANGE    1    ${NUM_ENTRIES}
-   \    Should Contain     ${resp.content}   user${i}
-
-Get car-person mappings using Follower2
-   [Documentation]     Get car-person mappings using Follower2 to see 100 entry
-   ${resp}             GetCarPersonMappings    @{FOLLOWERS}[1]     ${PORT}     ${0}
-   Should Be Equal As Strings    ${resp.status_code}    200
-   :FOR    ${i}    IN RANGE    1    ${NUM_ENTRIES}
-   \    Should Contain     ${resp.content}   user${i}
+    ${CAR_PERSON_FOLLOWERS}   Get All Followers   ${SHARD_CAR_PERSON_NAME}
+    Set Suite Variable  ${CAR_PERSON_FOLLOWERS}
+
+Add car-person mapping and get car-person mapping from Leader
+    Add Car Person And Verify   ${CURRENT_CAR_PERSON_LEADER}
+
+Purchase cars on Leader
+    [Documentation]  Purchase some cars on the Leader
+    ${NUM_BUY_CARS_ON_LEADER}   Evaluate  ${NUM_ENTRIES}/3
+    ${NUM_BUY_CARS_ON_FOLLOWER1}   Evaluate  ${NUM_ENTRIES}/3
+    ${NUM_BUY_CARS_ON_FOLLOWER2}   Evaluate  ${NUM_ENTRIES}-${NUM_BUY_CARS_ON_LEADER}-${NUM_BUY_CARS_ON_FOLLOWER1}
+    Set Suite Variable   ${NUM_BUY_CARS_ON_LEADER}
+    Set Suite Variable   ${NUM_BUY_CARS_ON_FOLLOWER1}
+    Set Suite Variable   ${NUM_BUY_CARS_ON_FOLLOWER2}
+    Buy Cars And Verify        ${CURRENT_CAR_PERSON_LEADER}   ${NUM_BUY_CARS_ON_LEADER}
+
+Purchase cars on Follower1
+    [Documentation]  Purchase some cars on Follower1
+    Buy Cars And Verify  @{CAR_PERSON_FOLLOWERS}[0]   ${NUM_BUY_CARS_ON_FOLLOWER1}   ${NUM_BUY_CARS_ON_LEADER}
+
+Purchase cars on Follower2
+    [Documentation]  Purchase some cars on Follower2
+    ${start}    Evaluate    ${NUM_BUY_CARS_ON_LEADER}+${NUM_BUY_CARS_ON_FOLLOWER1}
+    Buy Cars And Verify  @{CAR_PERSON_FOLLOWERS}[1]   ${NUM_BUY_CARS_ON_FOLLOWER2}   ${start}
+
+Get car-person mappings from Leader
+   [Documentation]     Get car-person mappings from Leader to see all entries
+   Wait Until Keyword Succeeds   60s  2s  Get Car-Person Mappings And Verify   ${CURRENT_CAR_PERSON_LEADER}  ${NUM_ENTRIES} 
+
+Get car-person mappings from Follower1
+   [Documentation]     Get car-person mappings from Follower1 to see all entries
+   Wait Until Keyword Succeeds   60s  2s  Get Car-Person Mappings And Verify   @{CAR_PERSON_FOLLOWERS}[0]  ${NUM_ENTRIES}
+
+Get car-person mappings from Follower2
+   [Documentation]     Get car-person mappings from Follower2 to see all entries
+   Wait Until Keyword Succeeds   60s  2s  Get Car-Person Mappings And Verify   @{CAR_PERSON_FOLLOWERS}[1]  ${NUM_ENTRIES}
index 5e177387f234df2f0d90fcce0d9f8febf289b430..f22eb1d646817bfa5db73ebf0f81c49bbd66f3dc 100644 (file)
@@ -1,5 +1,6 @@
 *** Settings ***
 Documentation     This test finds the followers of certain shards in a 3-Node cluster and executes CRUD operations on any one follower
+Default Tags  3-node-cluster
 
 Library           Collections
 Library           ../../../libraries/RequestsLibrary.py
@@ -8,6 +9,7 @@ Library           ../../../libraries/CrudLibrary.py
 Library           ../../../libraries/SettingsLibrary.py
 Library           ../../../libraries/UtilLibrary.py
 Library           ../../../libraries/ClusterStateLibrary.py
+Resource           ../../../libraries/ClusterKeywords.txt
 Variables         ../../../variables/Variables.py
 
 *** Variables ***
@@ -19,96 +21,58 @@ ${NUM_ENTRIES}  ${40}
 
 *** Test Cases ***
 Get Car Followers
-    ${CAR_FOLLOWERS}   GetFollowers   ${SHARD_CAR_NAME}   ${3}    ${3}    ${1}    ${PORT}     ${MEMBER1}   ${MEMBER2}    ${MEMBER3}
-    Log    ${CAR_FOLLOWERS}
-    SET SUITE VARIABLE  ${CAR_FOLLOWERS}
+    ${CAR_FOLLOWERS}   Get All Followers   ${SHARD_CAR_NAME}
+    Set Suite Variable  ${CAR_FOLLOWERS}
 
 Get People Followers
-    ${PEOPLE_FOLLOWERS}   GetFollowers   ${SHARD_PEOPLE_NAME}   ${3}    ${3}    ${1}    ${PORT}     ${MEMBER1}   ${MEMBER2}    ${MEMBER3}
-    Log    ${PEOPLE_FOLLOWERS}
-    SET SUITE VARIABLE  ${PEOPLE_FOLLOWERS}
+    ${PEOPLE_FOLLOWERS}   Get All Followers   ${SHARD_PEOPLE_NAME}
+    Set Suite Variable  ${PEOPLE_FOLLOWERS}
 
 Get Car-Person Followers
-    ${CAR_PERSON_FOLLOWERS}   GetFollowers   ${SHARD_CAR_NAME}   ${3}    ${3}    ${1}    ${PORT}     ${MEMBER1}   ${MEMBER2}    ${MEMBER3}
-    Log    ${CAR_PERSON_FOLLOWERS}
-    SET SUITE VARIABLE  ${CAR_PERSON_FOLLOWERS}
+    ${CAR_PERSON_FOLLOWERS}   Get All Followers   ${SHARD_CAR_PERSON_NAME}
+    Set Suite Variable  ${CAR_PERSON_FOLLOWERS}
 
 Delete cars from Follower1
-    DeleteAllCars    @{CAR_FOLLOWERS}[0]    ${PORT}    ${0}
-    ${resp}    Getcars    @{CAR_FOLLOWERS}[0]    ${PORT}    ${0}
-    Should Be Equal As Strings    ${resp.status_code}    404
+    Delete All Cars And Verify    @{CAR_FOLLOWERS}[0]
 
 Delete people from Follower1
-    DeleteAllPersons    @{PEOPLE_FOLLOWERS}[0]    ${PORT}    ${0}
-    ${resp}         GetPersons      @{PEOPLE_FOLLOWERS}[0]   ${PORT}    ${0}
-    Should Be Equal As Strings    ${resp.status_code}    404
+    Delete All People And Verify   @{PEOPLE_FOLLOWERS}[0]
 
 Delete car-persons from Follower1
-    DeleteAllCarsPersons    @{CAR_PERSON_FOLLOWERS}[0]    ${PORT}    ${0}
-    ${resp}         GetCarPersonMappings      @{CAR_PERSON_FOLLOWERS}[0]   ${PORT}    ${0}
-    Should Be Equal As Strings    ${resp.status_code}    404
+    Delete All Cars-Persons And Verify    @{CAR_PERSON_FOLLOWERS}[0]
 
 Add cars and get cars from Follower1
     [Documentation]    Add cars and get added cars from Follower1
-    ${resp}            AddCar  @{CAR_FOLLOWERS}[0]     ${PORT} ${NUM_ENTRIES}
-    ${resp}            Getcars @{CAR_FOLLOWERS}[0]     ${PORT} ${0}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    :FOR    ${i}    IN RANGE    1    ${NUM_ENTRIES}
-    \    Should Contain     ${resp.content}   manufacturer${i}
-
-Get added cars using Follower2
-   [Documentation]   Get added cars using Follower2
-   ${resp}             Getcars  @{CAR_FOLLOWERS}[1]  ${PORT}  ${0}
-   Should Be Equal As Strings    ${resp.status_code}    200
-   :FOR    ${i}    IN RANGE    1    ${NUM_ENTRIES}
-   \    Should Contain     ${resp.content}   manufacturer${i}
-
-Add persons and get persons from Follower1
-    [Documentation]    Add persons and get persons from Follower1
-    [Documentation]    Note: There should be one person added first to enable rpc
-    ${resp}            AddPerson       @{PEOPLE_FOLLOWERS}[0]  ${PORT} ${0}
-    ${resp}            AddPerson       @{PEOPLE_FOLLOWERS}[0]  ${PORT} ${NUM_ENTRIES}
-    Sleep               5
-    ${resp}            GetPersons      @{PEOPLE_FOLLOWERS}[0]  ${PORT} ${0}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    :FOR    ${i}    IN RANGE    1    ${NUM_ENTRIES}
-    \    Should Contain     ${resp.content}   user${i}
+    Add Cars And Verify   @{CAR_FOLLOWERS}[0]   ${NUM_ENTRIES}
 
-Add car-person mapping and get car-person mapping from Follower1
-    [Documentation]    Add car-person and get car-person from Follower1
-    [Documentation]    Note: This is done to enable working of rpc
+Get added cars from Follower2
+    [Documentation]   Get added cars from Follower2
+    Wait Until Keyword Succeeds   60s  2s  Get Cars And Verify   @{CAR_FOLLOWERS}[1]   ${NUM_ENTRIES}
+
+Add people and get people from Follower1
+    [Documentation]  Add people and get people from Follower1
+    Add People And Verify   @{PEOPLE_FOLLOWERS}[0]   ${NUM_ENTRIES}
 
-    ${resp}            AddCarPerson    @{CAR_PERSON_FOLLOWERS}[0]      ${PORT} ${0}
-    Sleep    1
-    ${resp}            GetCarPersonMappings    @{CAR_PERSON_FOLLOWERS}[0]      ${PORT} ${0}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    Should Contain     ${resp.content}   user0
+Get added people from Follower2
+    [Documentation]   Get added people from Follower2
+    Wait Until Keyword Succeeds   60s  2s  Get People And Verify   @{PEOPLE_FOLLOWERS}[1]    ${NUM_ENTRIES}
+
+Add car-person mapping and get car-person mapping from Follower1
+    Add Car Person And Verify   @{CAR_PERSON_FOLLOWERS}[0]
 
-Purchase cars using Follower1
+Purchase cars on Follower1
     [Documentation]  Purchase cars using Follower1
-    ${resp}            BuyCar  @{CAR_PERSON_FOLLOWERS}[0]      ${PORT} ${NUM_ENTRIES}
-    Sleep   5
-
-Get car-person mappings using Follower1
-    [Documentation]    Get car-person mappings using follower1 to see 100 entry
-    ${resp}            GetCarPersonMappings    @{CAR_PERSON_FOLLOWERS}[0]      ${PORT} ${0}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    :FOR    ${i}    IN RANGE    1    ${NUM_ENTRIES}
-    \    Should Contain     ${resp.content}   user${i}
-
-Get car-person mappings using Leader
-    [Documentation]    Get car-person mappings using Leader to see 100 entry
-    ${CURRENT_CAR_LEADER}   GetLeader   ${SHARD_CAR_PERSON_NAME}   ${3}    ${3}    ${1}    ${PORT}     ${MEMBER1}   ${MEMBER2}    ${MEMBER3}
-    Log     ${CURRENT_CAR_LEADER}
-    Sleep   1
-    ${resp}            GetCarPersonMappings    ${CURRENT_CAR_LEADER}   ${PORT} ${0}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    :FOR    ${i}    IN RANGE    1    ${NUM_ENTRIES}
-    \    Should Contain     ${resp.content}   user${i}
-
-Get car-person mappings using Follower2
-    [Documentation]    Get car-person mappings using Follower2 to see 100 entry
-    ${resp}            GetCarPersonMappings    @{CAR_PERSON_FOLLOWERS}[1]      ${PORT} ${0}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    :FOR    ${i}    IN RANGE    1    ${NUM_ENTRIES}
-    \    Should Contain     ${resp.content}   user${i}
+    Buy Cars And Verify   @{CAR_PERSON_FOLLOWERS}[0]   ${NUM_ENTRIES}
+
+Get car-person mappings from Follower1
+    [Documentation]    Get car-person mappings from Follower1 to see all entries
+    Wait Until Keyword Succeeds   60s  2s  Get Car-Person Mappings And Verify   @{CAR_PERSON_FOLLOWERS}[0]  ${NUM_ENTRIES}
+
+Get car-person mappings from Leader
+    [Documentation]    Get car-person mappings from the Leader to see all entries
+    ${CURRENT_CAR_LEADER}   Wait For Leader   ${SHARD_CAR_PERSON_NAME}
+    Wait Until Keyword Succeeds   60s  2s  Get Car-Person Mappings And Verify   ${CURRENT_CAR_LEADER}  ${NUM_ENTRIES}
+
+Get car-person mappings from Follower2
+    [Documentation]    Get car-person mappings from Follower2 to see all entries
+    Wait Until Keyword Succeeds   60s  2s  Get Car-Person Mappings And Verify   @{CAR_PERSON_FOLLOWERS}[1]  ${NUM_ENTRIES}
index 77f865c92db0ac0942be9e18ece3ecfffc7d07fb..7de7160a4e0a85f1a56c47816236f2bb932c2605 100644 (file)
@@ -1,8 +1,11 @@
 *** Settings ***
 Documentation     This test brings down the current leader of the "car" shard and then executes CRUD operations on the new leader
+Default Tags  3-node-cluster
+
 Library           ../../../libraries/CrudLibrary.py
 Library           ../../../libraries/UtilLibrary.py
 Library           ../../../libraries/ClusterStateLibrary.py
+Resource           ../../../libraries/ClusterKeywords.txt
 
 *** Variables ***
 ${CAR_SHARD}      shard-car-config
@@ -11,93 +14,53 @@ ${NUM_ORIG_CARS}  ${10}
 
 *** Test Cases ***
 Get old car leader
-    ${OLD_CAR_LEADER}    GetLeader  ${CAR_SHARD}  ${3}  ${3}  ${2}  ${PORT}  ${MEMBER1}  ${MEMBER2}  ${MEMBER3}
-    Should Not Be Equal As Strings   ${OLD_CAR_LEADER}   None
+    ${OLD_CAR_LEADER}    Wait For Leader  ${CAR_SHARD}
     Set Suite Variable    ${OLD_CAR_LEADER}
 
 Delete cars on old leader
-    DeleteAllCars  ${OLD_CAR_LEADER}  ${PORT}  ${0}
-    ${resp}     Getcars   ${OLD_CAR_LEADER}   ${PORT}   ${0}
-    Should Be Equal As Strings    ${resp.status_code}    404
+    Delete All Cars And Verify   ${OLD_CAR_LEADER}
+
 Add original cars on old leader
-    ${resp}             AddCar    ${OLD_CAR_LEADER}   ${PORT}   ${NUM_ORIG_CARS}
-    ${resp}             Getcars   ${OLD_CAR_LEADER}   ${PORT}   ${0}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    :FOR    ${i}    IN RANGE    1    ${NUM_ORIG_CARS}
-    \    Should Contain     ${resp.content}   manufacturer${i}
+    Add Cars And Verify  ${OLD_CAR_LEADER}  ${NUM_ORIG_CARS}
 
 Switch car leader
-  [Documentation]    stop leader and elect new leader
-  Stopcontroller  ${OLD_CAR_LEADER}  ${USERNAME}  ${PASSWORD}  ${KARAFHOME}
-  Sleep    3
-  ${NEW_CAR_LEADER}    GetLeader  ${CAR_SHARD}  ${3}  ${3}  ${2}  ${PORT}  ${MEMBER1}  ${MEMBER2}  ${MEMBER3}
-  Log  ${NEW_CAR_LEADER}
-  Should Not Be Equal As Strings   ${NEW_CAR_LEADER}   None
-  Should Not Be Equal    ${OLD_CAR_LEADER}    ${NEW_CAR_LEADER}
-  Set Suite Variable   ${NEW_CAR_LEADER}
+    [Documentation]  Stop the leader to cause a new leader to be elected
+    ${NEW_CAR_LEADER}  Switch Leader  ${CAR_SHARD}  ${OLD_CAR_LEADER}
+    Set Suite Variable ${NEW_CAR_LEADER}
 
 Get original cars on new leader
-    ${resp}             Getcars   ${NEW_CAR_LEADER}   ${PORT}   ${0}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    :FOR    ${i}    IN RANGE    1    ${NUM_ORIG_CARS}
-    \    Should Contain     ${resp.content}   manufacturer${i}
+    Wait Until Keyword Succeeds   60s  2s  Get Cars And Verify   ${NEW_CAR_LEADER}   ${NUM_ORIG_CARS}
 
-Delete cars at new leader
-    [Documentation]    delete cars
-  DeleteAllCars         ${NEW_CAR_LEADER}  ${PORT}  ${0}
-  ${resp}              Getcars ${NEW_CAR_LEADER}       ${PORT} ${0}
-  Should Be Equal As Strings    ${resp.status_code}    404
+Delete cars on new leader
+    Delete All Cars And Verify   ${NEW_CAR_LEADER}
 
 Add new cars and get cars from new leader
-    [Documentation]    Add cars and get added cars from Leader
-    ${resp}            AddCar  ${NEW_CAR_LEADER}       ${PORT} ${NUM_CARS}
-    ${resp}            Getcars ${NEW_CAR_LEADER}       ${PORT} ${0}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    :FOR    ${i}    IN RANGE    1    ${NUM_CARS}
-    \    Should Contain     ${resp.content}   manufacturer${i}
+    [Documentation]    Add cars and get added cars from the Leader
+    Add Cars And Verify   ${NEW_CAR_LEADER}   ${NUM_CARS}
 
 Get Car Followers
-    ${CAR_FOLLOWERS}   GetFollowers   ${CAR_SHARD}   ${3}    ${3}    ${1}    ${PORT}     ${MEMBER1}   ${MEMBER2}    ${MEMBER3}
-    Log    ${CAR_FOLLOWERS}
-    SET SUITE VARIABLE  ${CAR_FOLLOWERS}
+    ${CAR_FOLLOWERS}   Get All Followers   ${CAR_SHARD}
+    Set Suite Variable  ${CAR_FOLLOWERS}
 
 Get added cars from Follower
-   [Documentation]   Get added cars using the Follower
-   ${resp}             Getcars  @{CAR_FOLLOWERS}[0]  ${PORT}  ${0}
-   Should Be Equal As Strings    ${resp.status_code}    200
-   :FOR    ${i}    IN RANGE    1    ${NUM_CARS}
-   \    Should Contain     ${resp.content}   manufacturer${i}
-
-Delete cars from Follower
-    [Documentation]    delete cars
-  DeleteAllCars  @{CAR_FOLLOWERS}[0]  ${PORT}  ${0}
-  ${resp}     Getcars   @{CAR_FOLLOWERS}[0]   ${PORT}  ${0}
-  Should Be Equal As Strings    ${resp.status_code}    404
-
-Add cars from follower
-    [Documentation]    Add more cars using the follower
-    ${resp}             AddCar    @{CAR_FOLLOWERS}[0]    ${PORT}   ${NUM_CARS}
-    ${resp}             Getcars   @{CAR_FOLLOWERS}[0]    ${PORT}   ${0}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    :FOR    ${i}    IN RANGE    1    ${NUM_CARS}
-    \    Should Contain     ${resp.content}   manufacturer${i}
+    [Documentation]   Get the added cars from the Follower
+    Wait Until Keyword Succeeds   60s  2s  Get Cars And Verify   @{CAR_FOLLOWERS}[0]   ${NUM_CARS}
+
+Delete cars on Follower
+    Delete All Cars And Verify   @{CAR_FOLLOWERS}[0]
+
+Add cars from Follower
+    [Documentation]    Add more cars from the Follower
+    Add Cars And Verify   @{CAR_FOLLOWERS}[0]   ${NUM_CARS}
 
 Get added cars from new leader
-   [Documentation]   Get added cars using the new leader
-   ${resp}             Getcars  ${NEW_CAR_LEADER}  ${PORT}  ${0}
-   Should Be Equal As Strings    ${resp.status_code}    200
-   :FOR    ${i}    IN RANGE    1    ${NUM_CARS}
-   \    Should Contain     ${resp.content}   manufacturer${i}
+    [Documentation]   Get added cars from the new leader
+    Wait Until Keyword Succeeds   60s  2s  Get Cars And Verify   ${NEW_CAR_LEADER}   ${NUM_CARS}
 
 Restart old Car leader
-    Startcontroller    ${OLD_CAR_LEADER}    ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}    ${PORT}
-    Sleep   3
+    StartController    ${OLD_CAR_LEADER}    ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}    ${PORT}
 
 Get added cars from old leader
-   [Documentation]   Get added cars using the old leader
-   ${resp}             Getcars  ${OLD_CAR_LEADER}  ${PORT}  ${0}
-   Should Be Equal As Strings    ${resp.status_code}    200
-   :FOR    ${i}    IN RANGE    1    ${NUM_CARS}
-   \    Should Contain     ${resp.content}   manufacturer${i}
+    [Documentation]   Get the added cars from the old leader
+    Wait Until Keyword Succeeds   60s  2s  Get Cars And Verify   ${OLD_CAR_LEADER}   ${NUM_CARS}
 
index 0704abf88a2722950827c281c7571a9266cdbb94..f62c289a3f9bad5d13cbc5f07b881f76ce49f34c 100644 (file)
@@ -1,8 +1,11 @@
 *** Settings ***
 Documentation     This test brings down the current leader of the "car" shard and then executes CRUD operations on the new leader
+Default Tags  3-node-cluster
+
 Library           ../../../libraries/CrudLibrary.py
 Library           ../../../libraries/UtilLibrary.py
 Library           ../../../libraries/ClusterStateLibrary.py
+Resource           ../../../libraries/ClusterKeywords.txt
 
 *** Variables ***
 ${PEOPLE_SHARD}   shard-people-config
@@ -10,74 +13,38 @@ ${NUM_ENTRIES}  ${50}
 
 *** Test Cases ***
 Switch People Leader
-  [Documentation]    stop leader and elect new leader
-  ${OLD_PEOPLE_LEADER}    GetLeader  ${PEOPLE_SHARD}  ${3}  ${3}  ${2}  ${PORT}  ${MEMBER1}  ${MEMBER2}  ${MEMBER3}
-  Stopcontroller  ${OLD_PEOPLE_LEADER}  ${USERNAME}  ${PASSWORD}  ${KARAFHOME}
-  Sleep    3
-  ${NEW_PEOPLE_LEADER}    GetLeader  ${PEOPLE_SHARD}  ${3}  ${3}  ${2}  ${PORT}  ${MEMBER1}  ${MEMBER2}  ${MEMBER3}
-  Log  ${NEW_PEOPLE_LEADER}
-  Should Not Be Equal As Strings   ${NEW_PEOPLE_LEADER}   None
-  Should Not Be Equal    ${OLD_PEOPLE_LEADER}    ${NEW_PEOPLE_LEADER}
-  Set Suite Variable    ${NEW_PEOPLE_LEADER}
-  Set Suite Variable    ${OLD_PEOPLE_LEADER}
+    [Documentation]    Stop the leader to cause a new leader to be elected
+    ${OLD_PEOPLE_LEADER}   Wait For Leader  ${PEOPLE_SHARD}
+    ${NEW_PEOPLE_LEADER}   Switch Leader  ${PEOPLE_SHARD}  ${OLD_PEOPLE_LEADER}
+    Set Suite Variable   ${OLD_PEOPLE_LEADER}
+    Set Suite Variable   ${NEW_PEOPLE_LEADER}
 
 Delete people from new leader
-    [Documentation]    delete people
-        DeleteAllPersons  ${NEW_PEOPLE_LEADER}   ${PORT}    ${0}
-        ${resp}         GetPersons      ${NEW_PEOPLE_LEADER}   ${PORT}   ${0}
-  Should Be Equal As Strings    ${resp.status_code}    404
+    Delete All People And Verify   ${NEW_PEOPLE_LEADER}
 
-Add persons and get from new leader
-    [Documentation]    Add persons and get persons from new leader
-    [Documentation]    Note: There should be one person added first to enable rpc
-    ${resp}             AddPerson       ${NEW_PEOPLE_LEADER}  ${PORT}   ${0}
-    ${resp}             AddPerson       ${NEW_PEOPLE_LEADER}  ${PORT}   ${NUM_ENTRIES}
-    Sleep               10
-    ${resp}             GetPersons      ${NEW_PEOPLE_LEADER}  ${PORT}   ${0}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    :FOR    ${i}    IN RANGE    1    ${NUM_ENTRIES}
-    \    Should Contain     ${resp.content}   user${i}
+Add people and get from new leader
+    [Documentation]    Add people and get people from new leader
+    Add People And Verify   ${NEW_PEOPLE_LEADER}   ${NUM_ENTRIES}
 
 Get People Followers
-    ${PEOPLE_FOLLOWERS}   GetFollowers   ${PEOPLE_SHARD}   ${3}    ${3}    ${1}    ${PORT}     ${MEMBER1}   ${MEMBER2}    ${MEMBER3}
-    Log    ${PEOPLE_FOLLOWERS}
-    SET SUITE VARIABLE  ${PEOPLE_FOLLOWERS}
+    ${PEOPLE_FOLLOWERS}   Get All Followers   ${PEOPLE_SHARD}
+    Set Suite Variable  ${PEOPLE_FOLLOWERS}
 
-Get added persons from follower
-    ${resp}             GetPersons      @{PEOPLE_FOLLOWERS}[0]   ${PORT}   ${0}
-    Should Be Equal As Strings    ${resp.status_code}    200  
-    :FOR    ${i}    IN RANGE    1    ${NUM_ENTRIES}
-    \    Should Contain     ${resp.content}   user${i}
+Get added people from Follower
+    Wait Until Keyword Succeeds   60s  2s  Get People And Verify   @{PEOPLE_FOLLOWERS}[0]   ${NUM_ENTRIES}
 
 Delete people from new Follower
-    [Documentation]    delete people
-    DeleteAllPersons  @{PEOPLE_FOLLOWERS}[0]   ${PORT}    ${0}
-    ${resp}         GetPersons      @{PEOPLE_FOLLOWERS}[0]   ${PORT}   ${0}
-    Should Be Equal As Strings    ${resp.status_code}    404
+    Delete All People And Verify   @{PEOPLE_FOLLOWERS}[0]
 
-Add persons from new Follower
-    [Documentation]    Add persons and get persons from follower
-    [Documentation]    Note: There should be one person added first to enable rpc
-    ${resp}             AddPerson       @{PEOPLE_FOLLOWERS}[0]  ${PORT}   ${0}
-    ${resp}             AddPerson       @{PEOPLE_FOLLOWERS}[0]  ${PORT}   ${NUM_ENTRIES}
-    Sleep               10
-    ${resp}             GetPersons      @{PEOPLE_FOLLOWERS}[0]  ${PORT}   ${0}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    :FOR    ${i}    IN RANGE    1    ${NUM_ENTRIES}
-    \    Should Contain     ${resp.content}   user${i}
+Add people from new Follower
+    [Documentation]    Add people and get people from follower
+    Add People And Verify   @{PEOPLE_FOLLOWERS}[0]   ${NUM_ENTRIES}
 
-Get added persons from new leader
-    ${resp}             GetPersons      ${NEW_PEOPLE_LEADER}   ${PORT}   ${0}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    :FOR    ${i}    IN RANGE    1    ${NUM_ENTRIES}
-    \    Should Contain     ${resp.content}   user${i}
+Get added people from new leader
+    Wait Until Keyword Succeeds   60s  2s  Get People And Verify   ${NEW_PEOPLE_LEADER}   ${NUM_ENTRIES}
 
 Restart old People leader
-    Startcontroller    ${OLD_PEOPLE_LEADER}    ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}    ${PORT}
-    Sleep    3
+    StartController    ${OLD_PEOPLE_LEADER}    ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}    ${PORT}
 
-Get added persons from old leader
-    ${resp}             GetPersons      ${OLD_PEOPLE_LEADER}    ${PORT}    ${0}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    :FOR    ${i}    IN RANGE    1    ${NUM_ENTRIES}
-    \    Should Contain     ${resp.content}   user${i}
+Get added people from old leader
+    Wait Until Keyword Succeeds   60s  2s  Get People And Verify   ${OLD_PEOPLE_LEADER}   ${NUM_ENTRIES}
index 1a4d601c4f6dca8c4e3215d4ac9f3ab2ae951efb..e5358aab5157ede27af6fd39a9b9b7139d40f7f6 100644 (file)
@@ -1,8 +1,11 @@
 *** Settings ***
 Documentation     This test restarts all controllers to verify recovery of car data from persistene
+Default Tags  3-node-cluster
+
 Library           ../../../libraries/CrudLibrary.py
 Library           ../../../libraries/UtilLibrary.py
 Library           ../../../libraries/ClusterStateLibrary.py
+Resource          ../../../libraries/ClusterKeywords.txt
 Variables         ../../../variables/Variables.py
 
 *** Variables ***
@@ -11,14 +14,11 @@ ${NUM_CARS}  ${50}
 
 *** Test Cases ***
 Get car leader
-    ${CAR_LEADER}    GetLeader  ${CAR_SHARD}  ${3}  ${3}  ${2}  ${PORT}  ${MEMBER1}  ${MEMBER2}  ${MEMBER3}
-    Should Not Be Equal As Strings   ${CAR_LEADER}   None
+    ${CAR_LEADER}    Wait For Leader  ${CAR_SHARD}
     Set Suite Variable    ${CAR_LEADER}
 
 Delete cars from leader
-    DeleteAllCars  ${CAR_LEADER}  ${PORT}  ${0}
-    ${resp}     Getcars   ${CAR_LEADER}   ${PORT}   ${0}
-    Should Be Equal As Strings    ${resp.status_code}    404
+    Delete All Cars And Verify   ${CAR_LEADER}
 
 Stop all controllers after delete
     StopAllControllers    ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}    ${MEMBER1}    ${MEMBER2}    ${MEMBER3}
@@ -29,15 +29,11 @@ Start all controllers after delete
     Should Be True    ${rc}
 
 Verify no cars on leader after restart
-    ${resp}     Getcars   ${CAR_LEADER}   ${PORT}   ${0}
+    ${resp}  Getcars   ${CAR_LEADER}   ${PORT}   ${0}
     Should Be Equal As Strings    ${resp.status_code}    404
+
 Add cars on leader
-    ${resp}             AddCar    ${CAR_LEADER}   ${PORT}   ${NUM_CARS}
-    ${resp}             Getcars   ${CAR_LEADER}   ${PORT}   ${0}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    :FOR    ${i}    IN RANGE    1    ${NUM_CARS}
-    \    Should Contain     ${resp.content}   manufacturer${i}
+    Add Cars And Verify  ${CAR_LEADER}   ${NUM_CARS}
 
 Stop all controllers after add
     StopAllControllers    ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}    ${MEMBER1}    ${MEMBER2}    ${MEMBER3}
@@ -48,8 +44,15 @@ Start all controllers after add
     Should Be True    ${rc}
 
 Get cars from leader after restart
-    ${resp}  Getcars   ${CAR_LEADER}   ${PORT}   ${0}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    :FOR    ${i}    IN RANGE    1    ${NUM_CARS}
-    \    Should Contain     ${resp.content}   manufacturer${i}
+    Wait Until Keyword Succeeds   60s  2s  Get Cars And Verify   ${CAR_LEADER}   ${NUM_CARS}
+
+Get car followers
+    ${CAR_FOLLOWERS}   Get All Followers   ${CAR_SHARD}
+    Set Suite Variable  ${CAR_FOLLOWERS}
+
+Get cars from Follower1 after restart
+    Wait Until Keyword Succeeds   60s  2s  Get Cars And Verify   @{CAR_FOLLOWERS}[0]   ${NUM_CARS}
+
+Get cars from Follower2 after restart
+    Wait Until Keyword Succeeds   60s  2s  Get Cars And Verify   @{CAR_FOLLOWERS}[1]   ${NUM_CARS}
 
index 9943294cae8997f8f6542813664ceb318c764e0f..4582bf6951fe7a50b61d57ecca6679633db7a1e9 100644 (file)
@@ -1,5 +1,7 @@
 *** Settings ***
 Documentation     This test kills any of the followers and verifies that when that follower is restarted it can join the cluster
+Default Tags  3-node-cluster
+
 Library           Collections
 Library           ../../../libraries/RequestsLibrary.py
 Library           ../../../libraries/Common.py
@@ -7,6 +9,7 @@ Library           ../../../libraries/CrudLibrary.py
 Library           ../../../libraries/SettingsLibrary.py
 Library           ../../../libraries/UtilLibrary.py
 Library           ../../../libraries/ClusterStateLibrary.py
+Resource          ../../../libraries/ClusterKeywords.txt
 Variables         ../../../variables/Variables.py
 
 *** Variables ***
@@ -14,63 +17,54 @@ ${REST_CONTEXT}    /restconf/config/
 ${CAR_SHARD}      shard-car-config
 ${NUM_CARS}     ${60}
 
-*** Test Cases *** 
+*** Test Cases ***
 Stop All Controllers
     [Documentation]    Stop all the controllers in the cluster
     StopAllControllers    ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}    ${MEMBER1}    ${MEMBER2}    ${MEMBER3}
 
-
 Clean All Journals
     [Documentation]    Clean the journals of all the controllers in the cluster
     CleanJournal    ${MEMBER1}    ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}
     CleanJournal    ${MEMBER2}    ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}
     CleanJournal    ${MEMBER3}    ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}
-    Sleep    5
 
 Start All Controllers
     [Documentation]    Start all the controllers in the cluster
     ${rc}   StartAllControllers    ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}    ${RESTCONFPORT}
     ...    ${MEMBER1}    ${MEMBER2}    ${MEMBER3}
     Should Be True    ${rc}
-    Sleep    3
 
 Get car leader and followers
-    ${CURRENT_CAR_LEADER}   GetLeader   ${CAR_SHARD}   ${3}    ${3}    ${1}    ${PORT}     ${MEMBER1}   ${MEMBER2}    ${MEMBER3}
+    ${CURRENT_CAR_LEADER}   Wait For Leader   ${CAR_SHARD}
     Set Suite Variable    ${CURRENT_CAR_LEADER}
-    ${CAR_FOLLOWERS}  GetFollowers  ${CAR_SHARD}  ${3}  ${3}  ${1}  ${PORT}  ${MEMBER1}  ${MEMBER2}  ${MEMBER3}
+    ${CAR_FOLLOWERS}  Get All Followers  ${CAR_SHARD}
     Set Suite Variable    ${CAR_FOLLOWERS}
 
 Stop both of the followers
     StopAllControllers    ${USER_NAME}   ${PASSWORD}   ${KARAF_HOME}   @{CAR_FOLLOWERS}[0]    @{CAR_FOLLOWERS}[1]
+    Wait Until Keyword Succeeds   30s  2s  Expect No Leader
 
 Attempt to add a car from the leader
     [Documentation]    Should fail as both followers are down
-    ${resp}   AddCar  ${CURRENT_CAR_LEADER}    ${PORT}    ${1}
+    AddCar  ${CURRENT_CAR_LEADER}    ${PORT}    ${1}
+    Sleep  2
     ${resp}    Getcars    ${CURRENT_CAR_LEADER}    ${PORT}    ${1}
     Should Be Equal As Strings    ${resp.status_code}    404
 
 Restart the first follower
-    Startcontroller    @{CAR_FOLLOWERS}[0]   ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}    ${PORT}
-    Sleep    3
+    StartController    @{CAR_FOLLOWERS}[0]   ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}    ${PORT}
+    Sleep    1
 
 Add cars from the first follower
-    ${resp}             AddCar  @{CAR_FOLLOWERS}[0]     ${PORT}    ${NUM_CARS}
-    Should Be Equal As Strings    ${resp.status_code}    204
-    ${resp}             Getcars  @{CAR_FOLLOWERS}[0]   ${PORT}   ${0}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    :FOR    ${i}    IN RANGE    1    ${NUM_CARS}
-    \    Should Contain     ${resp.content}   manufacturer${i}
+    Wait Until Keyword Succeeds   60s  2s  Add Cars And Verify   @{CAR_FOLLOWERS}[0]   ${NUM_CARS}  4s
 
 Restart the second follower
-    Startcontroller    @{CAR_FOLLOWERS}[1]   ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}    ${PORT}
-    Sleep    3
+    StartController    @{CAR_FOLLOWERS}[1]   ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}    ${PORT}
 
 Get all the cars from the second follower
-    ${resp}    Getcars    @{CAR_FOLLOWERS}[1]    ${PORT}    ${0}
-    Should Be Equal As Strings    ${resp.status_code}    200
-    :FOR    ${i}    IN RANGE    1    ${NUM_CARS}
-    \    Should Contain     ${resp.content}   manufacturer${i}
+    Wait Until Keyword Succeeds   60s  2s  Get Cars And Verify   @{CAR_FOLLOWERS}[1]   ${NUM_CARS}
 
-Cleanup All Controllers 
-    [Documentation]    Stop all the controllers in the cluster
-    StopAllControllers    ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}    ${MEMBER1}    ${MEMBER2}    ${MEMBER3}
+*** Keywords ***
+Expect No Leader
+    ${leader}   GetLeader   ${CAR_SHARD}   ${3}    ${1}    ${1}    ${PORT}     ${CURRENT_CAR_LEADER}
+    Should Be Equal As Strings   ${leader}   None
\ No newline at end of file
diff --git a/test/csit/suites/clustering/datastore/999_cleanup.txt b/test/csit/suites/clustering/datastore/999_cleanup.txt
new file mode 100644 (file)
index 0000000..f11e048
--- /dev/null
@@ -0,0 +1,17 @@
+*** Settings ***
+Documentation  Test cleanup
+Default Tags  3-node-cluster
+
+Library           ../../../libraries/UtilLibrary.py
+Variables         ../../../variables/Variables.py
+
+*** Test Cases ***
+Kill All Controllers
+    KillController    ${MEMBER1}   ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}
+    KillController    ${MEMBER2}   ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}
+    KillController    ${MEMBER3}   ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}
+
+Clean All Journals
+    CleanJournal    ${MEMBER1}    ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}
+    CleanJournal    ${MEMBER2}    ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}
+    CleanJournal    ${MEMBER3}    ${USER_NAME}    ${PASSWORD}    ${KARAF_HOME}