blob: 54d7b4f588c4fbd8457f8b5679aa73949a448d60 [file] [log] [blame]
Rene_Robert8fff4b52019-08-02 14:16:37 +02001.. 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.
4
5.. _postman-guides:
6
7Test ONAP API with Postman
8==========================
9
10Postman
11-------
12
13Postman is a tool that allows a user to run REST API.
14
15The user defines the API requests and has the possibility to group them
16in files called a "Collections".
17
18The user can then run each individual API request or run a complete collection.
19
20Postman includes the possibility to define "environment" variables.
21
22An API request can then get or set a value from/to that "environment" variable.
23
24Get and install Postman tool on your own machine (Linux/windows).
25
26Postman is available here: https://www.getpostman.com/
27
28
29ONAP Postman collections
30------------------------
31
32ONAP Integration project provides several Postman collections with two
33environment files.
34
35Those Postman Collections will allow a Developer to experiment various ONAP API
36on 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
53A collection is also provided to delete objects
54(reminder: it is not possible to delete object in SDC)
55
56They have been tested with Onap Dublin (they are not all compatible with
57Casablanca, and there is not guaranty about ONAP "master" as API definition
58can change)
59
60
61Download ONAP Postman collections
62---------------------------------
63
64From your machine, git clone the ONAP Integration project.
65
66::
67
68 git clone "https://gerrit.onap.org/r/integration"
69
70
71Import ONAP Postman collections
72-------------------------------
73
74ONAP Postman collection are in the repository integration/test/postman
75
76Launch Postman tool
77
78import all ONAP Collections into Postman
79
80.. figure:: files/postman/import.png
81 :align: center
82
83And you should see all the collections into Postman
84
85.. figure:: files/postman/collections.png
86 :align: center
87
88Each collection is made of several API operations
89
90.. figure:: files/postman/collection-detail.png
91 :align: center
92
93
94Running ONAP Postman collections
95--------------------------------
96
97Running all those collections, in the order, from 1 to 10 will create a lot of
98objects 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
106The order is very important because a lot of API requests will need the API
107response from the previous operation o get and set some variable values.
108
109.. figure:: files/postman/collection-detail-test.png
110 :align: center
111
112It is possible to run the complete collection using Postman
113
114.. figure:: files/postman/run.png
115 :align: center
116
117You need, a zip file that contains Heat files for a VNF.
118
119Collection 3 is about uploading that file into ONAP SDC.
120
121.. figure:: files/postman/zipfile.png
122 :align: center
123
124Before running those collections, once in Postman, you need to have a look
125at "globals" environment parameters.
126
127.. figure:: files/postman/globals.png
128 :align: center
129
130All variables that begin by "auto" must NOT be changed (they will be modified
131using API response).
132
133All other variables must be adapted to your needs.
134
135In particular, you need to put your own values for cloud_region_id, tenant_name
136and 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
156 listener_url:http://10.4.2.65:8080/externalapi/listener/v1/listener
157
158
159Using Newman
160------------
161
162Newman is a tool that allow to run postman collections via command-line
163
164On a linux server, with Docker installed on it, run those lines:
165
166::
167
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
171 USECASE=$'ubuntu16'
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
185
186All collections are processed, then you can see results and you will
187also obtain result json files in the onap-tests/postamn/newman directory
188
189Of course you can adapt globals variables in globals.postman_globals.json
190or change the USECASE=$'ubuntu16' value to onboard any heat template located
191in onap_tests/templates/heat_files directory