Modify test scripts of F version and add instructions about it 96/102196/4
authoryangyan <yangyanyj@chinamobile.com>
Mon, 24 Feb 2020 06:24:37 +0000 (14:24 +0800)
committeryangyan <yangyanyj@chinamobile.com>
Tue, 25 Feb 2020 03:26:54 +0000 (11:26 +0800)
Change-Id: Ic0fb0effc701c47ee5609a5cb88d25619ce05c69
Issue-ID: VFC-1621
Signed-off-by: yangyan <yangyanyj@chinamobile.com>
24 files changed:
resources/testscripts/F-version/ns/Instructions [new file with mode: 0644]
resources/testscripts/F-version/ns/ns_create.py
resources/testscripts/F-version/ns/ns_delete.py
resources/testscripts/F-version/ns/ns_download.py [new file with mode: 0644]
resources/testscripts/F-version/ns/ns_get.py
resources/testscripts/F-version/ns/ns_get_one.py
resources/testscripts/F-version/ns/ns_upload.py
resources/testscripts/F-version/ns_instance/create.py
resources/testscripts/F-version/ns_instance/del.py
resources/testscripts/F-version/ns_instance/get.py
resources/testscripts/F-version/ns_instance/get_job_id.py
resources/testscripts/F-version/ns_instance/get_one.py
resources/testscripts/F-version/ns_instance/instance.py
resources/testscripts/F-version/ns_instance/instructions [new file with mode: 0644]
resources/testscripts/F-version/ns_instance/terminate.py
resources/testscripts/F-version/vnf/Instruticons [new file with mode: 0644]
resources/testscripts/F-version/vnf/vnf_create.py
resources/testscripts/F-version/vnf/vnf_delete.py
resources/testscripts/F-version/vnf/vnf_download.py [new file with mode: 0644]
resources/testscripts/F-version/vnf/vnf_get.py
resources/testscripts/F-version/vnf/vnf_get_one.py
resources/testscripts/F-version/vnf/vnf_upload.py
resources/testscripts/__init__.py [new file with mode: 0644]
resources/testscripts/const.py [new file with mode: 0644]

diff --git a/resources/testscripts/F-version/ns/Instructions b/resources/testscripts/F-version/ns/Instructions
new file mode 100644 (file)
index 0000000..6994ded
--- /dev/null
@@ -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
index 32f39f5..eca0b68 100644 (file)
@@ -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
index aa3eb2b..9638586 100644 (file)
@@ -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 (file)
index 0000000..5ad12d8
--- /dev/null
@@ -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()
index 2ecb31b..9403592 100644 (file)
@@ -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())
index c4c484c..79d9fdf 100644 (file)
@@ -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())
index f91c80b..d4e435b 100644 (file)
@@ -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)
index e3fa51e..852dbc3 100644 (file)
@@ -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"
index 04e3b2e..5b64384 100644 (file)
@@ -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)
index ab741c3..984ea9c 100644 (file)
@@ -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())
index 4fbf7c9..3ed9991 100644 (file)
@@ -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())
index 63de7d5..5fbc83c 100644 (file)
@@ -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())
index 43e81e8..f202e18 100644 (file)
@@ -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 (file)
index 0000000..af96eb4
--- /dev/null
@@ -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
index 9d214c8..4b1ca31 100644 (file)
@@ -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 (file)
index 0000000..52c2c6e
--- /dev/null
@@ -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
index 1bc9e39..537aa3b 100644 (file)
@@ -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
index cd85ddf..7857878 100644 (file)
@@ -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 (file)
index 0000000..0f59988
--- /dev/null
@@ -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()
index 107b7dd..df14bd7 100644 (file)
@@ -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())
index 56998fd..a0b0be6 100644 (file)
@@ -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())
index 074f298..33b39df 100644 (file)
@@ -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 (file)
index 0000000..e69de29
diff --git a/resources/testscripts/const.py b/resources/testscripts/const.py
new file mode 100644 (file)
index 0000000..143e11b
--- /dev/null
@@ -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"