blob: 46f4eec5d18b471f1ce4471828cf4b9d89f8b048 [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.
Aric Gardnerae8d50c2020-04-09 12:26:09 -07004.. _docs_postman:
Rene_Robert8fff4b52019-08-02 14:16:37 +02005.. _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
Rene_Robert11c57832019-10-22 17:27:21 +020056They have been tested with Onap ElAlto (they are not all compatible with
57Dublin, and there is not guaranty about ONAP "master" as API definition
Rene_Robert8fff4b52019-08-02 14:16:37 +020058can 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
Rene_Robert11c57832019-10-22 17:27:21 +0200107response from the previous operation to get and set some variable values.
Rene_Robert8fff4b52019-08-02 14:16:37 +0200108
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
Rene_Robert8fff4b52019-08-02 14:16:37 +0200156
157
158Using Newman
159------------
160
161Newman is a tool that allow to run postman collections via command-line
162
163On 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_Robert11c57832019-10-22 17:27:21 +0200175 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_Robert8fff4b52019-08-02 14:16:37 +0200184
185All collections are processed, then you can see results and you will
Rene_Robert11c57832019-10-22 17:27:21 +0200186also obtain result json files in the onap-tests/postman/newman directory
Rene_Robert8fff4b52019-08-02 14:16:37 +0200187
188Of course you can adapt globals variables in globals.postman_globals.json
189or change the USECASE=$'ubuntu16' value to onboard any heat template located
190in onap_tests/templates/heat_files directory