blob: 241ebb815b91f832864aedb817519bac994c058a [file] [log] [blame]
Gary Wu9abb61c2018-09-27 10:38:50 -07001*** settings ***
2Resource ../../common.robot
3Library Collections
4Library RequestsLibrary
5Library OperatingSystem
6Library json
7Library HttpLibrary.HTTP
zhaoliping123e9ef0282019-10-23 09:06:10 +08008Library ONAPLibrary.Utilities
Gary Wu9abb61c2018-09-27 10:38:50 -07009
10*** Variables ***
11@{return_ok_list}= 200 201 202 204
12${queryswagger_url} /api/nslcm/v1/swagger.json
zhaoliping123e9ef0282019-10-23 09:06:10 +080013${ns_url} /api/nslcm/v1/ns
fujinhuad5a32832019-04-19 09:45:49 +080014${get_subscriptions_url} /api/nslcm/v1/subscriptions
fujinhua7aa8cd32019-04-05 08:20:53 +080015${healthcheck_url} /api/nslcm/v1/health_check
zhaoliping123179d6fc2019-10-15 15:20:08 +080016${get_job_url} /api/nslcm/v1/jobs
17${vnfs_url} /api/nslcm/v1/ns/vnfs
18${terminate_vnfs_url} /api/nslcm/v1/ns/terminatevnf
19${vls_url} /api/nslcm/v1/ns/vls
20${sfcs_url} /api/nslcm/v1/ns/sfcs
21${pnfs_url} /api/nslcm/v1/pnfs
22
23${ns_instances_url} /api/nslcm/v1/ns_instances
Gary Wu9abb61c2018-09-27 10:38:50 -070024
25#json files
26${create_ns_json} ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/create_ns.json
zhaoliping123179d6fc2019-10-15 15:20:08 +080027${heal_ns_json} ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/heal_ns.json
zhaoliping123179d6fc2019-10-15 15:20:08 +080028${scale_ns_json} ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/scale_ns.json
29${update_ns_json} ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/update_ns.json
30${terminate_ns_json} ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/terminate_ns.json
zhaoliping123179d6fc2019-10-15 15:20:08 +080031${create_vnf_json} ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/create_vnf.json
32${terminate_vnf_json} ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/terminate_vnf.json
33${create_vl_json} ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/create_vl.json
zhaoliping123179d6fc2019-10-15 15:20:08 +080034${create_subscriptions_json} ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/create_subscription.json
zhaoliping123179d6fc2019-10-15 15:20:08 +080035
36${create_ns_instance_json} ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/create_ns_instance.json
zhaoliping123179d6fc2019-10-15 15:20:08 +080037${terminate_ns_instance_json} ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/terminate_ns_instance.json
zhaoliping123e9ef0282019-10-23 09:06:10 +080038${update_ns_instance_json} ${SCRIPTS}/../tests/vfc/nfvo-lcm/jsoninput/update_ns_instance.json
Gary Wu9abb61c2018-09-27 10:38:50 -070039
40#global variables
41${nsInstId}
zhaoliping123179d6fc2019-10-15 15:20:08 +080042${jobInstId}
43${vnfInstId}
44${vlInstId}
zhaoliping123179d6fc2019-10-15 15:20:08 +080045${nsInstanceId}
Gary Wu9abb61c2018-09-27 10:38:50 -070046
47*** Test Cases ***
48NslcmSwaggerTest
49 [Documentation] query swagger info of nslcm
50 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
51 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
52 ${resp}= Get Request web_session ${queryswagger_url}
53 ${responese_code}= Convert To String ${resp.status_code}
54 List Should Contain Value ${return_ok_list} ${responese_code}
55 ${response_json} json.loads ${resp.content}
56 ${swagger_version}= Convert To String ${response_json['swagger']}
57 Should Be Equal ${swagger_version} 2.0
58
59NslcmSwaggerByMSBTest
60 [Documentation] query swagger info of nslcm by MSB
61 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
dengyh5c559902020-07-01 15:20:42 +080062 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
Gary Wu9abb61c2018-09-27 10:38:50 -070063 ${resp}= Get Request web_session ${queryswagger_url}
64 ${responese_code}= Convert To String ${resp.status_code}
65 List Should Contain Value ${return_ok_list} ${responese_code}
66 ${response_json} json.loads ${resp.content}
67 ${swagger_version}= Convert To String ${response_json['swagger']}
68 Should Be Equal ${swagger_version} 2.0
69
70CreateNSTest
71 [Documentation] Create NS function test
72 ${json_value}= json_from_file ${create_ns_json}
73 ${json_string}= string_from_json ${json_value}
74 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
dengyh5c559902020-07-01 15:20:42 +080075 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
Gary Wu9abb61c2018-09-27 10:38:50 -070076 Set Request Body ${json_string}
zhaoliping123e9ef0282019-10-23 09:06:10 +080077 ${resp}= Post Request web_session ${ns_url} ${json_string}
Gary Wu9abb61c2018-09-27 10:38:50 -070078 ${responese_code}= Convert To String ${resp.status_code}
79 List Should Contain Value ${return_ok_list} ${responese_code}
80 ${response_json} json.loads ${resp.content}
81 ${nsInstId}= Convert To String ${response_json['nsInstanceId']}
82 Set Global Variable ${nsInstId}
83
zhaoliping123179d6fc2019-10-15 15:20:08 +080084CreateVnfTest
85 [Documentation] Create vnf function test
86 ${json_value}= json_from_file ${create_vnf_json}
87 Set To Dictionary ${json_value} nsInstanceId=${nsInstId}
88 ${json_string}= string_from_json ${json_value}
89 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
dengyh5c559902020-07-01 15:20:42 +080090 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
zhaoliping123179d6fc2019-10-15 15:20:08 +080091 Set Request Body ${json_string}
92 ${resp}= Post Request web_session ${vnfs_url} ${json_string}
93 ${responese_code}= Convert To String ${resp.status_code}
94 List Should Contain Value ${return_ok_list} ${responese_code}
95 ${response_json} json.loads ${resp.content}
96 ${vnfInstId}= Convert To String ${response_json['vnfInstId']}
97 Set Global Variable ${vnfInstId}
98
99QueryVnfTest
100 [Documentation] Query vnf function test
101 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
dengyh5c559902020-07-01 15:20:42 +0800102 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800103 ${resp}= Get Request web_session ${vnfs_url}/${vnfInstId}
104 ${responese_code}= Convert To String ${resp.status_code}
105 List Should Contain Value ${return_ok_list} ${responese_code}
106
107TerminateVnfTest
108 [Documentation] Terminate vnf function test
109 ${json_value}= json_from_file ${terminate_vnf_json}
110 ${json_string}= string_from_json ${json_value}
111 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
dengyh5c559902020-07-01 15:20:42 +0800112 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800113 Set Request Body ${json_string}
zhaoliping123e9ef0282019-10-23 09:06:10 +0800114 ${resp}= Post Request web_session ${terminate_vnfs_url}/${vnfInstId} ${json_string}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800115 ${responese_code}= Convert To String ${resp.status_code}
116 List Should Contain Value ${return_ok_list} ${responese_code}
117
118CreateVlTest
119 [Documentation] Create vl function test
120 ${json_value}= json_from_file ${create_vl_json}
zhaoliping123e9ef0282019-10-23 09:06:10 +0800121 Set To Dictionary ${json_value} nsInstanceId=${nsInstId}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800122 ${json_string}= string_from_json ${json_value}
123 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
dengyh5c559902020-07-01 15:20:42 +0800124 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800125 Set Request Body ${json_string}
126 ${resp}= Post Request web_session ${vls_url} ${json_string}
127 ${responese_code}= Convert To String ${resp.status_code}
128 List Should Contain Value ${return_ok_list} ${responese_code}
129 ${response_json} json.loads ${resp.content}
130 ${vlInstId}= Convert To String ${response_json['vlId']}
131 Set Global Variable ${vlInstId}
132
zhaoliping123179d6fc2019-10-15 15:20:08 +0800133DeleteVlTest
134 [Documentation] Delete vl function test
135 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
dengyh5c559902020-07-01 15:20:42 +0800136 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800137 ${resp}= Delete Request web_session ${vls_url}/${vlInstId}
138 ${responese_code}= Convert To String ${resp.status_code}
139 List Should Contain Value ${return_ok_list} ${responese_code}
140
zhaoliping123179d6fc2019-10-15 15:20:08 +0800141ScaleNSTest
142 [Documentation] Scale Ns function test
143 ${json_value}= json_from_file ${scale_ns_json}
144 ${json_string}= string_from_json ${json_value}
145 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
dengyh5c559902020-07-01 15:20:42 +0800146 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800147 Set Request Body ${json_string}
zhaoliping123e9ef0282019-10-23 09:06:10 +0800148 ${resp}= Post Request web_session ${ns_url}/${nsInstId}/scale ${json_string}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800149 ${responese_code}= Convert To String ${resp.status_code}
150 List Should Contain Value ${return_ok_list} ${responese_code}
151
152HealNSTest
153 [Documentation] Heal Ns function test
154 ${json_value}= json_from_file ${heal_ns_json}
155 ${json_string}= string_from_json ${json_value}
156 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
dengyh5c559902020-07-01 15:20:42 +0800157 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800158 Set Request Body ${json_string}
zhaoliping123e9ef0282019-10-23 09:06:10 +0800159 ${resp}= Post Request web_session ${ns_url}/${nsInstId}/heal ${json_string}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800160 ${responese_code}= Convert To String ${resp.status_code}
161 List Should Contain Value ${return_ok_list} ${responese_code}
162 ${response_json} json.loads ${resp.content}
163 ${jobInstId}= Convert To String ${response_json['jobId']}
164 Set Global Variable ${jobInstId}
165
zhaoliping123179d6fc2019-10-15 15:20:08 +0800166GetJobTest
167 [Documentation] Query Ns Job function test
168 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
dengyh5c559902020-07-01 15:20:42 +0800169 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800170 ${resp}= Get Request web_session ${get_job_url}/${jobInstId}
171 ${responese_code}= Convert To String ${resp.status_code}
172 List Should Contain Value ${return_ok_list} ${responese_code}
173
zhaoliping123179d6fc2019-10-15 15:20:08 +0800174UpdateNSTest
175 [Documentation] Scale Ns function test
176 ${json_value}= json_from_file ${update_ns_json}
177 ${json_string}= string_from_json ${json_value}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800178 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
dengyh5c559902020-07-01 15:20:42 +0800179 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800180 Set Request Body ${json_string}
zhaoliping123e9ef0282019-10-23 09:06:10 +0800181 ${resp}= Post Request web_session ${ns_url}/${nsInstId}/update ${json_string}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800182 ${responese_code}= Convert To String ${resp.status_code}
183 List Should Contain Value ${return_ok_list} ${responese_code}
184
185TerminateNSTest
186 [Documentation] Terminate Ns function test
187 ${json_value}= json_from_file ${terminate_ns_json}
188 ${json_string}= string_from_json ${json_value}
189 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
dengyh5c559902020-07-01 15:20:42 +0800190 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800191 Set Request Body ${json_string}
zhaoliping123e9ef0282019-10-23 09:06:10 +0800192 ${resp}= Post Request web_session ${ns_url}/${nsInstId}/terminate ${json_string}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800193 ${responese_code}= Convert To String ${resp.status_code}
194 List Should Contain Value ${return_ok_list} ${responese_code}
195
196DeleteNSTest
Gary Wu9abb61c2018-09-27 10:38:50 -0700197 [Documentation] Delete NS function test
198 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
dengyh5c559902020-07-01 15:20:42 +0800199 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
zhaoliping123e9ef0282019-10-23 09:06:10 +0800200 ${resp}= Delete Request web_session ${ns_url}/${nsInstId}
Gary Wu9abb61c2018-09-27 10:38:50 -0700201 ${responese_code}= Convert To String ${resp.status_code}
202 List Should Contain Value ${return_ok_list} ${responese_code}
fujinhua7aa8cd32019-04-05 08:20:53 +0800203
204LcmHealthCheckTest
205 [Documentation] check health for nslcm by MSB
206 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
dengyh5c559902020-07-01 15:20:42 +0800207 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
fujinhua7aa8cd32019-04-05 08:20:53 +0800208 ${resp}= Get Request web_session ${healthcheck_url}
209 ${responese_code}= Convert To String ${resp.status_code}
210 List Should Contain Value ${return_ok_list} ${responese_code}
211 ${response_json} json.loads ${resp.content}
212 ${health_status}= Convert To String ${response_json['status']}
213 Should Be Equal ${health_status} active
fujinhua898e2cb2019-04-18 19:29:04 +0800214
215LcmGetNsTest
216 [Documentation] get ns instances for nslcm by MSB
217 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
dengyh5c559902020-07-01 15:20:42 +0800218 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
zhaoliping123e9ef0282019-10-23 09:06:10 +0800219 ${resp}= Get Request web_session ${ns_url}
fujinhua898e2cb2019-04-18 19:29:04 +0800220 ${responese_code}= Convert To String ${resp.status_code}
221 List Should Contain Value ${return_ok_list} ${responese_code}
fujinhuad5a32832019-04-19 09:45:49 +0800222
zhaoliping123179d6fc2019-10-15 15:20:08 +0800223QueryAllPnfsTest
224 [Documentation] Query all pnfs function test
225 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
dengyh5c559902020-07-01 15:20:42 +0800226 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800227 ${resp}= Get Request web_session ${pnfs_url}
228 ${responese_code}= Convert To String ${resp.status_code}
229 List Should Contain Value ${return_ok_list} ${responese_code}
230
zhaoliping123179d6fc2019-10-15 15:20:08 +0800231CreateNSInstanceTest
232 [Documentation] Create NS Instance function test
233 ${json_value}= json_from_file ${create_ns_instance_json}
234 ${json_string}= string_from_json ${json_value}
zhaoliping123e9ef0282019-10-23 09:06:10 +0800235 ${headers} Create Dictionary Content-Type=application/json Accept=application/json globalcustomerid=global-customer-id-test1 servicetype=service-type-test1
dengyh5c559902020-07-01 15:20:42 +0800236 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800237 Set Request Body ${json_string}
238 ${resp}= Post Request web_session ${ns_instances_url} ${json_string}
239 ${responese_code}= Convert To String ${resp.status_code}
240 List Should Contain Value ${return_ok_list} ${responese_code}
241 ${response_json} json.loads ${resp.content}
zhaoliping123e9ef0282019-10-23 09:06:10 +0800242 ${nsInstanceId}= Convert To String ${response_json['nsInstanceId']}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800243 Set Global Variable ${nsInstanceId}
244
245QueryNSInstancesTest
246 [Documentation] Query Ns Instances function test
247 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
dengyh5c559902020-07-01 15:20:42 +0800248 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800249 ${resp}= Get Request web_session ${ns_instances_url}
250 ${responese_code}= Convert To String ${resp.status_code}
251 List Should Contain Value ${return_ok_list} ${responese_code}
252
zhaoliping123179d6fc2019-10-15 15:20:08 +0800253UpdateNSInstanceTest
254 [Documentation] Scale Ns Instance function test
255 ${json_value}= json_from_file ${update_ns_instance_json}
256 ${json_string}= string_from_json ${json_value}
257 Log ${json_string}
258 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
dengyh5c559902020-07-01 15:20:42 +0800259 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800260 Set Request Body ${json_string}
261 ${resp}= Post Request web_session ${ns_instances_url}/${nsInstId}/update ${json_string}
262 ${responese_code}= Convert To String ${resp.status_code}
263 List Should Contain Value ${return_ok_list} ${responese_code}
264
265TerminateNSInstanceTest
266 [Documentation] Terminate Ns Instance function test
267 ${json_value}= json_from_file ${terminate_ns_instance_json}
268 ${json_string}= string_from_json ${json_value}
269 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
dengyh5c559902020-07-01 15:20:42 +0800270 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800271 Set Request Body ${json_string}
272 ${resp}= Post Request web_session ${ns_instances_url}/${nsInstanceId}/terminate ${json_string}
273 ${responese_code}= Convert To String ${resp.status_code}
274 List Should Contain Value ${return_ok_list} ${responese_code}
275
zhaoliping123179d6fc2019-10-15 15:20:08 +0800276LcmCreateSubscriptionsTest
277 [Documentation] Postdeal Ns function test
278 ${json_value}= json_from_file ${create_subscriptions_json}
279 ${json_string}= string_from_json ${json_value}
280 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
dengyh5c559902020-07-01 15:20:42 +0800281 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800282 Set Request Body ${json_string}
283 ${resp}= Post Request web_session ${get_subscriptions_url} ${json_string}
284 ${responese_code}= Convert To String ${resp.status_code}
285 List Should Contain Value ${return_ok_list} ${responese_code}
286
fujinhuad5a32832019-04-19 09:45:49 +0800287LcmGetSubscriptionsTest
288 [Documentation] get subscriptions for nslcm by MSB
289 ${headers} Create Dictionary Content-Type=application/json Accept=application/json
dengyh5c559902020-07-01 15:20:42 +0800290 Create Session web_session http://${NSLCM_IP}:8403 headers=${headers}
fujinhuad5a32832019-04-19 09:45:49 +0800291 ${resp}= Get Request web_session ${get_subscriptions_url}
292 ${responese_code}= Convert To String ${resp.status_code}
zhaoliping123179d6fc2019-10-15 15:20:08 +0800293 List Should Contain Value ${return_ok_list} ${responese_code}