diff options
-rw-r--r-- | test/postman/08_Declare_Customer_Service_Subscription_Cloud.postman_collection.json | 245 | ||||
-rw-r--r-- | test/postman/10_Service_Order.postman_collection.json | 6 | ||||
-rw-r--r-- | test/postman/README.md | 34 |
3 files changed, 270 insertions, 15 deletions
diff --git a/test/postman/08_Declare_Customer_Service_Subscription_Cloud.postman_collection.json b/test/postman/08_Declare_Customer_Service_Subscription_Cloud.postman_collection.json index f100c33f2..faa53d2f7 100644 --- a/test/postman/08_Declare_Customer_Service_Subscription_Cloud.postman_collection.json +++ b/test/postman/08_Declare_Customer_Service_Subscription_Cloud.postman_collection.json @@ -448,6 +448,175 @@ "response": [] }, { + "name": "check complex exists", + "event": [ + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "var complex_found = false;", + "if (responseCode.code === 404) {", + " tests[postman.getGlobalVariable(\"complex_name\")+\" does not exists in AAI\"] = true;", + "}", + "else {", + " if (responseCode.code === 200) {", + " tests[\"Status code is 200\"] = responseCode.code === 200;", + " }", + "var jsonData = JSON.parse(responseBody);", + "for (var i = 0; i < jsonData[\"complex\"].length; i++) { ", + " if (jsonData[\"complex\"][i][\"complex-name\"] === postman.getGlobalVariable(\"complex_name\")) {", + " complex_found = true;", + " }", + "}", + "", + "if (complex_found === false) {", + " tests[postman.getGlobalVariable(\"complex_name\")+\" does not exists\"] = true;", + "}", + "else {", + " tests[postman.getGlobalVariable(\"complex_name\")+\" already exists, we skip creation\"] = true;", + " postman.setNextRequest(\"check cloud-region exists\");", + "}", + "}" + ] + } + } + ], + "request": { + "url": "{{url-aai}}/aai/v14/cloud-infrastructure/complexes", + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic QUFJOkFBSQ==", + "description": "" + }, + { + "key": "X-FromAppId", + "value": "AAI", + "description": "" + }, + { + "key": "Accept", + "value": "application/json", + "description": "" + }, + { + "key": "X-TransactionId", + "value": "808b54e3-e563-4144-a1b9-e24e2ed93d4f", + "description": "" + } + ], + "body": {}, + "description": "" + }, + "response": [] + }, + { + "name": "create Complex", + "event": [ + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "tests[\"Status code is 201\"] = responseCode.code === 201;" + ] + } + } + ], + "request": { + "url": "{{url-aai}}/aai/v14/cloud-infrastructure/complexes/complex/{{complex_name}}", + "method": "PUT", + "header": [ + { + "key": "Authorization", + "value": "Basic QUFJOkFBSQ==", + "description": "" + }, + { + "key": "X-FromAppId", + "value": "AAI", + "description": "" + }, + { + "key": "Accept", + "value": "application/json", + "description": "" + }, + { + "key": "X-TransactionId", + "value": "808b54e3-e563-4144-a1b9-e24e2ed93d4f", + "description": "" + }, + { + "key": "Content-Type", + "value": "application/json", + "description": "" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"physical-location-id\": \"{{complex_name}}\",\n \"data-center-code\": \"\",\n \"complex-name\": \"{{complex_name}}\",\n \"identity-url\": \"\",\n \"physical-location-type\": \"\",\n \"street1\": \"\",\n \"street2\": \"\",\n \"city\": \"\",\n \"state\": \"\",\n \"postal-code\": \"\",\n \"country\": \"\",\n \"region\": \"\",\n \"latitude\": \"\",\n \"longitude\": \"\",\n \"elevation\": \"\",\n \"lata\": \"\"\n}" + }, + "description": "" + }, + "response": [] + }, + { + "name": "Check complex creation", + "event": [ + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "tests[\"Status code is 200\"] = responseCode.code === 200;", + "", + "var jsonData = JSON.parse(responseBody);", + "var complex_found = false;", + "for (var i = 0; i < jsonData[\"complex\"].length; i++) { ", + " if (jsonData[\"complex\"][i][\"complex-name\"] === postman.getGlobalVariable(\"complex_name\")) {", + " complex_found = true;", + " }", + "}", + "tests[postman.getGlobalVariable(\"complex_name\")+\" found\"] = complex_found === true;", + "" + ] + } + } + ], + "request": { + "url": "{{url-aai}}/aai/v14/cloud-infrastructure/complexes", + "method": "GET", + "header": [ + { + "key": "Authorization", + "value": "Basic QUFJOkFBSQ==", + "description": "" + }, + { + "key": "X-FromAppId", + "value": "AAI", + "description": "" + }, + { + "key": "Accept", + "value": "application/json", + "description": "" + }, + { + "key": "X-TransactionId", + "value": "808b54e3-e563-4144-a1b9-e24e2ed93d4f", + "description": "" + } + ], + "body": {}, + "description": "" + }, + "response": [] + }, + { "name": "check cloud-region exists", "event": [ { @@ -457,7 +626,7 @@ "exec": [ "var region_found = false;", "if (responseCode.code === 404) {", - " tests[postman.getGlobalVariable(\"cloud_region_id\")+\" does not exists in AAI\"] = true;", + " tests[postman.getGlobalVariable(\"onap_cloud_region_id\")+\" does not exists in AAI\"] = true;", "}", "else {", " if (responseCode.code === 200) {", @@ -465,16 +634,16 @@ " }", "var jsonData = JSON.parse(responseBody);", "for (var i = 0; i < jsonData[\"cloud-region\"].length; i++) { ", - " if (jsonData[\"cloud-region\"][i][\"cloud-region-id\"] === postman.getGlobalVariable(\"cloud_region_id\")) {", + " if (jsonData[\"cloud-region\"][i][\"cloud-region-id\"] === postman.getGlobalVariable(\"onap_cloud_region_id\")) {", " region_found = true;", " }", "}", "", "if (region_found === false) {", - " tests[postman.getGlobalVariable(\"cloud_region_id\")+\" does not exists\"] = true;", + " tests[postman.getGlobalVariable(\"onap_cloud_region_id\")+\" does not exists\"] = true;", "}", "else {", - " tests[postman.getGlobalVariable(\"cloud_region_id\")+\" already exists, we skip creation\"] = true;", + " tests[postman.getGlobalVariable(\"onap_cloud_region_id\")+\" already exists, we skip creation\"] = true;", " postman.setNextRequest(\"check tenant in cloud region\");", "}", "}" @@ -526,7 +695,7 @@ } ], "request": { - "url": "{{url-aai}}/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/{{cloud_owner_name}}/{{cloud_region_id}}", + "url": "{{url-aai}}/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/{{cloud_owner_name}}/{{onap_cloud_region_id}}", "method": "PUT", "header": [ { @@ -557,7 +726,7 @@ ], "body": { "mode": "raw", - "raw": "{\r\n \"cloud-owner\": \"{{cloud_owner_name}}\",\r\n \"cloud-region-id\": \"{{cloud_region_id}}\",\r\n \"cloud-type\": \"openstack\",\r\n \"owner-defined-type\": \"\",\r\n \"cloud-region-version\": \"\",\r\n \"cloud-zone\": \"\",\r\n \"complex-name\": \"\",\r\n \"identity-url\": \"\",\r\n \"sriov-automation\": false,\r\n \"cloud-extra-info\": \"\"\r\n}" + "raw": "{\r\n \"cloud-owner\": \"{{cloud_owner_name}}\",\r\n \"cloud-region-id\": \"{{onap_cloud_region_id}}\",\r\n \"cloud-type\": \"{{cloud_type}}\",\r\n \"owner-defined-type\": \"\",\r\n \"cloud-region-version\": \"{{cloud_region_version}}\",\r\n \"cloud-zone\": \"\",\r\n \"complex-name\": \"{{complex_name}}\",\r\n \"identity-url\": \"WillBeUpdatedByMultiCloud\",\r\n \"sriov-automation\": false,\r\n \"cloud-extra-info\": \"{\\\"openstack-region-id\\\":\\\"{{openstack_region_id}}\\\"}\",\r\n \"esr-system-info-list\": {\r\n \t\"esr-system-info\": [\r\n {\r\n \"esr-system-info-id\": \"{{random_uuid}}\",\r\n \"service-url\": \"{{keystone_url}}\",\r\n \"user-name\": \"{{user_name}}\",\r\n \"password\": \"{{keystone_password}}\",\r\n \"system-type\": \"VIM\",\r\n \"ssl-insecure\": true,\r\n \"cloud-domain\": \"Default\",\r\n \"default-tenant\": \"{{tenant_name}}\",\r\n \"system-status\": \"active\"\r\n }\r\n ]\r\n }\r\n}" }, "description": "" }, @@ -576,11 +745,11 @@ "var jsonData = JSON.parse(responseBody);", "var region_found = false;", "for (var i = 0; i < jsonData[\"cloud-region\"].length; i++) { ", - " if (jsonData[\"cloud-region\"][i][\"cloud-region-id\"] === postman.getGlobalVariable(\"cloud_region_id\")) {", + " if (jsonData[\"cloud-region\"][i][\"cloud-region-id\"] === postman.getGlobalVariable(\"onap_cloud_region_id\")) {", " region_found = true;", " }", "}", - "tests[postman.getGlobalVariable(\"cloud_region_id\")+\" found\"] = region_found === true;", + "tests[postman.getGlobalVariable(\"onap_cloud_region_id\")+\" found\"] = region_found === true;", "" ] } @@ -617,6 +786,58 @@ "response": [] }, { + "name": "associate Cloud-region to a complex", + "event": [ + { + "listen": "test", + "script": { + "type": "text/javascript", + "exec": [ + "tests[\"Status code is 200 : cloud-region associated to a complex\"] = responseCode.code === 200;", + "" + ] + } + } + ], + "request": { + "url": "{{url-aai}}/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/{{cloud_owner_name}}/{{onap_cloud_region_id}}/relationship-list/relationship", + "method": "PUT", + "header": [ + { + "key": "Authorization", + "value": "Basic QUFJOkFBSQ==", + "description": "" + }, + { + "key": "X-FromAppId", + "value": "AAI", + "description": "" + }, + { + "key": "Accept", + "value": "application/json", + "description": "" + }, + { + "key": "X-TransactionId", + "value": "808b54e3-e563-4144-a1b9-e24e2ed93d4f", + "description": "" + }, + { + "key": "Content-Type", + "value": "application/json", + "description": "" + } + ], + "body": { + "mode": "raw", + "raw": "{\n \"related-to\": \"complex\",\n \"related-link\": \"/aai/v13/cloud-infrastructure/complexes/complex/{{complex_name}}\",\n \"relationship-data\": [\n {\n \"relationship-key\": \"complex.physical-location-id\",\n \"relationship-value\": \"{{complex_name}}\"\n }\n ]\n }" + }, + "description": "" + }, + "response": [] + }, + { "name": "check tenant in cloud region", "event": [ { @@ -660,7 +881,7 @@ } ], "request": { - "url": "{{url-aai}}/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/{{cloud_owner_name}}/{{cloud_region_id}}/tenants", + "url": "{{url-aai}}/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/{{cloud_owner_name}}/{{onap_cloud_region_id}}/tenants", "method": "GET", "header": [ { @@ -708,7 +929,7 @@ } ], "request": { - "url": "{{url-aai}}/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/{{cloud_owner_name}}/{{cloud_region_id}}/tenants/tenant/{{tenant_id}}", + "url": "{{url-aai}}/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/{{cloud_owner_name}}/{{onap_cloud_region_id}}/tenants/tenant/{{tenant_id}}", "method": "PUT", "header": [ { @@ -769,7 +990,7 @@ } ], "request": { - "url": "{{url-aai}}/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/{{cloud_owner_name}}/{{cloud_region_id}}/tenants", + "url": "{{url-aai}}/aai/v14/cloud-infrastructure/cloud-regions/cloud-region/{{cloud_owner_name}}/{{onap_cloud_region_id}}/tenants", "method": "GET", "header": [ { @@ -971,7 +1192,7 @@ ], "body": { "mode": "raw", - "raw": "{\r\n\t\"service-type\": \"{{service}}\",\r\n\t\"relationship-list\": {\r\n\t\t\"relationship\": [{\r\n\t\t\t\"related-to\": \"tenant\",\r\n\t\t\t\"related-link\": \"https://aai.api.simpledemo.onap.org:8443/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/{{cloud_owner_name}}/{{cloud_region_id}}/tenants/tenant/{{tenant_id}}\",\r\n\t\t\t\"relationship-data\": [{\r\n\t\t\t\t\t\"relationship-key\": \"cloud-region.cloud-owner\",\r\n\t\t\t\t\t\"relationship-value\": \"{{cloud_owner_name}}\"\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"relationship-key\": \"cloud-region.cloud-region-id\",\r\n\t\t\t\t\t\"relationship-value\": \"{{cloud_region_id}}\"\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"relationship-key\": \"tenant.tenant-id\",\r\n\t\t\t\t\t\"relationship-value\": \"{{tenant_id}}\"\r\n\t\t\t\t}\r\n\t\t\t],\r\n\t\t\t\"related-to-property\": [{\r\n\t\t\t\t\"property-key\": \"tenant.tenant-name\",\r\n\t\t\t\t\"property-value\": \"{{tenant_name}}\"\r\n\t\t\t}]\r\n\t\t}]\r\n\t}\r\n}" + "raw": "{\r\n\t\"service-type\": \"{{service}}\",\r\n\t\"relationship-list\": {\r\n\t\t\"relationship\": [{\r\n\t\t\t\"related-to\": \"tenant\",\r\n\t\t\t\"related-link\": \"https://aai.api.simpledemo.onap.org:8443/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/{{cloud_owner_name}}/{{onap_cloud_region_id}}/tenants/tenant/{{tenant_id}}\",\r\n\t\t\t\"relationship-data\": [{\r\n\t\t\t\t\t\"relationship-key\": \"cloud-region.cloud-owner\",\r\n\t\t\t\t\t\"relationship-value\": \"{{cloud_owner_name}}\"\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"relationship-key\": \"cloud-region.cloud-region-id\",\r\n\t\t\t\t\t\"relationship-value\": \"{{onap_cloud_region_id}}\"\r\n\t\t\t\t},\r\n\t\t\t\t{\r\n\t\t\t\t\t\"relationship-key\": \"tenant.tenant-id\",\r\n\t\t\t\t\t\"relationship-value\": \"{{tenant_id}}\"\r\n\t\t\t\t}\r\n\t\t\t],\r\n\t\t\t\"related-to-property\": [{\r\n\t\t\t\t\"property-key\": \"tenant.tenant-name\",\r\n\t\t\t\t\"property-value\": \"{{tenant_name}}\"\r\n\t\t\t}]\r\n\t\t}]\r\n\t}\r\n}" }, "description": "" }, diff --git a/test/postman/10_Service_Order.postman_collection.json b/test/postman/10_Service_Order.postman_collection.json index 0903b1a3c..1668b762c 100644 --- a/test/postman/10_Service_Order.postman_collection.json +++ b/test/postman/10_Service_Order.postman_collection.json @@ -176,7 +176,11 @@ "tests[\"service_order_id exists\"] = jsonData.id === postman.getGlobalVariable(\"auto_service_order_id\");", "tests[\"service Order state is COMPLETED\"] = jsonData.state === \"COMPLETED\";", "tests[\"Service Instance state is ACTIVE\"] = jsonData.orderItem[0].service.serviceState === \"active\";", - "postman.setGlobalVariable(\"auto_service_instance_id\", \"\"+jsonData.orderItem[0].service.id+\"\");", + "", + "if(jsonData.hasOwnProperty('orderItem.service.id')){", + " postman.setGlobalVariable(\"auto_service_instance_id\", \"\"+jsonData.orderItem.service.id+\"\");", + "}", + "postman.setGlobalVariable(\"auto_service_messageInformation\", \"\"+jsonData.orderMessage[0].messageInformation+\"\");", "" ] } diff --git a/test/postman/README.md b/test/postman/README.md index 86a797b8f..2d65158c7 100644 --- a/test/postman/README.md +++ b/test/postman/README.md @@ -1,6 +1,6 @@ # Postman Collections -## Description +## Using Postman That repository contains 9 Postman collections and 2 environment files. @@ -30,7 +30,7 @@ The order is very important because a lot of API request will need the API response from the previous operation. ![postman](./images/collection-detail-test.png) -It is possible to run the complete collection. +It is possible to run the complete collection using Postman ![postman](./images/run.png) You need, a zip file that contains Heat files for a VNF. @@ -66,3 +66,33 @@ In particular, you need to put your own values for cloud_region_id, tenant_name service_instance_name:integration_test_freeradius_instance_001 listener_url:http://10.4.2.65:8080/externalapi/listener/v1/listener ``` + +## Using Newman + +Newman is a tool that allow to run postman collections via CLI + +Using a Linux server, just run those lines: + +```shell +git clone https://gitlab.com/Orange-OpenSource/lfn/onap/onap-tests.git +cd onap-tests/postman +sudo apt-get -y install zip +USECASE=$'ubuntu16' +zip -j $USECASE.zip ../onap_tests/templates/heat_files/$USECASE/* +TAB=$'\t\t\t\t\t\t\t' +sed -i -e "s/.*src.*/$TAB\"src\": \"$USECASE.zip\"/" 03_Onboard_VSP_part2.postman_collection.json +docker pull postman/newman:alpine +docker run --network="host" --volume="/home/debian/rene/onap-tests/postman:/etc/newman" postman/newman:alpine run 01_Onboard_Vendor.postman_collection.json --environment integration_test_urls.postman_environment.json --globals globals.postman_globals.json --export-globals globals.postman_globals.json --reporters cli,json --reporter-cli-no-assertions --reporter-cli-no-console +docker run --network="host" --volume="/home/debian/rene/onap-tests/postman:/etc/newman" postman/newman:alpine run 02_Onboard_VSP_part1.postman_collection.json --environment integration_test_urls.postman_environment.json --globals globals.postman_globals.json --export-globals globals.postman_globals.json +docker run --network="host" --volume="/home/debian/rene/onap-tests/postman:/etc/newman" postman/newman:alpine run 03_Onboard_VSP_part2.postman_collection.json --environment integration_test_urls.postman_environment.json --globals globals.postman_globals.json --export-globals globals.postman_globals.json +docker run --network="host" --volume="/home/debian/rene/onap-tests/postman:/etc/newman" postman/newman:alpine run 04_Onboard_VSP_part3.postman_collection.json --environment integration_test_urls.postman_environment.json --globals globals.postman_globals.json --export-globals globals.postman_globals.json +docker run --network="host" --volume="/home/debian/rene/onap-tests/postman:/etc/newman" postman/newman:alpine run 05_Onboard_VF.postman_collection.json --environment integration_test_urls.postman_environment.json --globals globals.postman_globals.json --export-globals globals.postman_globals.json +docker run --network="host" --volume="/home/debian/rene/onap-tests/postman:/etc/newman" postman/newman:alpine run 06_Onboard_Service.postman_collection.json --environment integration_test_urls.postman_environment.json --globals globals.postman_globals.json --export-globals globals.postman_globals.json +docker run --network="host" --volume="/home/debian/rene/onap-tests/postman:/etc/newman" postman/newman:alpine run 07_Declare_owningEntity_LineOfBusiness_project_platform.postman_collection.json --environment integration_test_urls.postman_environment.json --globals globals.postman_globals.json --export-globals globals.postman_globals.json +docker run --network="host" --volume="/home/debian/rene/onap-tests/postman:/etc/newman" postman/newman:alpine run 08_Declare_Customer_Service_Subscription_Cloud.postman_collection.json --insecure --environment integration_test_urls.postman_environment.json --globals globals.postman_globals.json --export-globals globals.postman_globals.json +docker run --network="host" --volume="/home/debian/rene/onap-tests/postman:/etc/newman" postman/newman:alpine run 10_Service_Order.postman_collection.json --environment integration_test_urls.postman_environment.json --globals globals.postman_globals.json --export-globals globals.postman_globals.json --reporters cli,json --reporter-cli-no-assertions --reporter-cli-no-console +``` + +All collections are run, you can see results and you will also obtain result json files in the onap-tests/postamn/newman directory + +Of course you can adapt globals variables in globals.postman_globals.json or change the USECASE=$'ubuntu16' value to onboard any heat template located in onap_tests/templates/heat_files directory |