Chameleon API Tests
Change-Id: I8002eb19add6e296f034adcdf7801d2ee54744cf
diff --git a/src/test/cord-api/Framework/restApi.py b/src/test/cord-api/Framework/restApi.py
index 5c22097..a14d196 100644
--- a/src/test/cord-api/Framework/restApi.py
+++ b/src/test/cord-api/Framework/restApi.py
@@ -90,11 +90,23 @@
data = json.dumps(jsonData)
print "url, data..", url, data
resp = requests.post(url, data=data, headers=self.jsonHeader, auth=(self.user, self.password))
- passed = self.checkResult(resp, requests.codes.created)
+ print "requests.codes.....",requests.codes.created
+ passed = self.checkResult(resp, requests.codes.created) or self.checkResult(resp, requests.codes.ok)
return passed
def ApiGet(self, key, urlSuffix=""):
url = self.getURL(key) + str(urlSuffix)
+ print "get url...",url
+ resp = requests.get(url, auth=(self.user, self.password))
+ passed = self.checkResult(resp, requests.codes.ok)
+ if not passed:
+ return None
+ else:
+ return resp.json()
+
+ def ApiChameleonGet(self, key, urlSuffix=""):
+ url = self.getURL(key) + "/" + str(urlSuffix)
+ print "get url...",url
resp = requests.get(url, auth=(self.user, self.password))
passed = self.checkResult(resp, requests.codes.ok)
if not passed:
@@ -110,11 +122,29 @@
passed = self.checkResult(resp, requests.codes.ok)
return passed
+ def ApiChameleonPut(self, key, jsonData, urlSuffix=""):
+ print "urlSuffix....",type(urlSuffix)
+ url = self.getURL(key) + "/" + str(urlSuffix)
+ print "url", url
+ data = json.dumps(jsonData)
+ resp = requests.put(url, data=data, headers=self.jsonHeader, auth=(self.user, self.password))
+ passed = self.checkResult(resp, requests.codes.ok)
+ return passed
+
def ApiDelete(self, key, urlSuffix=""):
url = self.getURL(key) + str(urlSuffix)
print "url",url
resp = requests.delete(url, auth=(self.user, self.password))
- passed = self.checkResult(resp, requests.codes.no_content)
+ #passed = self.checkResult(resp, requests.codes.no_content)
+ passed = self.checkResult(resp, requests.codes.created) or self.checkResult(resp, requests.codes.ok)
+ return passed
+
+ def ApiChameleonDelete(self, key, urlSuffix=""):
+ url = self.getURL(key) + "/" + str(urlSuffix)
+ print "url",url
+ resp = requests.delete(url, auth=(self.user, self.password))
+ #passed = self.checkResult(resp, requests.codes.no_content)
+ passed = self.checkResult(resp, requests.codes.created) or self.checkResult(resp, requests.codes.ok)
return passed
#test
@@ -142,30 +172,40 @@
#jsonGetData = test.ApiGet(key)
#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/"})
-#jsonResponse = test.ApiDelete(key,15)
+key = "VOLT_TENANT"
+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"})
#jsonResponse = test.ApiPost(key2,{"username":"padmin@vicci.org","password":"letmein"})
#jsonResponse = test.ApiPut(key,{"username":"testuser","password":"TestUser001"},"9")
-#key = "UTILS_SYNCHRONIZER"
-key = "CORE_SANITY_INSTANCES"
-key1 = "CORE_SANITY_SLICES"
-key2 = "CORE_SLICES"
+#key = "CORE_INSTANCES"
+#key1 = "CORE_SANITY_SLICES"
+#key2 = "CORE_SLICES"
#input_dict = { "s_tag" : "111", "c_tag" : "222", "subscriber" : 23}
input_dict = {
- "name": "test-instance",
- "image": 1,
- "slice": 1,
- "deployment": 1,
- "node": 1
- }
-input_dict1 = { "name" : "mysite_Test1", "site" : 1 , "creator" : 1}
-jsonResponse = test.ApiPost(key1,input_dict1)
-#jsonGetData = test.ApiGet(key)
-print "========="
+ "s_tag" : 117,
+ "c_tag" : 227
+ }
+
+#input_dict1 = { "name" : "mysite_Test1", "site" : 1 , "creator" : 1}
+input_dict2 = {
+
+ "cdn_enable": "true",
+ "uplink_speed": 1000000000,
+ "downlink_speed": 1000000000,
+ "enable_uverse": "true",
+ "status": "enabled",
+ "service_specific_id": "100",
+ "name": "My House"
+ }
+#jsonResponse = test.ApiPost(key,input_dict)
+#jsonResponse = test.ApiChameleonPut(key,input_dict,12)
+#jsonGetData = test.ApiGet(key,"/12")
+#print "========="
#print jsonGetData
#jsonEdit = test.ApiPut(key,{"c_tag" : "666","s_tag" : "123"},"30")
-#jsonO = test.ApiDelete(key2,"1")
+jsonO = test.ApiDelete(key,"/7")
#jsonResponse = test.ApiPut(key,{"identity":{"name":"My House 22"}},"71")
#jsonResponse = test.ApiPost(key,{"name":"test-2"})
#jsonResponse = test.ApiPut(key,{"name":"test1-changed"},"9")
diff --git a/src/test/cord-api/Framework/utils/utils.py b/src/test/cord-api/Framework/utils/utils.py
index fb1a797..832bee2 100644
--- a/src/test/cord-api/Framework/utils/utils.py
+++ b/src/test/cord-api/Framework/utils/utils.py
@@ -128,10 +128,12 @@
return_dict = {}
result = ''
for data in getJsonDataList:
+ print "data..",data
return_dict = {}
found = False
input_keys = data.keys()
for key in input_keys:
+ print "key in input_keys...",key
if key == searchKey and str(data[key]) == str(searchKeyValue):
found = True
return_dict = data
@@ -220,19 +222,251 @@
'''
#Test
dict_list = {
- "humanReadableName": "cordSubscriber-17",
- "id": 17,
- "features": {
- "uplink_speed": 1000000000,
- "downlink_speed": 1000000000,
- "status": "enabled"
+[
+ {
+ "humanReadableName": "mysite_vsg-1",
+ "validators": {
+ "policed": [],
+ "creator": [],
+ "ip": [],
+ "image": [
+ "notBlank"
+ ],
+ "backend_register": [
+ "notBlank"
+ ],
+ "flavor": [
+ "notBlank"
+ ],
+ "backend_status": [
+ "notBlank"
+ ],
+ "id": [],
+ "instance_name": [],
+ "slice": [
+ "notBlank"
+ ],
+ "backend_need_delete": [],
+ "enacted": [],
+ "no_sync": [],
+ "node": [
+ "notBlank"
+ ],
+ "userData": [],
+ "updated": [
+ "notBlank"
+ ],
+ "parent": [],
+ "deleted": [],
+ "lazy_blocked": [],
+ "deployment": [
+ "notBlank"
+ ],
+ "backend_need_reap": [],
+ "instance_uuid": [],
+ "numberCores": [
+ "notBlank"
+ ],
+ "name": [
+ "notBlank"
+ ],
+ "created": [],
+ "write_protect": [],
+ "isolation": [
+ "notBlank"
+ ],
+ "no_policy": [],
+ "instance_id": [],
+ "volumes": []
},
- "identity": {
- "account_num": "20",
- "name": "My House"
+ "id": 1,
+ "created": "2017-03-13T22:23:48.805109Z",
+ "updated": "2017-03-13T22:38:06.084074Z",
+ "enacted": "2017-03-13T22:38:43.894253Z",
+ "policed": "2017-03-13T22:38:08.086489Z",
+ "backend_register": "{\"next_run\": 0, \"last_success\": 1489444729.019414, \"exponent\": 0}",
+ "backend_status": "1 - OK",
+ "instance_id": "instance-00000001",
+ "instance_uuid": "a46d716f-e82c-4088-a042-72c3a97ed3ff",
+ "name": "mysite_vsg",
+ "instance_name": "mysite_vsg-1",
+ "ip": "10.1.0.17",
+ "image": "http://ms1333.utah.cloudlab.us:8080/api/core/images/1/",
+ "creator": "http://ms1333.utah.cloudlab.us:8080/api/core/users/1/",
+ "slice": "http://ms1333.utah.cloudlab.us:8080/api/core/slices/2/",
+ "deployment": "http://ms1333.utah.cloudlab.us:8080/api/core/deployments/1/",
+ "node": "http://ms1333.utah.cloudlab.us:8080/api/core/nodes/1/",
+ "numberCores": 0,
+ "flavor": "http://ms1333.utah.cloudlab.us:8080/api/core/flavors/1/",
+ "isolation": "vm",
+ "volumes": "/etc/dnsmasq.d,/etc/ufw",
+ "networks": [
+ "http://ms1333.utah.cloudlab.us:8080/api/core/networks/1/",
+ "http://ms1333.utah.cloudlab.us:8080/api/core/networks/2/"
+ ]
+ },
+ {
+ "humanReadableName": "mysite_exampleservice-2",
+ "validators": {
+ "policed": [],
+ "creator": [],
+ "ip": [],
+ "image": [
+ "notBlank"
+ ],
+ "backend_register": [
+ "notBlank"
+ ],
+ "flavor": [
+ "notBlank"
+ ],
+ "backend_status": [
+ "notBlank"
+ ],
+ "id": [],
+ "instance_name": [],
+ "slice": [
+ "notBlank"
+ ],
+ "backend_need_delete": [],
+ "enacted": [],
+ "no_sync": [],
+ "node": [
+ "notBlank"
+ ],
+ "userData": [],
+ "updated": [
+ "notBlank"
+ ],
+ "parent": [],
+ "deleted": [],
+ "lazy_blocked": [],
+ "deployment": [
+ "notBlank"
+ ],
+ "backend_need_reap": [],
+ "instance_uuid": [],
+ "numberCores": [
+ "notBlank"
+ ],
+ "name": [
+ "notBlank"
+ ],
+ "created": [],
+ "write_protect": [],
+ "isolation": [
+ "notBlank"
+ ],
+ "no_policy": [],
+ "instance_id": [],
+ "volumes": []
},
- "related": {}
+ "id": 2,
+ "created": "2017-03-13T22:38:03.872267Z",
+ "updated": "2017-03-13T22:38:06.047153Z",
+ "enacted": "2017-03-13T22:39:07.002800Z",
+ "policed": "2017-03-13T22:38:07.895147Z",
+ "backend_register": "{\"next_run\": 0, \"last_success\": 1489444774.726988, \"exponent\": 0}",
+ "backend_status": "1 - OK",
+ "instance_id": "instance-00000002",
+ "instance_uuid": "cb219739-0d11-48a2-9f19-1e2aba1f004e",
+ "name": "mysite_exampleservice",
+ "instance_name": "mysite_exampleservice-2",
+ "ip": "10.1.0.17",
+ "image": "http://ms1333.utah.cloudlab.us:8080/api/core/images/3/",
+ "creator": "http://ms1333.utah.cloudlab.us:8080/api/core/users/1/",
+ "slice": "http://ms1333.utah.cloudlab.us:8080/api/core/slices/4/",
+ "deployment": "http://ms1333.utah.cloudlab.us:8080/api/core/deployments/1/",
+ "node": "http://ms1333.utah.cloudlab.us:8080/api/core/nodes/1/",
+ "numberCores": 0,
+ "flavor": "http://ms1333.utah.cloudlab.us:8080/api/core/flavors/1/",
+ "isolation": "vm",
+ "networks": [
+ "http://ms1333.utah.cloudlab.us:8080/api/core/networks/3/",
+ "http://ms1333.utah.cloudlab.us:8080/api/core/networks/1/",
+ "http://ms1333.utah.cloudlab.us:8080/api/core/networks/4/"
+ ]
+ },
+ {
+ "humanReadableName": "mysite_vsg-3",
+ "validators": {
+ "policed": [],
+ "creator": [],
+ "ip": [],
+ "image": [
+ "notBlank"
+ ],
+ "backend_register": [
+ "notBlank"
+ ],
+ "flavor": [
+ "notBlank"
+ ],
+ "backend_status": [
+ "notBlank"
+ ],
+ "id": [],
+ "instance_name": [],
+ "slice": [
+ "notBlank"
+ ],
+ "backend_need_delete": [],
+ "enacted": [],
+ "no_sync": [],
+ "node": [
+ "notBlank"
+ ],
+ "userData": [],
+ "updated": [
+ "notBlank"
+ ],
+ "parent": [],
+ "deleted": [],
+ "lazy_blocked": [],
+ "deployment": [
+ "notBlank"
+ ],
+ "backend_need_reap": [],
+ "instance_uuid": [],
+ "numberCores": [
+ "notBlank"
+ ],
+ "name": [
+ "notBlank"
+ ],
+ "created": [],
+ "write_protect": [],
+ "isolation": [
+ "notBlank"
+ ],
+ "no_policy": [],
+ "instance_id": [],
+ "volumes": []
+ },
+ "id": 3,
+ "created": "2017-03-17T23:15:13.556863Z",
+ "updated": "2017-03-17T23:15:13.555271Z",
+ "enacted": "2017-03-17T23:15:24.376854Z",
+ "policed": "2017-03-17T23:15:14.991037Z",
+ "backend_register": "{\"next_run\": 0, \"last_success\": 1489792538.996003, \"exponent\": 0}",
+ "backend_status": "1 - OK",
+ "instance_id": "instance-00000003",
+ "instance_uuid": "ec5ece6d-bebe-4165-98c5-3a026a41c63c",
+ "name": "mysite_vsg",
+ "instance_name": "mysite_vsg-3",
+ "ip": "10.1.0.17",
+ "image": "http://ms1333.utah.cloudlab.us:8080/api/core/images/1/",
+ "creator": "http://ms1333.utah.cloudlab.us:8080/api/core/users/1/",
+ "slice": "http://ms1333.utah.cloudlab.us:8080/api/core/slices/2/",
+ "deployment": "http://ms1333.utah.cloudlab.us:8080/api/core/deployments/1/",
+ "node": "http://ms1333.utah.cloudlab.us:8080/api/core/nodes/1/",
+ "numberCores": 0,
+ "flavor": "http://ms1333.utah.cloudlab.us:8080/api/core/flavors/1/",
+ "isolation": "vm",
+ "volumes": "/etc/dnsmasq.d,/etc/ufw"
}
+ ]
+ }
input_dict = {
"s_tag" : "111",
"c_tag" : "222",
@@ -243,10 +477,10 @@
#data=test.jsonToList("Subscribers.json","SubscriberInfo")
#print test.jsonToList("Subscribers.json","SubscriberInfo")
#print "index 1...",test.listToDict(data,1)
-#result = test.getDictFromListOfDict(dict_list,"email",21)
+result = test.getDictFromListOfDict(dict_list,"instance_name","mysite_vsg-3")
#result = test.getFieldValueFromDict(dict_list,"id")
#result = test.getDictFromListOfDict(dict_list,"account_num",21)
#result = test.setFieldValueInDict(input_dict,"subscriber",new_value)
-result = test.getAllFieldValues(list1,"instance_name")
+#result = test.getAllFieldValues(list1,"instance_name")
print "finalllllll result....", result
'''