diff options
author | yangyan <yangyanyj@chinamobile.com> | 2020-02-24 14:24:37 +0800 |
---|---|---|
committer | yangyan <yangyanyj@chinamobile.com> | 2020-02-25 11:26:54 +0800 |
commit | 590f3a6fd34225ac6d48666803a83721bcb35c97 (patch) | |
tree | da6bc3d7a395cd95c35ad8fd9dea2b314202e73f /resources | |
parent | a84c8a335a496627881401400b801de859efc9cb (diff) |
Modify test scripts of F version and add instructions about it
Change-Id: Ic0fb0effc701c47ee5609a5cb88d25619ce05c69
Issue-ID: VFC-1621
Signed-off-by: yangyan <yangyanyj@chinamobile.com>
Diffstat (limited to 'resources')
24 files changed, 202 insertions, 26 deletions
diff --git a/resources/testscripts/F-version/ns/Instructions b/resources/testscripts/F-version/ns/Instructions new file mode 100644 index 00000000..6994dedd --- /dev/null +++ b/resources/testscripts/F-version/ns/Instructions @@ -0,0 +1,27 @@ + +# msb_create +The Python script in this folder is used to register ns to msb. +It mainly includes the creation, upload, query acquisition and deletion of msb. + +# msb_upload +When you execute the msb_create script, you get an ID. At this time, you open the msb_upload script, +change the file path to the path where you want to upload the ns CSAR package, +then execute the msb_upload script and place the ID after executing the command, +and the ID will be automatically passed in. + +# msb_download + +By executing this script, you can access the catalog parsing interface and get the parsing content of the + uploaded ns package + +# msb_get +If you want to query the registration status in msb, you can execute the msb_get script directly. + +# msb_delete +If you want to delete an MSB record, you can execute the msb_del script and put the ID generated +at the time of creation after execution of the command. + +Note: You should configure the IP and CSAR file path of MSB in const file + IP address for MSB service + MSB cannot be created repeatedly + The request mode of MSB is HTTPS, and the port of public IP is 30283 diff --git a/resources/testscripts/F-version/ns/ns_create.py b/resources/testscripts/F-version/ns/ns_create.py index 32f39f5b..eca0b68c 100644 --- a/resources/testscripts/F-version/ns/ns_create.py +++ b/resources/testscripts/F-version/ns/ns_create.py @@ -1,7 +1,9 @@ import json import httplib2 -full_url = 'https://192.168.235.89:30283/api/nsd/v1/ns_descriptors' +from testscripts.const import MSB_BASE_URL + +full_url = MSB_BASE_URL + '/api/nsd/v1/ns_descriptors' ud_data = {'userDefinedData': {"key2": "value2"}} headers = {'content-type': 'application/json', 'accept': 'application/json'} ca_certs = None diff --git a/resources/testscripts/F-version/ns/ns_delete.py b/resources/testscripts/F-version/ns/ns_delete.py index aa3eb2b5..96385863 100644 --- a/resources/testscripts/F-version/ns/ns_delete.py +++ b/resources/testscripts/F-version/ns/ns_delete.py @@ -1,8 +1,10 @@ import requests import sys +from testscripts.const import MSB_BASE_URL + id = sys.argv[1] requests.packages.urllib3.disable_warnings() -resp = requests.delete('https://192.168.235.89:30283/api/nsd/v1/ns_descriptors/' + id, verify=False) +resp = requests.delete(MSB_BASE_URL + '/api/nsd/v1/ns_descriptors/' + id, verify=False) print(resp.status_code) diff --git a/resources/testscripts/F-version/ns/ns_download.py b/resources/testscripts/F-version/ns/ns_download.py new file mode 100644 index 00000000..5ad12d80 --- /dev/null +++ b/resources/testscripts/F-version/ns/ns_download.py @@ -0,0 +1,11 @@ +import requests +import sys + +from testscripts.const import MSB_BASE_URL, NS_CSAR_PATH + +id = sys.argv[1] +url = MSB_BASE_URL + '/api/nsd/v1/ns_descriptors/' + id + '/nsd_content' +resp = requests.get(url) +local_file = open(NS_CSAR_PATH, 'wb') +local_file.write(resp.content) +local_file.close() diff --git a/resources/testscripts/F-version/ns/ns_get.py b/resources/testscripts/F-version/ns/ns_get.py index 2ecb31bf..9403592b 100644 --- a/resources/testscripts/F-version/ns/ns_get.py +++ b/resources/testscripts/F-version/ns/ns_get.py @@ -1,5 +1,7 @@ import requests +from testscripts.const import MSB_BASE_URL + requests.packages.urllib3.disable_warnings() -resp = requests.get('https://192.168.235.89:30283/api/nsd/v1/ns_descriptors', verify=False) +resp = requests.get(MSB_BASE_URL + '/api/nsd/v1/ns_descriptors', verify=False) print(resp.status_code, resp.json()) diff --git a/resources/testscripts/F-version/ns/ns_get_one.py b/resources/testscripts/F-version/ns/ns_get_one.py index c4c484cd..79d9fdf4 100644 --- a/resources/testscripts/F-version/ns/ns_get_one.py +++ b/resources/testscripts/F-version/ns/ns_get_one.py @@ -1,8 +1,10 @@ import requests import sys +from testscripts.const import MSB_BASE_URL + id = sys.argv[1] requests.packages.urllib3.disable_warnings() -resp = requests.get('https://192.168.235.89:30283/api/nsd/v1/ns_descriptors/' + id, verify=False) +resp = requests.get(MSB_BASE_URL + '/api/nsd/v1/ns_descriptors/' + id, verify=False) print(resp.status_code, resp.json()) diff --git a/resources/testscripts/F-version/ns/ns_upload.py b/resources/testscripts/F-version/ns/ns_upload.py index f91c80b3..d4e435b8 100644 --- a/resources/testscripts/F-version/ns/ns_upload.py +++ b/resources/testscripts/F-version/ns/ns_upload.py @@ -1,6 +1,10 @@ import requests +import sys +from testscripts.const import MSB_BASE_URL, NS_CSAR_PATH + +id = sys.argv[1] requests.packages.urllib3.disable_warnings() -url = 'https://192.168.235.89:30283/api/nsd/v1/ns_descriptors/84090010-6e67-4536-81cc-61ae7b0b4ecd/nsd_content' -resp = requests.put(url, files={'file': open(r"C:\Users\86187\Desktop\vfc-tests\ns\ns-new\ns_vgw.csar", 'rb')}, verify=False) +url = MSB_BASE_URL + '/api/nsd/v1/ns_descriptors/ + id /nsd_content' +resp = requests.put(url, files={'file': open(NS_CSAR_PATH, 'rb')}, verify=False) print(resp.status_code) diff --git a/resources/testscripts/F-version/ns_instance/create.py b/resources/testscripts/F-version/ns_instance/create.py index e3fa51ef..852dbc32 100644 --- a/resources/testscripts/F-version/ns_instance/create.py +++ b/resources/testscripts/F-version/ns_instance/create.py @@ -1,17 +1,19 @@ import json import httplib2 +from testscripts.const import MSB_BASE_URL, GLOBAL_CUSTOMER_Id, SERVICE_TYPE, CSAR_ID, NS_NAME, DESCRIPTION + data = { "context": { - "globalCustomerId": "global-customer-id-test1", - "serviceType": "service-type-test1" + "globalCustomerId": GLOBAL_CUSTOMER_Id, + "serviceType": SERVICE_TYPE }, - "csarId": "d5d678dc-80ef-461e-8630-d105f43b0a18", - "nsName": "ns_vsn", - "description": "description" + "csarId": CSAR_ID, + "nsName": NS_NAME, + "description": DESCRIPTION } -full_url = 'https://192.168.235.89:30283/api/nslcm/v1/ns' +full_url = MSB_BASE_URL + '/api/nslcm/v1/ns' headers = {'content-type': 'application/json', 'accept': 'application/json'} ca_certs = None auth_type = "rest_no_auth" diff --git a/resources/testscripts/F-version/ns_instance/del.py b/resources/testscripts/F-version/ns_instance/del.py index 04e3b2e5..5b64384e 100644 --- a/resources/testscripts/F-version/ns_instance/del.py +++ b/resources/testscripts/F-version/ns_instance/del.py @@ -1,6 +1,9 @@ import requests import sys +from testscripts.const import MSB_BASE_URL + +requests.packages.urllib3.disable_warnings() id = sys.argv[1] -resp = requests.delete('https://192.168.235.89:30283/api/nslcm/v1/ns/' + id, verify=False) +resp = requests.delete(MSB_BASE_URL + '/api/nslcm/v1/ns/' + id, verify=False) print(resp.status_code) diff --git a/resources/testscripts/F-version/ns_instance/get.py b/resources/testscripts/F-version/ns_instance/get.py index ab741c35..984ea9c1 100644 --- a/resources/testscripts/F-version/ns_instance/get.py +++ b/resources/testscripts/F-version/ns_instance/get.py @@ -1,5 +1,7 @@ import requests +from testscripts.const import MSB_BASE_URL + requests.packages.urllib3.disable_warnings() -resp = requests.get('https://192.168.235.89:30283/api/nslcm/v1/ns', verify=False) +resp = requests.get(MSB_BASE_URL + '/api/nslcm/v1/ns', verify=False) print(resp.status_code, resp.json()) diff --git a/resources/testscripts/F-version/ns_instance/get_job_id.py b/resources/testscripts/F-version/ns_instance/get_job_id.py index 4fbf7c90..3ed9991e 100644 --- a/resources/testscripts/F-version/ns_instance/get_job_id.py +++ b/resources/testscripts/F-version/ns_instance/get_job_id.py @@ -1,9 +1,11 @@ import requests import sys +from testscripts.const import MSB_BASE_URL + requests.packages.urllib3.disable_warnings() jobId = '1' if len(sys.argv) > 1: jobId = sys.argv[1] -resp = requests.get('https://192.168.235.89:30283/api/nslcm/v1/jobs/%s' % jobId, verify=False) +resp = requests.get(MSB_BASE_URL + '/api/nslcm/v1/jobs/%s' % jobId, verify=False) print(resp.status_code, resp.json()) diff --git a/resources/testscripts/F-version/ns_instance/get_one.py b/resources/testscripts/F-version/ns_instance/get_one.py index 63de7d52..5fbc83cc 100644 --- a/resources/testscripts/F-version/ns_instance/get_one.py +++ b/resources/testscripts/F-version/ns_instance/get_one.py @@ -1,7 +1,9 @@ import requests import sys +from testscripts.const import MSB_BASE_URL + id = sys.argv[1] requests.packages.urllib3.disable_warnings() -resp = requests.get('https://192.168.235.89:30283/api/nslcm/v1/ns/' + id, verify=False) +resp = requests.get(MSB_BASE_URL + '/api/nslcm/v1/ns/' + id, verify=False) print(resp.status_code, resp.json()) diff --git a/resources/testscripts/F-version/ns_instance/instance.py b/resources/testscripts/F-version/ns_instance/instance.py index 43e81e8b..f202e189 100644 --- a/resources/testscripts/F-version/ns_instance/instance.py +++ b/resources/testscripts/F-version/ns_instance/instance.py @@ -1,15 +1,18 @@ import json import httplib2 import sys + +from testscripts.const import VNF_PROFILE_ID, VIM_ID, MSB_BASE_URL + ns_instance_Id = sys.argv[1] data = { "additionalParamForNs": { "sdnControllerId": "2" }, "locationConstraints": [{ - "vnfProfileId": "45711f40-3f43-415b-bb45-46e5c6940735", + "vnfProfileId": VNF_PROFILE_ID, "locationConstraints": { - "vimId": "CPE-DC_RegionOne" + "vimId": VIM_ID } }] } @@ -18,6 +21,6 @@ ca_certs = None auth_type = "rest_no_auth" http = httplib2.Http(ca_certs=ca_certs, disable_ssl_certificate_validation=(auth_type == "rest_no_auth")) http.follow_all_redirects = True -resp, resp_content = http.request('https://192.168.235.89:30283/api/nslcm/v1/ns/' + ns_instance_Id + '/instantiate', +resp, resp_content = http.request(MSB_BASE_URL + '/api/nslcm/v1/ns/' + ns_instance_Id + '/instantiate', method="POST", body=json.dumps(data), headers=headers) print(resp['status'], resp_content) diff --git a/resources/testscripts/F-version/ns_instance/instructions b/resources/testscripts/F-version/ns_instance/instructions new file mode 100644 index 00000000..af96eb4b --- /dev/null +++ b/resources/testscripts/F-version/ns_instance/instructions @@ -0,0 +1,51 @@ +This process is ns instantiation process +When the NS and vnf packages are uploaded and the MSB is registered successfully. +the instantiation operation begins. +This process mainly includes ns creation, instantiation, information query acquisition, +instance termination and data deletion after termination. + +# create + +Prepare the data before instance creation according to your needs, +and replace the CSAR ID generated after uploading package management. +When the execution is completed, an instance ID and other data are returned. + +# instance + +This process also prepares the data according to the requirement of creating the instance itself, +returns the instance ID after executing the create script, +and then executes the script after executing the script command. At this point, +the instance ID will be passed into the script, and a series of instantiation operations will be started, +and the virtual machine will be created. + +# get + +If you want to get some data generated during instance creation, you can execute the script +The script can query all the instance information in the database. + +# get_one + +If you want to get some instance data during instance creation, you can execute the script +The script only queries the content of an instance information, +executes the script command and puts the created instance ID after the command, +then the query can be completed. + +# terminate + +After the instantiation process is successfully created, +if you want to terminate the instantiation, execute the script. +The virtual machine generated after the script execution will also stop, +as well as some data deletion, termination of services. +After the script command is executed, the instance ID needs to be added after the command. + +# delete + +Some data will remain after termination. Execute the script to clear the data in the database. +The instance ID is also required to execute this process. +The completion of this process indicates the end of an instance creation termination process. + +Note: You should configure the IP and CSAR file path of MSB in const file + IP address for MSB service + NS cannot be created repeatedly + Update test scripts of ns_instance + The request mode of MSB is HTTPS, and the port of public IP is 30283 diff --git a/resources/testscripts/F-version/ns_instance/terminate.py b/resources/testscripts/F-version/ns_instance/terminate.py index 9d214c8c..4b1ca31c 100644 --- a/resources/testscripts/F-version/ns_instance/terminate.py +++ b/resources/testscripts/F-version/ns_instance/terminate.py @@ -2,6 +2,8 @@ import json import httplib2 import sys +from testscripts.const import MSB_BASE_URL + id = sys.argv[1] data = { "gracefulTerminationTimeout": 600, @@ -12,7 +14,7 @@ ca_certs = None auth_type = "rest_no_auth" http = httplib2.Http(ca_certs=ca_certs, disable_ssl_certificate_validation=(auth_type == "rest_no_auth")) http.follow_all_redirects = True -resp, resp_content = http.request('https://192.168.235.89:30283/api/nslcm/v1/ns/' + id + '/terminate', +resp, resp_content = http.request(MSB_BASE_URL + '/api/nslcm/v1/ns/' + id + '/terminate', method="POST", body=json.dumps(data), headers=headers) diff --git a/resources/testscripts/F-version/vnf/Instruticons b/resources/testscripts/F-version/vnf/Instruticons new file mode 100644 index 00000000..52c2c6eb --- /dev/null +++ b/resources/testscripts/F-version/vnf/Instruticons @@ -0,0 +1,27 @@ + +# msb_create +The Python script in this folder is used to register vnf to msb. +It mainly includes the creation, upload, query acquisition and deletion of msb. + +# msb_upload +When the msb_create script is executed, an ID is obtained. +At this time, the msb_upload script is opened, the file path is changed to the path of the CSAR package +you want to upload vnf. Then the msb_upload script is executed and the ID is placed after the +command is executed, and the ID is automatically passed in. + +# msb_download + +By executing this script, you can access the catalog parsing interface and get the parsing content of the + uploaded vnf package + +# msb_get +If you want to query the registration status in msb, you can execute the msb_get script directly. + +# msb_delete +If you want to delete an MSB record, you can execute the msb_del script and put the ID +generated at the time of creation after execution of the command. + +Note: You should configure the IP and CSAR file path of MSB in const file + IP address for MSB service + MSB cannot be created repeatedly + The request mode of MSB is HTTPS, and the port of public IP is 30283
\ No newline at end of file diff --git a/resources/testscripts/F-version/vnf/vnf_create.py b/resources/testscripts/F-version/vnf/vnf_create.py index 1bc9e391..537aa3b6 100644 --- a/resources/testscripts/F-version/vnf/vnf_create.py +++ b/resources/testscripts/F-version/vnf/vnf_create.py @@ -1,7 +1,9 @@ import json import httplib2 -full_url = 'https://192.168.235.89:30283/api/vnfpkgm/v1/vnf_packages' +from testscripts.const import MSB_BASE_URL + +full_url = MSB_BASE_URL + '/api/vnfpkgm/v1/vnf_packages' ud_data = {'userDefinedData': {"key2": "value2"}} headers = {'content-type': 'application/json', 'accept': 'application/json'} ca_certs = None diff --git a/resources/testscripts/F-version/vnf/vnf_delete.py b/resources/testscripts/F-version/vnf/vnf_delete.py index cd85ddf8..7857878e 100644 --- a/resources/testscripts/F-version/vnf/vnf_delete.py +++ b/resources/testscripts/F-version/vnf/vnf_delete.py @@ -1,8 +1,10 @@ import requests import sys +from testscripts.const import MSB_BASE_URL + id = sys.argv[1] requests.packages.urllib3.disable_warnings() -resp = requests.delete('https://192.168.235.89:30283/api/vnfpkgm/v1/vnf_packages/' + id, verify=False) +resp = requests.delete(MSB_BASE_URL + '/api/vnfpkgm/v1/vnf_packages/' + id, verify=False) print(resp.status_code) diff --git a/resources/testscripts/F-version/vnf/vnf_download.py b/resources/testscripts/F-version/vnf/vnf_download.py new file mode 100644 index 00000000..0f599880 --- /dev/null +++ b/resources/testscripts/F-version/vnf/vnf_download.py @@ -0,0 +1,12 @@ +import requests +import sys + +from testscripts.const import MSB_BASE_URL, VNF_CSAR_PATH + +requests.packages.urllib3.disable_warnings() +id = sys.argv[1] +url = MSB_BASE_URL + '/api/vnfpkgm/v1/vnf_packages/' + id + '/package_content' +resp = requests.get(url, verify=False) +local_file = open(VNF_CSAR_PATH, 'wb') +local_file.write(resp.content) +local_file.close() diff --git a/resources/testscripts/F-version/vnf/vnf_get.py b/resources/testscripts/F-version/vnf/vnf_get.py index 107b7dd8..df14bd76 100644 --- a/resources/testscripts/F-version/vnf/vnf_get.py +++ b/resources/testscripts/F-version/vnf/vnf_get.py @@ -1,5 +1,7 @@ import requests +from testscripts.const import MSB_BASE_URL + requests.packages.urllib3.disable_warnings() -resp = requests.get('https://192.168.235.89:30283/api/vnfpkgm/v1/vnf_packages', verify=False) +resp = requests.get(MSB_BASE_URL + '/api/vnfpkgm/v1/vnf_packages', verify=False) print(resp.status_code, resp.json()) diff --git a/resources/testscripts/F-version/vnf/vnf_get_one.py b/resources/testscripts/F-version/vnf/vnf_get_one.py index 56998fdf..a0b0be6c 100644 --- a/resources/testscripts/F-version/vnf/vnf_get_one.py +++ b/resources/testscripts/F-version/vnf/vnf_get_one.py @@ -1,8 +1,10 @@ import requests import sys +from testscripts.const import MSB_BASE_URL + id = sys.argv[1] requests.packages.urllib3.disable_warnings() -resp = requests.get('https://192.168.235.89:30283/api/vnfpkgm/v1/vnf_packages/' + id, verify=False) +resp = requests.get(MSB_BASE_URL + '/api/vnfpkgm/v1/vnf_packages/' + id, verify=False) print(resp.status_code, resp.json()) diff --git a/resources/testscripts/F-version/vnf/vnf_upload.py b/resources/testscripts/F-version/vnf/vnf_upload.py index 074f298c..33b39dff 100644 --- a/resources/testscripts/F-version/vnf/vnf_upload.py +++ b/resources/testscripts/F-version/vnf/vnf_upload.py @@ -1,9 +1,11 @@ import requests import sys +from testscripts.const import MSB_BASE_URL, VNF_CSAR_PATH + id = sys.argv[1] requests.packages.urllib3.disable_warnings() -url = 'https://192.168.235.89:30283/api/vnfpkgm/v1/vnf_packages/' + id + '/package_content' -resp = requests.put(url, files={'file': open(r"C:\Users\86187\Desktop\vfc-tests\vgw.csar", 'rb')}, verify=False) +url = MSB_BASE_URL + '/api/vnfpkgm/v1/vnf_packages/' + id + '/package_content' +resp = requests.put(url, files={'file': open(VNF_CSAR_PATH, 'rb')}, verify=False) print(resp.status_code) diff --git a/resources/testscripts/__init__.py b/resources/testscripts/__init__.py new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/resources/testscripts/__init__.py diff --git a/resources/testscripts/const.py b/resources/testscripts/const.py new file mode 100644 index 00000000..143e11bf --- /dev/null +++ b/resources/testscripts/const.py @@ -0,0 +1,10 @@ +MSB_BASE_URL = "You should change it according to your environment" +NS_CSAR_PATH = r"You should change it according to your environment" +VNF_CSAR_PATH = r"You should change it according to your environment" +GLOBAL_CUSTOMER_Id = "You should change it according to your environment" +SERVICE_TYPE = "You should change it according to your environment" +CSAR_ID = "You should change it according to your environment" +NS_NAME = "You should change it according to your environment" +DESCRIPTION = "description" +VNF_PROFILE_ID = "You should change it according to your environment" +VIM_ID = "You should change it according to your environment" |