Rene_Robert | 8fff4b5 | 2019-08-02 14:16:37 +0200 | [diff] [blame] | 1 | .. This work is licensed under a Creative Commons Attribution 4.0 |
| 2 | .. International License. http://creativecommons.org/licenses/by/4.0 |
| 3 | .. Copyright 2017 AT&T Intellectual Property. All rights reserved. |
Aric Gardner | ae8d50c | 2020-04-09 12:26:09 -0700 | [diff] [blame] | 4 | .. _docs_postman: |
Rene_Robert | 8fff4b5 | 2019-08-02 14:16:37 +0200 | [diff] [blame] | 5 | .. _postman-guides: |
| 6 | |
| 7 | Test ONAP API with Postman |
| 8 | ========================== |
| 9 | |
| 10 | Postman |
| 11 | ------- |
| 12 | |
| 13 | Postman is a tool that allows a user to run REST API. |
| 14 | |
| 15 | The user defines the API requests and has the possibility to group them |
| 16 | in files called a "Collections". |
| 17 | |
| 18 | The user can then run each individual API request or run a complete collection. |
| 19 | |
| 20 | Postman includes the possibility to define "environment" variables. |
| 21 | |
| 22 | An API request can then get or set a value from/to that "environment" variable. |
| 23 | |
| 24 | Get and install Postman tool on your own machine (Linux/windows). |
| 25 | |
| 26 | Postman is available here: https://www.getpostman.com/ |
| 27 | |
| 28 | |
| 29 | ONAP Postman collections |
| 30 | ------------------------ |
| 31 | |
| 32 | ONAP Integration project provides several Postman collections with two |
| 33 | environment files. |
| 34 | |
| 35 | Those Postman Collections will allow a Developer to experiment various ONAP API |
| 36 | on various ONAP components (SDC, NBI, SO, AAI, SDNC) |
| 37 | |
| 38 | - declare a vendor |
| 39 | - declare a VSP |
| 40 | - upload a package |
| 41 | - declare a VF based on the VSP |
| 42 | - declare a Service composed of the VF and a Virtual Link |
| 43 | - distribute all those informations |
| 44 | - declare a customer, a service subscription |
| 45 | - declare OwningEntity, Platform... |
| 46 | - declare a Complex, Cloud Region, Tenant |
| 47 | - associate customer/service/tenant |
| 48 | - declare a service instance via a serviceOrder |
| 49 | - declare a vnf |
| 50 | - declare a vf-module |
| 51 | - declare a network |
| 52 | |
| 53 | A collection is also provided to delete objects |
| 54 | (reminder: it is not possible to delete object in SDC) |
| 55 | |
Rene_Robert | 11c5783 | 2019-10-22 17:27:21 +0200 | [diff] [blame] | 56 | They have been tested with Onap ElAlto (they are not all compatible with |
| 57 | Dublin, and there is not guaranty about ONAP "master" as API definition |
Rene_Robert | 8fff4b5 | 2019-08-02 14:16:37 +0200 | [diff] [blame] | 58 | can change) |
| 59 | |
| 60 | |
| 61 | Download ONAP Postman collections |
| 62 | --------------------------------- |
| 63 | |
| 64 | From your machine, git clone the ONAP Integration project. |
| 65 | |
| 66 | :: |
| 67 | |
| 68 | git clone "https://gerrit.onap.org/r/integration" |
| 69 | |
| 70 | |
| 71 | Import ONAP Postman collections |
| 72 | ------------------------------- |
| 73 | |
| 74 | ONAP Postman collection are in the repository integration/test/postman |
| 75 | |
| 76 | Launch Postman tool |
| 77 | |
| 78 | import all ONAP Collections into Postman |
| 79 | |
| 80 | .. figure:: files/postman/import.png |
| 81 | :align: center |
| 82 | |
| 83 | And you should see all the collections into Postman |
| 84 | |
| 85 | .. figure:: files/postman/collections.png |
| 86 | :align: center |
| 87 | |
| 88 | Each collection is made of several API operations |
| 89 | |
| 90 | .. figure:: files/postman/collection-detail.png |
| 91 | :align: center |
| 92 | |
| 93 | |
| 94 | Running ONAP Postman collections |
| 95 | -------------------------------- |
| 96 | |
| 97 | Running all those collections, in the order, from 1 to 10 will create a lot of |
| 98 | objects in ONAP components : |
| 99 | |
| 100 | - SDC : vendor, VSP, zip file upload, VF from VSP, Service, add VF to Service |
| 101 | - VID : OwningEntity, LineOfBusiness, Project, Platform |
| 102 | - AAI : customer, subscription, cloud region, tenant |
| 103 | - NBI : serviceOrder to add a service instance, serviceOrder to delete |
| 104 | a service instance |
| 105 | |
| 106 | The order is very important because a lot of API requests will need the API |
Rene_Robert | 11c5783 | 2019-10-22 17:27:21 +0200 | [diff] [blame] | 107 | response from the previous operation to get and set some variable values. |
Rene_Robert | 8fff4b5 | 2019-08-02 14:16:37 +0200 | [diff] [blame] | 108 | |
| 109 | .. figure:: files/postman/collection-detail-test.png |
| 110 | :align: center |
| 111 | |
| 112 | It is possible to run the complete collection using Postman |
| 113 | |
| 114 | .. figure:: files/postman/run.png |
| 115 | :align: center |
| 116 | |
| 117 | You need, a zip file that contains Heat files for a VNF. |
| 118 | |
| 119 | Collection 3 is about uploading that file into ONAP SDC. |
| 120 | |
| 121 | .. figure:: files/postman/zipfile.png |
| 122 | :align: center |
| 123 | |
| 124 | Before running those collections, once in Postman, you need to have a look |
| 125 | at "globals" environment parameters. |
| 126 | |
| 127 | .. figure:: files/postman/globals.png |
| 128 | :align: center |
| 129 | |
| 130 | All variables that begin by "auto" must NOT be changed (they will be modified |
| 131 | using API response). |
| 132 | |
| 133 | All other variables must be adapted to your needs. |
| 134 | |
| 135 | In particular, you need to put your own values for cloud_region_id, tenant_name |
| 136 | and tenant_id to fit with the place where you will instantiate the VNF. |
| 137 | |
| 138 | |
| 139 | :: |
| 140 | |
| 141 | service:freeradius |
| 142 | vf_name:integration_test_VF_freeradius |
| 143 | vsp_name:integration_test_VSP |
| 144 | vendor_name:onap_integration_vendor |
| 145 | owning_entity:integration_test_OE |
| 146 | platform:integration_test_platform |
| 147 | project:integration_test_project |
| 148 | lineofbusiness:integration_test_LOB |
| 149 | customer_name:generic |
| 150 | cloud_owner_name:OPNFV |
| 151 | cloud_region_id:RegionOne |
| 152 | tenant_name:openlab-vnfs |
| 153 | tenant_id:234a9a2dc4b643be9812915b214cdbbb |
| 154 | externalId:integration_test_BSS-order-001 |
| 155 | service_instance_name:integration_test_freeradius_instance_001 |
Rene_Robert | 8fff4b5 | 2019-08-02 14:16:37 +0200 | [diff] [blame] | 156 | |
| 157 | |
| 158 | Using Newman |
| 159 | ------------ |
| 160 | |
| 161 | Newman is a tool that allow to run postman collections via command-line |
| 162 | |
| 163 | On a linux server, with Docker installed on it, run those lines: |
| 164 | |
| 165 | :: |
| 166 | |
| 167 | git clone https://gitlab.com/Orange-OpenSource/lfn/onap/onap-tests.git |
| 168 | cd onap-tests/postman |
| 169 | sudo apt-get -y install zip |
| 170 | USECASE=$'ubuntu16' |
| 171 | zip -j $USECASE.zip ../onap_tests/templates/heat_files/$USECASE/* |
| 172 | TAB=$'\t\t\t\t\t\t\t' |
| 173 | sed -i -e "s/.*src.*/$TAB\"src\": \"$USECASE.zip\"/" 03_Onboard_VSP_part2.postman_collection.json |
| 174 | docker pull postman/newman:alpine |
Rene_Robert | 11c5783 | 2019-10-22 17:27:21 +0200 | [diff] [blame] | 175 | 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-environment integration_test_urls.postman_environment.json --reporters cli,json --reporter-cli-no-assertions --reporter-cli-no-console |
| 176 | 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-environment integration_test_urls.postman_environment.json |
| 177 | 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-environment integration_test_urls.postman_environment.json |
| 178 | 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-environment integration_test_urls.postman_environment.json |
| 179 | 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-environment integration_test_urls.postman_environment.json |
| 180 | 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-environment integration_test_urls.postman_environment.json |
| 181 | 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-environment integration_test_urls.postman_environment.json |
| 182 | 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-environment integration_test_urls.postman_environment.json |
| 183 | docker run --network="host" --volume="/home/debian/rene/onap-tests/postman:/etc/newman" postman/newman:alpine run 10_instantiate_service_vnf_vfmodule.postman_collection.json --environment integration_test_urls.postman_environment.json --globals globals.postman_globals.json --export-environment integration_test_urls.postman_environment.json --reporters cli,json --reporter-cli-no-assertions --reporter-cli-no-console |
Rene_Robert | 8fff4b5 | 2019-08-02 14:16:37 +0200 | [diff] [blame] | 184 | |
| 185 | All collections are processed, then you can see results and you will |
Rene_Robert | 11c5783 | 2019-10-22 17:27:21 +0200 | [diff] [blame] | 186 | also obtain result json files in the onap-tests/postman/newman directory |
Rene_Robert | 8fff4b5 | 2019-08-02 14:16:37 +0200 | [diff] [blame] | 187 | |
| 188 | Of course you can adapt globals variables in globals.postman_globals.json |
| 189 | or change the USECASE=$'ubuntu16' value to onboard any heat template located |
| 190 | in onap_tests/templates/heat_files directory |