Single Instance Test: Chameleon API
Change-Id: I364243fdb2b5eec7d174782006253c8bd34f0f84
diff --git a/src/test/cord-api/Framework/restApi.py b/src/test/cord-api/Framework/restApi.py
index ea5fec4..0dd6c81 100644
--- a/src/test/cord-api/Framework/restApi.py
+++ b/src/test/cord-api/Framework/restApi.py
@@ -162,7 +162,7 @@
time.sleep(5)
result = test.ApiDelete(key, urlSuffix)
'''
-'''
+#'''
test = restApi()
#key = "UTILS_SYNCHRONIZER"
#key = "CORE_USERS"
@@ -172,7 +172,7 @@
#jsonResponse = test.ApiPost(key,{"identity":{"name":"My House 22"}})
#jsonResponse = test.ApiPost(key,{"firstname":"Test002","lastname":"User002","email":"test002@onlab.us","password":"TestUser002","site": "http://localhost:8000/api/core/sites/1/"})
key = "VOLT_TENANT"
-key = "VOLT_SUBSCRIBER"
+#key = "VOLT_SUBSCRIBER"
#jsonResponse = test.ApiDelete(key,204)
#jsonResponse = test.ApiPut(key,{"firstname":"Test002","lastname":"User002","email":"test002update@onlab.us","password":"TestUser002","site": "http://localhost:8000/api/core/sites/1/"},14)
#jsonResponse = test.ApiPost(key2,{"username":"test002update@onlab.us","password":"TestUser002"})
@@ -184,7 +184,8 @@
#input_dict = { "s_tag" : "111", "c_tag" : "222", "subscriber" : 23}
input_dict = {
"s_tag" : 117,
- "c_tag" : 227
+ "c_tag" : 227,
+ "subscriber_root_id" : "16"
}
#input_dict1 = { "name" : "mysite_Test1", "site" : 1 , "creator" : 1}
@@ -200,13 +201,13 @@
}
#jsonResponse = test.ApiPost(key,input_dict)
#jsonResponse = test.ApiChameleonPut(key,input_dict,12)
-#jsonGetData = test.ApiGet(key,"/12")
+jsonGetData = test.ApiGet(key)
#print "========="
#print jsonGetData
#jsonEdit = test.ApiPut(key,{"c_tag" : "666","s_tag" : "123"},"30")
-jsonO = test.ApiDelete(key,"/7")
+#jsonO = test.ApiChameleonDelete(key,"56")
#jsonResponse = test.ApiPut(key,{"identity":{"name":"My House 22"}},"71")
-#jsonResponse = test.ApiPost(key,{"name":"test-2"})
+#jsonResponse = test.ApiPost(key,input_dict)
#jsonResponse = test.ApiPut(key,{"name":"test1-changed"},"9")
print "========="
-'''
+#'''
diff --git a/src/test/cord-api/Framework/utils/utils.py b/src/test/cord-api/Framework/utils/utils.py
index 48dcae2..87d15ca 100644
--- a/src/test/cord-api/Framework/utils/utils.py
+++ b/src/test/cord-api/Framework/utils/utils.py
@@ -131,6 +131,7 @@
return_dict = {}
result = ''
for data in getJsonDataList:
+ print "data", data
return_dict = {}
found = False
input_keys = data.keys()
@@ -138,6 +139,7 @@
if key == searchKey and str(data[key]) == str(searchKeyValue):
found = True
return_dict = data
+ print "return_dict",return_dict
break
elif type(data[key]) == dict:
result, found = self.search_dictionary(data[key],searchKey)
diff --git a/src/test/cord-api/Properties/RestApiProperties.py b/src/test/cord-api/Properties/RestApiProperties.py
index db4af80..b88b662 100644
--- a/src/test/cord-api/Properties/RestApiProperties.py
+++ b/src/test/cord-api/Properties/RestApiProperties.py
@@ -3,7 +3,7 @@
SERVER_IP = 'localhost'
SERVER_PORT = '8080'
USER = 'xosadmin@opencord.org'
-PASSWD = 'y7vibol8lK67TLXLVWN2'
+PASSWD = 'GKHDWlgEgHB780HSbUSc'
VOLT_SUBSCRIBER = '/xosapi/v1/rcord/cordsubscriberroots'
VOLT_TENANT = '/xosapi/v1/volt/volttenants'
TENANT_SUBSCRIBER = '/api/tenant/cord/subscriber/'
diff --git a/src/test/cord-api/Tests/Ch_SingleInstanceTest.txt b/src/test/cord-api/Tests/Ch_SingleInstanceTest.txt
new file mode 100644
index 0000000..90f80b4
--- /dev/null
+++ b/src/test/cord-api/Tests/Ch_SingleInstanceTest.txt
@@ -0,0 +1,108 @@
+*** Settings ***
+Documentation Test suite for Instance creation for multiple subscribers with same "s_tag" - Chameleon APIs
+Suite Setup Read InputFile
+Test Template Verify Single Instance Functionality
+Library Collections
+Library String
+Library OperatingSystem
+Library XML
+Library RequestsLibrary
+Library ../Framework/utils/utils.py
+Library ../Framework/restApi.py
+
+*** Variables ***
+${USER} admin
+${PASSWORD} admin
+${PATHFILE} ${CURDIR}/data/Ch_Subscriber.json
+${PATHFILE2} ${CURDIR}/data/Ch_SingleInstance_VoltTenant.json
+
+*** Test Cases *** TYPE LISTINDEX
+Test Create Subscriber-1
+ SUBSCRIBER_CREATE 0
+
+Test Create Subscriber-2
+ SUBSCRIBER_CREATE 1
+
+Test Create Subscriber-3
+ SUBSCRIBER_CREATE 2
+
+Test Create Tenant-1
+ TENANT_CREATE 0
+
+Test Create Tenant-2
+ TENANT_CREATE 1
+
+Test Create Tenant-3
+ TENANT_CREATE 2
+
+Test Instance creation validation
+ INSTANCE_VALIDATE 0
+
+*** Keywords ***
+Read InputFile
+ ${subscriberList} = utils.jsonToList ${PATHFILE} SubscriberInfo
+ Set Suite Variable ${slist} ${subscriberList}
+ ${voltList}= utils.jsonToList ${PATHFILE2} voltSubscriberInfo
+ Set Suite Variable ${vlist} ${voltList}
+ @{instanceList}= Create List
+ Set Suite Variable @{instanceList}
+
+Verify Single Instance functionality
+ [Arguments] ${type} ${listIndex}
+ Run Keyword If "${type}" == "SUBSCRIBER_CREATE" Test Post Subscriber Create ${listIndex}
+ Run Keyword If "${type}" == "TENANT_CREATE" Test Post volt Tenant Create ${listIndex}
+ Run Keyword If "${type}" == "INSTANCE_VALIDATE" Test Instance Validation ${listIndex}
+
+Test Post Subscriber Create
+ [Arguments] ${listIndex}
+ ${subscriberList} = Get Variable Value ${slist}
+ ${subscriberDict}= utils.listToDict ${subscriberList} ${listIndex}
+ ${api_result}= restApi.ApiPost VOLT_SUBSCRIBER ${subscriberDict}
+ ${instanceList} Create List
+
+Test Post volt Tenant Create
+ [Arguments] ${listIndex}
+ ${voltTenantList} = Get Variable Value ${vlist}
+ ${voltTenantDict}= utils.listToDict ${voltTenantList} ${listIndex}
+ ${voltDict}= Get From Dictionary ${voltTenantDict} voltTenant
+ ${service_specific_id}= Get From Dictionary ${voltTenantDict} service_specific_id
+ ${get_result}= restApi.ApiGet VOLT_SUBSCRIBER
+ ${get_result_list}= Get From Dictionary ${get_result} items
+ ${subscriberDict}= utils.getDictFromListofDict ${get_result_list} service_specific_id ${service_specific_id}
+ ${subscriberID}= utils.getFieldValueFromDict ${subscriberDict} id
+ ${updatedVoltDict}= utils.setFieldValueInDict ${voltDict} subscriber_root_id ${subscriberID}
+ ${api_result}= restApi.ApiPost VOLT_TENANT ${updatedVoltDict}
+ Should Be True ${api_result}
+ # Verifying Get operation after POST
+ Sleep 20
+ ${getVolt_result}= restApi.ApiGet VOLT_TENANT
+ Log ${getVolt_result}
+ ${getVolt_result_list}= utils.getFieldValueFromDict ${getVolt_result} items
+ Log ${getVolt_result_list}
+ ${getJsonDict}= utils.getDictFromListOfDict ${getVolt_result_list} subscriber_root_id ${subscriberID}
+ Log ${getJsonDict}
+ ${test_result}= utils.compare_dict ${voltDict} ${getJsonDict}
+ Should Be True ${test_result}
+ # Validation of Instances
+ Log ${instanceList}
+ Log ${getJsonDict}
+ ${VSGTenantList}= Get From Dictionary ${getJsonDict} subscribed_tenants_ids
+ Log ${VSGTenantList}
+ ${VSGTenant}= Get From List ${VSGTenantList} 0
+ ${getVSG_result}= restApi.ApiChameleonGet VSG_TENANT ${VSGTenant}
+ ${instance_id}= Get From Dictionary ${getVSG_result} instance_id
+ Append To List ${instanceList} ${instance_id}
+ Log ${instanceList}
+
+Test Instance Validation
+ [Arguments] ${listIndex}
+ ${get_result}= restApi.ApiGet VSG_TENANT
+ Should Be True ${get_result}
+ ${instanceFinalList}= Remove Duplicates ${instanceList}
+ Log ${instanceFinalList}
+ ${instanceCount}= Get Length ${instanceFinalList}
+ Log ${instanceCount}
+ Should Be True ${instanceCount} == 1
+ ${instance_id}= Get From List ${instanceFinalList} 0
+ ${get_CoreInstanceresult}= restApi.ApiChameleonGet CH_CORE_INSTANCES ${instance_id}
+ Should Be True ${get_CoreInstanceresult}
diff --git a/src/test/cord-api/Tests/data/Ch_SingleInstance_VoltTenant.json b/src/test/cord-api/Tests/data/Ch_SingleInstance_VoltTenant.json
new file mode 100644
index 0000000..43c0500
--- /dev/null
+++ b/src/test/cord-api/Tests/data/Ch_SingleInstance_VoltTenant.json
@@ -0,0 +1,31 @@
+{
+ "voltSubscriberInfo" : [
+ {
+ "voltTenant" :
+ {
+ "s_tag" : 115,
+ "c_tag" : 222,
+ "subscriber_root_id" : ""
+ },
+ "service_specific_id" : "304"
+ },
+ {
+ "voltTenant" :
+ {
+ "s_tag" : 115,
+ "c_tag" : 333,
+ "subscriber_root_id" : ""
+ },
+ "service_specific_id" : "305"
+ },
+ {
+ "voltTenant" :
+ {
+ "s_tag" : 115,
+ "c_tag" : 444,
+ "subscriber_root_id" : ""
+ },
+ "service_specific_id" : "306"
+ }
+ ]
+}