# Given a shardname (e.g. shard-inventory-config), number of shards and bunch of ips
# determines what role each ip has in an Akka (Raft based) cluster
# result would look like
-# {'Leader':10.194.126.118', 'Follower':10.194.126.118':, '10.194.126.117': None}
+# {'10.194.126.118':'Leader', '10.194.126.118':'Follower', '10.194.126.117': None}
#
def getClusterRoles(shardName,numOfShards=3,numOfTries=3,sleepBetweenRetriesInSecs=1,port=8181,*ips):
print (ip + " seems to have value "+ str(dict[ip]))
def testGetLeader ():
- leader = getLeader("shard-inventory-config",3,1,1,8181,"10.194.126.116","10.194.126.117","10.194.126.118")
+ leader = getLeader("shard-car-config",3,1,1,8181,"10.194.126.116","10.194.126.117","10.194.126.118")
print leader
return leader
return followers
#testGetClusterRoles()
-#testGetLeader()
+testGetLeader()
#testGetFollowers()
resp = UtilLibrary.get(SettingsLibrary.getCarPersonUrl(hostname,port),"admin","admin")
resp.encoding = 'utf-8'
print (resp)
-
+
return resp
#
resp = getPersons(hostname,port,ignore)
print("Persons in store after deletion:"+ str(resp))
+
+#
+#delete all car -poeple s in the store using RESTCONF
+#
+#
+def deleteAllCarsPersons(hostname,port,ignore):
+ UtilLibrary.delete(SettingsLibrary.getCarPersonsUrl(hostname,port),"admin","admin")
+ resp = getPersons(hostname,port,ignore)
+ print("Persons in store after deletion:"+ str(resp))
+
#
# Usage message shown to user
#
*** Settings ***
-Documentation Test suite for RESTCONF RPC CAR PERSON
+Documentation Test suite for testing Distributed Datastore main operations performed from leader
+
Library Collections
Library ../../../../libraries/RequestsLibrary.py
Library ../../../../libraries/Common.py
Library ../../../../libraries/CrudLibrary.py
Library ../../../../libraries/SettingsLibrary.py
Library ../../../../libraries/UtilLibrary.py
+Library ../../../../libraries/ClusterStateLibrary.py
Variables ../../../../variables/Variables.py
+
*** Variables ***
${REST_CONTEXT} /restconf/config/
+${SHARD_CAR_NAME} shard-car-config
+${SHARD_PEOPLE_NAME} shard-people-config
+${SHARD_CAR_PERSON_NAME} shard-car-people-config
-*** Test Cases ***
-Add cars and get cars from Leader
+*** Test Cases ***
+Add cars and get cars from Leader
[Documentation] Add 100 cars and get added cars from Leader
- ${resp} AddCar ${LEADER} ${PORT} ${100}
- ${resp} Getcars ${LEADER} ${PORT} ${0}
+ ${CURRENT_CAR_LEADER} GetLeader ${SHARD_CAR_NAME} ${3} ${3} ${1} ${PORT} ${LEADER} ${FOLLOWER1} ${FOLLOWER2}
+ Log CURRENT_CAR_SHARD_LEADER ${CURRENT_CAR_LEADER}
+ Set Suite Variable ${CURRENT_CAR_LEADER}
+ ${resp} AddCar ${CURRENT_CAR_LEADER} ${PORT} ${100}
+ ${resp} Getcars ${CURRENT_CAR_LEADER} ${PORT} ${0}
Should Be Equal As Strings ${resp.status_code} 200
- Should Contain ${resp.content} manufacturer1
-
-Add persons and get persons from Leader
+ Should Contain ${resp.content} manufacturer1
+
+Add persons and get persons from Leader
[Documentation] Add 100 persons and get persons
[Documentation] Note: There should be one person added first to enable rpc
- ${resp} AddPerson ${LEADER} ${PORT} ${0}
- ${resp} AddPerson ${LEADER} ${PORT} ${100}
- ${resp} GetPersons ${LEADER} ${PORT} ${0}
+ ${CURRENT_PEOPLE_LEADER} GetLeader ${SHARD_PEOPLE_NAME} ${3} ${3} ${1} ${PORT} ${LEADER} ${FOLLOWER1} ${FOLLOWER2}
+ Set Suite Variable ${CURRENT_PEOPLE_LEADER}
+ ${resp} AddPerson ${CURRENT_PEOPLE_LEADER} ${PORT} ${0}
+ ${resp} AddPerson ${CURRENT_PEOPLE_LEADER} ${PORT} ${100}
+ ${resp} GetPersons ${CURRENT_PEOPLE_LEADER} ${PORT} ${0}
Should Be Equal As Strings ${resp.status_code} 200
- Should Contain ${resp.content} user5
-
-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
+ Should Contain ${resp.content} user5
- ${resp} AddCarPerson ${LEADER} ${PORT} ${0}
- ${resp} GetCarPersonMappings ${LEADER} ${PORT} ${0}
+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} ${LEADER} ${FOLLOWER1} ${FOLLOWER2}
+ Set Suite Variable ${CURRENT_CAR_PERSON_LEADER}
+ ${resp} AddCarPerson ${CURRENT_CAR_PERSON_LEADER} ${PORT} ${0}
+ Sleep 2
+ ${resp} GetCarPersonMappings ${CURRENT_CAR_PERSON_LEADER} ${PORT} ${0}
Should Be Equal As Strings ${resp.status_code} 200
Should Contain ${resp.content} user0
-
-Purchase 100 cars using Leader
+
+Purchase 100 cars using Leader
[Documentation] Purchase 100 cars using Leader
- ${resp} BuyCar ${LEADER} ${PORT} ${100}
- ${resp} GetCarPersonMappings ${LEADER} ${PORT} ${0}
+ ${resp} BuyCar ${CURRENT_CAR_PERSON_LEADER} ${PORT} ${100}
+ Sleep 2
+ ${resp} GetCarPersonMappings ${CURRENT_CAR_PERSON_LEADER} ${PORT} ${0}
Should Be Equal As Strings ${resp.status_code} 200
Get car-person mappings using Leader
[Documentation] Get car-person mappings using Leader to see 100 entry
- ${resp} GetCarPersonMappings ${LEADER} ${PORT} ${0}
+ ${resp} GetCarPersonMappings ${CURRENT_CAR_PERSON_LEADER} ${PORT} ${0}
Should Be Equal As Strings ${resp.status_code} 200
Should Contain ${resp.content} user100
Get car-person mappings using Follower1
[Documentation] Get car-person mappings using Follower1 to see 100 entry
- ${resp} GetCarPersonMappings ${FOLLOWER1} ${PORT} ${0}
+ ${FOLLOWERS} GetFollowers ${SHARD_CAR_PERSON_NAME} ${3} ${3} ${1} ${PORT} ${LEADER} ${FOLLOWER1} ${FOLLOWER2}
+ Log ${FOLLOWERS}
+ SET SUITE VARIABLE ${FOLLOWERS}
+ ${resp} GetCarPersonMappings ${FOLLOWERS[0]} ${PORT} ${0}
Should Be Equal As Strings ${resp.status_code} 200
Should Contain ${resp.content} user100
Should Contain ${resp.content} user5
Get car-person mappings using Follower2
[Documentation] Get car-person mappings using Follower2 to see 100 entry
- ${resp} GetCarPersonMappings ${FOLLOWER2} ${PORT} ${0}
+ ${resp} GetCarPersonMappings ${FOLLOWERS[1]} ${PORT} ${0}
Should Be Equal As Strings ${resp.status_code} 200
Should Contain ${resp.content} user0
Should Contain ${resp.content} user100
+++ /dev/null
-*** Settings ***
-Documentation Test suite for RESTCONF RPC CAR PERSON
-Library Collections
-Library ../../../../libraries/RequestsLibrary.py
-Library ../../../../libraries/Common.py
-Library ../../../../libraries/CrudLibrary.py
-Library ../../../../libraries/SettingsLibrary.py
-Library ../../../../libraries/UtilLibrary.py
-Variables ../../../../variables/Variables.py
-
-*** Variables ***
-${REST_CONTEXT} /restconf/config/
-
-
-*** Test Cases ***
-Add cars and get cars from Leader
- [Documentation] Add 100 cars and get added cars from Leader
- ${resp} AddCar ${FOLLOWER1} ${PORT} ${100}
- ${resp} Getcars ${FOLLOWER1} ${PORT} ${0}
- Should Be Equal As Strings ${resp.status_code} 200
- Should Contain ${resp.content} manufacturer1
-
-Add persons and get persons from Leader
- [Documentation] Add 100 persons and get persons
- [Documentation] Note: There should be one person added first to enable rpc
- ${resp} AddPerson ${FOLLOWER1} ${PORT} ${0}
- ${resp} AddPerson ${FOLLOWER1} ${PORT} ${100}
- ${resp} GetPersons ${FOLLOWER1} ${PORT} ${0}
- Should Be Equal As Strings ${resp.status_code} 200
- Should Contain ${resp.content} user5
-
-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
-
- ${resp} AddCarPerson ${FOLLOWER1} ${PORT} ${0}
- ${resp} GetCarPersonMappings ${FOLLOWER1} ${PORT} ${0}
- Should Be Equal As Strings ${resp.status_code} 200
- Should Contain ${resp.content} user0
-
-Purchase 100 cars using Leader
- [Documentation] Purchase 100 cars using Leader
-
- ${resp} BuyCar ${FOLLOWER1} ${PORT} ${100}
- ${resp} GetCarPersonMappings ${FOLLOWER1} ${PORT} ${0}
- Should Be Equal As Strings ${resp.status_code} 200
-
-Get car-person mappings using Leader
- [Documentation] Get car-person mappings using Leader to see 100 entry
- ${resp} GetCarPersonMappings ${FOLLOWER1} ${PORT} ${0}
- Should Be Equal As Strings ${resp.status_code} 200
- Should Contain ${resp.content} user100
-
-Get car-person mappings using Leader
- [Documentation] Get car-person mappings using Leader to see 100 entry
- ${resp} GetCarPersonMappings ${LEADER} ${PORT} ${0}
- Should Be Equal As Strings ${resp.status_code} 200
- Should Contain ${resp.content} user100
- Should Contain ${resp.content} user5
-
-
-Get car-person mappings using Follower2
- [Documentation] Get car-person mappings using Follower2 to see 100 entry
- ${resp} GetCarPersonMappings ${FOLLOWER2} ${PORT} ${0}
- Should Be Equal As Strings ${resp.status_code} 200
- Should Contain ${resp.content} user0
- Should Contain ${resp.content} user100
+++ /dev/null
-*** Settings ***
-Documentation Test suite for RESTCONF RPC CAR PERSON
-Library Collections
-Library ../../../../libraries/RequestsLibrary.py
-Library ../../../../libraries/Common.py
-Library ../../../../libraries/CrudLibrary.py
-Library ../../../../libraries/SettingsLibrary.py
-Library ../../../../libraries/UtilLibrary.py
-Variables ../../../../variables/Variables.py
-
-*** Variables ***
-${REST_CONTEXT} /restconf/config/
-
-
-*** Test Cases ***
-Add cars and get cars from Leader
- [Documentation] Add 100 cars and get added cars from Leader
- ${resp} AddCar ${FOLLOWER2} ${PORT} ${100}
- ${resp} Getcars ${FOLLOWER2} ${PORT} ${0}
- Should Be Equal As Strings ${resp.status_code} 200
- Should Contain ${resp.content} manufacturer1
-
-Add persons and get persons from Leader
- [Documentation] Add 100 persons and get persons
- [Documentation] Note: There should be one person added first to enable rpc
- ${resp} AddPerson ${FOLLOWER2} ${PORT} ${0}
- ${resp} AddPerson ${FOLLOWER2} ${PORT} ${100}
- ${resp} GetPersons ${FOLLOWER2} ${PORT} ${0}
- Should Be Equal As Strings ${resp.status_code} 200
- Should Contain ${resp.content} user5
-
-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
-
- ${resp} AddCarPerson ${FOLLOWER2} ${PORT} ${0}
- ${resp} GetCarPersonMappings ${FOLLOWER2} ${PORT} ${0}
- Should Be Equal As Strings ${resp.status_code} 200
- Should Contain ${resp.content} user0
-
-Purchase 100 cars using Leader
- [Documentation] Purchase 100 cars using Leader
-
- ${resp} BuyCar ${FOLLOWER2} ${PORT} ${100}
- ${resp} GetCarPersonMappings ${FOLLOWER2} ${PORT} ${0}
- Should Be Equal As Strings ${resp.status_code} 200
-
-Get car-person mappings using Leader
- [Documentation] Get car-person mappings using Leader to see 100 entry
- ${resp} GetCarPersonMappings ${FOLLOWER2} ${PORT} ${0}
- Should Be Equal As Strings ${resp.status_code} 200
- Should Contain ${resp.content} user100
-
-Get car-person mappings using Leader
- [Documentation] Get car-person mappings using Leader to see 100 entry
- ${resp} GetCarPersonMappings ${LEADER} ${PORT} ${0}
- Should Be Equal As Strings ${resp.status_code} 200
- Should Contain ${resp.content} user100
- Should Contain ${resp.content} user5
-
-
-Get car-person mappings using Follower1
- [Documentation] Get car-person mappings using Follower1 to see 100 entry
- ${resp} GetCarPersonMappings ${FOLLOWER1} ${PORT} ${0}
- Should Be Equal As Strings ${resp.status_code} 200
- Should Contain ${resp.content} user0
- Should Contain ${resp.content} user100
--- /dev/null
+*** Settings ***
+Documentation Test suite for testing Distributed Datastore main operations performed from follower1
+
+Library Collections
+Library ../../../../libraries/RequestsLibrary.py
+Library ../../../../libraries/Common.py
+Library ../../../../libraries/CrudLibrary.py
+Library ../../../../libraries/SettingsLibrary.py
+Library ../../../../libraries/UtilLibrary.py
+Library ../../../../libraries/ClusterStateLibrary.py
+Variables ../../../../variables/Variables.py
+
+*** Variables ***
+${REST_CONTEXT} /restconf/config/
+${SHARD_CAR_NAME} shard-car-config
+${SHARD_PEOPLE_NAME} shard-people-config
+${SHARD_CAR_PERSON_NAME} shard-car-people-config
+
+
+*** Test Cases ***
+Add cars and get cars from Follower1
+ [Documentation] Add 100 cars and get added cars from Follower1
+ ${FOLLOWERS} GetFollowers ${SHARD_CAR_PERSON_NAME} ${3} ${3} ${1} ${PORT} ${LEADER} ${FOLLOWER1} ${FOLLOWER2}
+ Log ${FOLLOWERS}
+ SET SUITE VARIABLE ${FOLLOWERS}
+
+ ${resp} AddCar ${FOLLOWERS[0]} ${PORT} ${100}
+ Sleep 1
+ ${resp} Getcars ${FOLLOWERS[0]} ${PORT} ${0}
+ Should Be Equal As Strings ${resp.status_code} 200
+ Should Contain ${resp.content} manufacturer1
+
+Add persons and get persons from Follower1
+ [Documentation] Add 100 persons and get persons from Follower1
+ [Documentation] Note: There should be one person added first to enable rpc
+ ${resp} AddPerson ${FOLLOWERS[0]} ${PORT} ${0}
+ ${resp} AddPerson ${FOLLOWERS[0]} ${PORT} ${100}
+ Sleep 1
+ ${resp} GetPersons ${FOLLOWERS[0]} ${PORT} ${0}
+ Should Be Equal As Strings ${resp.status_code} 200
+ Should Contain ${resp.content} user5
+
+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
+
+ ${resp} AddCarPerson ${FOLLOWERS[0]} ${PORT} ${0}
+ ${resp} GetCarPersonMappings ${FOLLOWERS[0]} ${PORT} ${0}
+ Should Be Equal As Strings ${resp.status_code} 200
+ Should Contain ${resp.content} user0
+
+Purchase 100 cars using Follower1
+ [Documentation] Purchase 100 cars using Follower1
+
+ ${resp} BuyCar ${FOLLOWERS[0]} ${PORT} ${100}
+ Sleep 1
+ ${resp} GetCarPersonMappings ${FOLLOWERS[0]} ${PORT} ${0}
+ Should Be Equal As Strings ${resp.status_code} 200
+
+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
+ Should Contain ${resp.content} user100
+ Should Contain ${resp.content} user5
+
+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} ${LEADER} ${FOLLOWER1} ${FOLLOWER2}
+ Log ${CURRENT_CAR_LEADER}
+ Sleep 1
+ ${resp} GetCarPersonMappings ${CURRENT_CAR_LEADER} ${PORT} ${0}
+ Should Be Equal As Strings ${resp.status_code} 200
+ Should Contain ${resp.content} user100
+
+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
+ Should Contain ${resp.content} user0
+ Should Contain ${resp.content} user100
--- /dev/null
+*** Settings ***
+Documentation Test suite for testing Distributed Datastore main operations performed from follower2
+
+Library Collections
+Library ../../../../libraries/RequestsLibrary.py
+Library ../../../../libraries/Common.py
+Library ../../../../libraries/CrudLibrary.py
+Library ../../../../libraries/SettingsLibrary.py
+Library ../../../../libraries/UtilLibrary.py
+Library ../../../../libraries/ClusterStateLibrary.py
+Variables ../../../../variables/Variables.py
+
+*** Variables ***
+${REST_CONTEXT} /restconf/config/
+${SHARD_CAR_NAME} shard-car-config
+${SHARD_PEOPLE_NAME} shard-people-config
+${SHARD_CAR_PERSON_NAME} shard-car-people-config
+
+
+*** Test Cases ***
+Add cars and get cars from Follower2
+ [Documentation] Add 100 cars and get added cars from Follower2
+ ${FOLLOWERS} GetFollowers ${SHARD_CAR_PERSON_NAME} ${3} ${3} ${1} ${PORT} ${LEADER} ${FOLLOWER1} ${FOLLOWER2}
+ Log ${FOLLOWERS}
+ SET SUITE VARIABLE ${FOLLOWERS}
+
+ ${resp} AddCar ${FOLLOWERS[1]} ${PORT} ${100}
+ Sleep 1
+ ${resp} Getcars ${FOLLOWERS[1]} ${PORT} ${0}
+ Should Be Equal As Strings ${resp.status_code} 200
+ Should Contain ${resp.content} manufacturer1
+
+Add persons and get persons from Follower2
+ [Documentation] Add 100 persons and get persons from Follower2
+ [Documentation] Note: There should be one person added first to enable rpc
+ ${resp} AddPerson ${FOLLOWERS[1]} ${PORT} ${0}
+ ${resp} AddPerson ${FOLLOWERS[1]} ${PORT} ${100}
+ Sleep 1
+ ${resp} GetPersons ${FOLLOWERS[1]} ${PORT} ${0}
+ Should Be Equal As Strings ${resp.status_code} 200
+ Should Contain ${resp.content} user5
+
+Add car-person mapping and get car-person mapping from Follower2
+ [Documentation] Add car-person and get car-person from Follower2
+ [Documentation] Note: This is done to enable working of rpc
+
+ ${resp} AddCarPerson ${FOLLOWERS[1]} ${PORT} ${0}
+ ${resp} GetCarPersonMappings ${FOLLOWERS[1]} ${PORT} ${0}
+ Should Be Equal As Strings ${resp.status_code} 200
+ Should Contain ${resp.content} user0
+
+Purchase 100 cars using Follower1
+ [Documentation] Purchase 100 cars using Follower2
+
+ ${resp} BuyCar ${FOLLOWERS[1]} ${PORT} ${100}
+ Sleep 1
+ ${resp} GetCarPersonMappings ${FOLLOWERS[1]} ${PORT} ${0}
+ Should Be Equal As Strings ${resp.status_code} 200
+
+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
+ Should Contain ${resp.content} user100
+ Should Contain ${resp.content} user5
+
+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} ${LEADER} ${FOLLOWER1} ${FOLLOWER2}
+ Log ${CURRENT_CAR_LEADER}
+ Sleep 1
+ ${resp} GetCarPersonMappings ${CURRENT_CAR_LEADER} ${PORT} ${0}
+ Should Be Equal As Strings ${resp.status_code} 200
+ Should Contain ${resp.content} user100
+
+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
+ Should Contain ${resp.content} user0
+ Should Contain ${resp.content} user100