Currently, the addCar and addPerson methods create multiple cars/people in tight... 00/24400/2
authorShaleen Saxena <ssaxena@brocade.com>
Wed, 22 Jul 2015 15:32:57 +0000 (08:32 -0700)
committerShaleen Saxena <ssaxena@brocade.com>
Wed, 22 Jul 2015 16:11:14 +0000 (09:11 -0700)
loops do not check the results of the individual post operations. In case of cluster failures,
each post operation may take up to 5 minutes to timeout. Hence, these loops could take many
hours to complete.

The fix is to add an additional 'expected' parameter to these methods. This is a list of possible
results expected by the post operation. If any post operation does not match any of the 'expected'
values, then the loop will exit and raise an exception. This way the loop will wait for only
few minutes instead of hours.

Please note that this 'expected' parameter is optional. If it is not provided, then the old
behavior is preserved.

The other changes are to pass the expected values from various AddCar and AddPerson test cases.

Change-Id: I7375979de90f64c3ce70cfe4f3f6634d0aeac8e2
Signed-off-by: Shaleen Saxena <ssaxena@brocade.com>
test/csit/libraries/ClusterKeywords.txt
test/csit/libraries/CrudLibrary.py
test/csit/suites/controller/Clustering_Datastore/140_recovery_restart_follower.robot

index 13b6882ecf2bd832e43fd41d7c4c5e1a69eb4e66..5565bd7de18e7e6ce18da0bb1eea44932f7b616a 100644 (file)
@@ -53,14 +53,15 @@ Add Cars And Verify
     [Arguments]    ${controller_ip}    ${num_cars}  ${timeout}=60s
     ${resp}   InitCar   ${controller_ip}   ${PORT}
     Should Be Equal As Strings    ${resp.status_code}    204
-    ${resp}   AddCar   ${controller_ip}   ${RESTCONFPORT}   ${num_cars}
+    ${resp}   AddCar   ${controller_ip}   ${RESTCONFPORT}   ${num_cars}    204
     Should Be Equal As Strings    ${resp.status_code}    204
     Wait Until Keyword Succeeds   ${timeout}  2s  Get Cars And Verify   ${controller_ip}  ${num_cars}
 
 Add Cars And Verify Without Init
     [Documentation]  Adds cars to an initialized cars shard then performs a GET as a check.
     [Arguments]    ${controller_ip}    ${num_cars}  ${timeout}=60s
-    ${resp}   AddCar   ${controller_ip}   ${RESTCONFPORT}   ${num_cars}
+    Comment    First car add may return 409, but subsequent should be 204
+    ${resp}   AddCar   ${controller_ip}   ${RESTCONFPORT}   ${num_cars}   204    409
     Should Be Equal As Strings    ${resp.status_code}    204
     Wait Until Keyword Succeeds   ${timeout}  2s  Get Cars And Verify   ${controller_ip}  ${num_cars}
 
@@ -79,10 +80,10 @@ Add People And Verify
     [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}  ${RESTCONFPORT}  ${0}
+    ${resp}  AddPerson  ${controller_ip}  ${RESTCONFPORT}  ${0}    204
     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}    ${RESTCONFPORT}  ${num_people}
+    ${resp}  AddPerson   ${controller_ip}    ${RESTCONFPORT}  ${num_people}    200
     Wait Until Keyword Succeeds   60s  2s  Get People And Verify  ${controller_ip}  ${num_people}
 
 Get One Person And Verify
index 53ab35eb5705f8a973150199b96ebb8d933e2ed4..534a47e0b879420d0aec8deaaad1faa10823f35e 100644 (file)
@@ -24,7 +24,7 @@ def initCar(hostname, port):
     return resp
 
 
-def addCar(hostname, port, numberOfCars):
+def addCar(hostname, port, numberOfCars, *expected):
     """Creates the specified number of cars based on Cars yang model using RESTCONF"""
     for x in range(1, numberOfCars + 1):
         strId = str(x)
@@ -39,12 +39,16 @@ def addCar(hostname, port, numberOfCars):
 
         print("the response of the POST to add car=")
         print(resp)
+        if expected and str(resp.status_code) not in expected:
+            raise RuntimeError('Add car failed for {}:{} with status {}'.
+                               format(hostname, port, resp.status_code))
+
     return resp
 
     # TBD: Detailed validation
 
 
-def addPerson(hostname, port, numberOfPersons):
+def addPerson(hostname, port, numberOfPersons, *expected):
     """Creates the specified number of persons based on People yang model using main RPC
     <note>
         To enable RPC a non-user input person entry is created with personId=user0
@@ -81,6 +85,9 @@ def addPerson(hostname, port, numberOfPersons):
         print(payload)
         print("the response of the POST to add person=")
         print(resp)
+        if expected and str(resp.status_code) not in expected:
+            raise RuntimeError('Add person failed for {}:{} with status {}'.
+                               format(hostname, port, resp.status_code))
 
     return resp
 
index b717abdd8de25bd3c9c5bebd25c87c47bae4f2ee..f248662db96d8f57069aa4b0d8cfbc4ecb580f3f 100644 (file)
@@ -42,7 +42,7 @@ Stop both of the followers
 
 Attempt to add a car to the leader
     [Documentation]    Should fail as both followers are down
-    AddCar    ${CURRENT_CAR_LEADER}    ${RESTCONFPORT}    ${1}
+    AddCar    ${CURRENT_CAR_LEADER}    ${RESTCONFPORT}    ${1}    500
     Sleep    2
     ${resp}    Getcars    ${CURRENT_CAR_LEADER}    ${RESTCONFPORT}    ${1}
     Should Not Be Equal As Strings    ${resp.status_code}    200