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.
7 Test ONAP API with Postman
8 ==========================
13 Postman is a tool that allows a user to run REST API.
15 The user defines the API requests and has the possibility to group them
16 in files called a "Collections".
18 The user can then run each individual API request or run a complete collection.
20 Postman includes the possibility to define "environment" variables.
22 An API request can then get or set a value from/to that "environment" variable.
24 Get and install Postman tool on your own machine (Linux/windows).
26 Postman is available here: https://www.getpostman.com/
29 ONAP Postman collections
30 ------------------------
32 ONAP Integration project provides several Postman collections with two
35 Those Postman Collections will allow a Developer to experiment various ONAP API
36 on various ONAP components (SDC, NBI, SO, AAI, SDNC)
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
53 A collection is also provided to delete objects
54 (reminder: it is not possible to delete object in SDC)
56 They have been tested with Onap Dublin (they are not all compatible with
57 Casablanca, and there is not guaranty about ONAP "master" as API definition
61 Download ONAP Postman collections
62 ---------------------------------
64 From your machine, git clone the ONAP Integration project.
68 git clone "https://gerrit.onap.org/r/integration"
71 Import ONAP Postman collections
72 -------------------------------
74 ONAP Postman collection are in the repository integration/test/postman
78 import all ONAP Collections into Postman
80 .. figure:: files/postman/import.png
83 And you should see all the collections into Postman
85 .. figure:: files/postman/collections.png
88 Each collection is made of several API operations
90 .. figure:: files/postman/collection-detail.png
94 Running ONAP Postman collections
95 --------------------------------
97 Running all those collections, in the order, from 1 to 10 will create a lot of
98 objects in ONAP components :
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
106 The order is very important because a lot of API requests will need the API
107 response from the previous operation o get and set some variable values.
109 .. figure:: files/postman/collection-detail-test.png
112 It is possible to run the complete collection using Postman
114 .. figure:: files/postman/run.png
117 You need, a zip file that contains Heat files for a VNF.
119 Collection 3 is about uploading that file into ONAP SDC.
121 .. figure:: files/postman/zipfile.png
124 Before running those collections, once in Postman, you need to have a look
125 at "globals" environment parameters.
127 .. figure:: files/postman/globals.png
130 All variables that begin by "auto" must NOT be changed (they will be modified
133 All other variables must be adapted to your needs.
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.
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
156 listener_url:http://10.4.2.65:8080/externalapi/listener/v1/listener
162 Newman is a tool that allow to run postman collections via command-line
164 On a linux server, with Docker installed on it, run those lines:
168 git clone https://gitlab.com/Orange-OpenSource/lfn/onap/onap-tests.git
169 cd onap-tests/postman
170 sudo apt-get -y install zip
172 zip -j $USECASE.zip ../onap_tests/templates/heat_files/$USECASE/*
173 TAB=$'\t\t\t\t\t\t\t'
174 sed -i -e "s/.*src.*/$TAB\"src\": \"$USECASE.zip\"/" 03_Onboard_VSP_part2.postman_collection.json
175 docker pull postman/newman:alpine
176 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
177 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
178 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
179 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
180 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
181 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
182 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
183 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
184 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-globals globals.postman_globals.json --reporters cli,json --reporter-cli-no-assertions --reporter-cli-no-console
186 All collections are processed, then you can see results and you will
187 also obtain result json files in the onap-tests/postamn/newman directory
189 Of course you can adapt globals variables in globals.postman_globals.json
190 or change the USECASE=$'ubuntu16' value to onboard any heat template located
191 in onap_tests/templates/heat_files directory