3 # ============LICENSE_START===============================================
4 # Copyright (C) 2020 Nordix Foundation. All rights reserved.
5 # ========================================================================
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 # ============LICENSE_END=================================================
21 TC_ONELINE_DESCR="Full agent API walk through using agent REST/DMAAP and with/without SDNC A1 Controller"
23 #App names to include in the test, space separated list
24 INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
27 #SUPPORTED TEST ENV FILE
28 SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN"
30 . ../common/testcase_common.sh $@
31 . ../common/agent_api_functions.sh
32 . ../common/ricsimulator_api_functions.sh
33 . ../common/cr_api_functions.sh
39 # Tested variants of REST/DMAAP/SDNC config
40 TESTED_VARIANTS="REST DMAAP REST+SDNC DMAAP+SDNC"
42 #Test agent and simulator protocol versions (others are http only)
43 TESTED_PROTOCOLS="HTTP HTTPS"
45 for __httpx in $TESTED_PROTOCOLS ; do
46 for interface in $TESTED_VARIANTS ; do
48 echo "#####################################################################"
49 echo "#####################################################################"
50 echo "### Testing agent: $interface using $__httpx"
51 echo "#####################################################################"
52 echo "#####################################################################"
54 # Clean container and start all needed containers #
57 if [ $__httpx == "HTTPS" ]; then
67 # Create service to be able to receive events when rics becomes available
68 # Must use rest towards the agent since dmaap is not configured yet
69 api_put_service 201 "ric-registration" 0 "$CR_PATH/ric-registration"
72 if [ $__httpx == "HTTPS" ]; then
76 if [[ $interface = *"SDNC"* ]]; then
79 if [[ $interface = *"DMAAP"* ]]; then
88 if [[ $interface = *"SDNC"* ]]; then
91 if [[ $interface = *"DMAAP"* ]]; then
98 start_ric_simulators ricsim_g1 1 OSC_2.1.0
99 start_ric_simulators ricsim_g2 1 STD_1.1.3
100 if [ "$PMS_VERSION" == "V2" ]; then
101 start_ric_simulators ricsim_g3 1 STD_2.0.0
112 if [[ $interface = *"SDNC"* ]]; then
114 prepare_consul_config SDNC ".consul_config.json"
116 prepare_consul_config NOSDNC ".consul_config.json"
119 consul_config_app ".consul_config.json"
121 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
122 sim_put_policy_type 201 ricsim_g1_1 2 testdata/OSC/sim_2.json
124 if [ "$PMS_VERSION" == "V2" ]; then
125 api_equal json:rics 3 60
127 api_equal json:policy-types 3 120
129 api_equal json:policies 0
131 api_equal json:policy-instances 0
133 api_equal json:rics 2 60
135 api_equal json:policy_schemas 3 120
137 api_equal json:policy_types 3
139 api_equal json:policies 0
141 api_equal json:policy_ids 0
144 if [ "$PMS_VERSION" == "V2" ]; then
145 cr_equal received_callbacks 3 120
146 cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1
148 mr_equal requests_submitted 0
151 echo "############################################"
152 echo "############## Health check ################"
153 echo "############################################"
157 echo "############################################"
158 echo "##### Service registry and supervision #####"
159 echo "############################################"
161 api_get_services 404 "service1"
163 api_put_service 201 "service1" 1000 "$CR_PATH/1"
165 api_put_service 200 "service1" 2000 "$CR_PATH/1"
168 api_put_service 400 "service2" -1 "$CR_PATH/2"
170 api_put_service 400 "service2" "wrong" "$CR_PATH/2"
172 api_put_service 400 "service2" 100 "/test"
174 api_put_service 400 "service2" 100 "test-path"
176 api_put_service 201 "service2" 300 "ftp://localhost:80/test"
178 api_get_services 200 "service1" "service1" 2000 "$CR_PATH/1"
180 api_get_service_ids 200 "service1" "service2" "ric-registration"
183 api_put_service 201 "service3" 5000 "$CR_PATH/3"
186 api_get_service_ids 200 "service1" "service2" "service3" "ric-registration"
189 api_get_services 200 "service1" "service1" 2000 "$CR_PATH/1"
191 api_get_services 200 NOSERVICE "service1" 2000 "$CR_PATH/1" "service2" 300 "ftp://localhost:80/test" "service3" 5000 "$CR_PATH/3" "ric-registration" 0 "$CR_PATH/ric-registration"
195 deviation "TR2 - Keep alive shall return 200/201 according to doc, only 200 works - test combo $interface and $__httpx"
196 #The below should work, keept here until fixed or other decision made
197 #api_put_services_keepalive 201 "service1"
198 #Using the below until decision
199 api_put_services_keepalive 200 "service1"
201 deviation "TR2 - Keep alive shall return 200/201 according to doc, only 200 works - test combo $interface and $__httpx"
202 #The below should work, keept here until fixed or other decision made
203 #api_put_services_keepalive 201 "service3"
204 #Using the below until decision
205 api_put_services_keepalive 200 "service3"
207 api_put_services_keepalive 200 "service1"
209 api_put_services_keepalive 200 "service3"
211 api_put_services_keepalive 404 "service5"
213 api_get_service_ids 200 "service1" "service2" "service3" "ric-registration"
215 api_delete_services 204 "service1"
217 api_get_service_ids 200 "service2" "service3" "ric-registration"
220 api_put_service 201 "service1" 50 "$CR_PATH/1"
222 api_get_service_ids 200 "service1" "service2" "service3" "ric-registration"
225 api_delete_services 204 "service1"
226 api_delete_services 204 "service3"
228 api_equal json:services 2
230 api_delete_services 204 "service2"
232 api_equal json:services 1
235 echo "############################################"
236 echo "############## RIC Repository ##############"
237 echo "############################################"
239 if [ "$PMS_VERSION" == "V2" ]; then
240 api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE ricsim_g3_1:me1_ricsim_g3_1,me2_ricsim_g3_1:NOTYPE:AVAILABLE"
242 api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
244 api_get_rics 200 1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
248 api_get_rics 404 "test"
250 if [ "$PMS_VERSION" == "V2" ]; then
251 api_get_ric 200 me1_ricsim_g1_1 NORIC "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
253 api_get_ric 200 me2_ricsim_g1_1 NORIC "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
255 api_get_ric 200 me1_ricsim_g2_1 NORIC "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
257 api_get_ric 200 me2_ricsim_g2_1 NORIC "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
259 api_get_ric 200 NOME ricsim_g1_1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
261 api_get_ric 200 NOME ricsim_g2_1 "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
263 api_get_ric 404 NOME test1
265 api_get_ric 404 test NORIC
267 api_get_ric 400 me1_ricsim_g1_1 ricsim_g1_1
269 api_get_ric 400 me1_ricsim_g1_1 TESTRIC
271 api_get_ric 400 TESTME ricsim_g1_1
274 api_get_ric 200 me1_ricsim_g1_1 ricsim_g1_1
276 api_get_ric 200 me2_ricsim_g1_1 ricsim_g1_1
278 api_get_ric 200 me1_ricsim_g2_1 ricsim_g2_1
280 api_get_ric 200 me2_ricsim_g2_1 ricsim_g2_1
285 echo "############################################"
286 echo "########### A1 Policy Management ###########"
287 echo "############################################"
289 if [ "$PMS_VERSION" == "V2" ]; then
290 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
291 #Behaviour accepted for now
292 api_get_policy_type 200 1 testdata/OSC/1-agent-modified.json
293 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
294 #Behaviour accepted for now
295 api_get_policy_type 200 2 testdata/OSC/2-agent-modified.json
297 api_get_policy_type 404 3
299 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
300 #Behaviour accepted for now
301 api_get_policy_schema 200 1 testdata/OSC/1-agent-modified.json
302 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
303 #Behaviour accepted for now
304 api_get_policy_schema 200 2 testdata/OSC/2-agent-modified.json
306 api_get_policy_schema 404 3
309 if [ "$PMS_VERSION" == "V2" ]; then
310 api_get_policy_schemas 404
312 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
313 #Behaviour accepted for now
314 api_get_policy_schemas 200 NORIC testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json NOFILE
315 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
316 #Behaviour accepted for now
317 api_get_policy_schemas 200 ricsim_g1_1 testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json
319 api_get_policy_schemas 200 ricsim_g2_1 NOFILE
321 api_get_policy_schemas 404 test
326 api_get_policy_types 200 NORIC 1 2 EMPTY
328 api_get_policy_types 200 ricsim_g1_1 1 2
330 api_get_policy_types 200 ricsim_g2_1 EMPTY
332 api_get_policy_types 404 dummy-ric
336 api_put_service 201 "service10" 3600 "$CR_PATH/1"
338 if [ "$PMS_VERSION" == "V2" ]; then
339 notificationurl=$CR_PATH"/test"
343 deviation "TR10 - agent allows policy creation on unregistered service (orig problem) - test combo $interface and $__httpx"
345 #api_put_policy 400 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json
347 api_put_policy 201 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
349 api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
350 api_put_policy 200 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
352 api_put_policy 200 "service10" ricsim_g1_1 1 5000 true $notificationurl testdata/OSC/pi1_template.json
353 api_put_policy 200 "service10" ricsim_g1_1 1 5000 false $notificationurl testdata/OSC/pi1_template.json
355 api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
356 api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
358 api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 true $notificationurl testdata/STD/pi1_template.json
359 api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 false $notificationurl testdata/STD/pi1_template.json
362 api_get_policy_status 200 5000 OSC "$VAL" "false"
363 api_get_policy_status 200 5100 STD "UNDEFINED"
366 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
368 #api_equal json:policies 2
370 api_equal json:policies 3
372 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
374 #api_equal json:policy_ids 2
376 if [ "$PMS_VERSION" == "V2" ]; then
377 api_equal json:policy-instances 3
379 api_equal json:policy_ids 3
382 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
384 #api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100
385 #Allow policy create with unregistered service for now
386 api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100 2000
389 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
391 #api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000
392 #Allow policy create with unregistered service for now
393 api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000 2000
395 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100
398 api_get_policy_ids 200 NORIC "service10" NOTYPE 5000 5100
400 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
402 #api_get_policy_ids 200 NORIC NOSERVICE 1 5000
403 #Allow policy create with unregistered service for now
404 api_get_policy_ids 200 NORIC NOSERVICE 1 5000 2000
406 api_get_policy_ids 200 NORIC NOSERVICE 2 NOID
408 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE 1 NOID
410 if [ "$PMS_VERSION" == "V2" ]; then
411 api_get_policy 200 5000 testdata/OSC/pi1_template.json "service10" ricsim_g1_1 1 false $notificationurl
413 api_get_policy 200 5100 testdata/STD/pi1_template.json "service10" ricsim_g2_1 NOTYPE false $notificationurl
415 api_get_policies 200 ricsim_g1_1 "service10" 1 5000 ricsim_g1_1 "service10" 1 false $notificationurl testdata/OSC/pi1_template.json
417 api_get_policy 200 5000 testdata/OSC/pi1_template.json
419 api_get_policy 200 5100 testdata/STD/pi1_template.json
421 api_get_policies 200 ricsim_g1_1 "service10" 1 5000 ricsim_g1_1 "service10" 1 testdata/OSC/pi1_template.json
424 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
426 #api_delete_policy 404 2000
427 #Allow policy create with unregistered service for now
428 api_delete_policy 204 2000
430 api_delete_policy 404 1500
432 api_delete_policy 204 5000
434 api_equal json:policies 1
436 if [ "$PMS_VERSION" == "V2" ]; then
437 api_equal json:policy-instances 1
439 api_equal json:policy_ids 1
442 api_delete_policy 204 5100
444 api_equal json:policies 0
446 if [ "$PMS_VERSION" == "V2" ]; then
447 api_equal json:policy-instances 0
449 api_equal json:policy_ids 0
452 if [ "$PMS_VERSION" == "V2" ]; then
453 cr_equal received_callbacks 3
456 if [[ $interface = *"DMAAP"* ]]; then
457 mr_greater requests_submitted 0
458 VAL=$(mr_read requests_submitted)
459 mr_equal requests_fetched $VAL
460 mr_equal responses_submitted $VAL
461 mr_equal responses_fetched $VAL
462 mr_equal current_requests 0
463 mr_equal current_responses 0
465 mr_equal requests_submitted 0
468 if [[ $interface = *"SDNC"* ]]; then
469 sim_contains_str ricsim_g1_1 remote_hosts "a1-controller"
470 sim_contains_str ricsim_g2_1 remote_hosts "a1-controller"
471 if [ "$PMS_VERSION" == "V2" ]; then
472 sim_contains_str ricsim_g3_1 remote_hosts "a1-controller"
475 sim_contains_str ricsim_g1_1 remote_hosts "policy-agent"
476 sim_contains_str ricsim_g2_1 remote_hosts "policy-agent"
477 if [ "$PMS_VERSION" == "V2" ]; then
478 sim_contains_str ricsim_g3_1 remote_hosts "policy-agent"
482 check_policy_agent_logs
483 check_control_panel_logs
485 if [[ $interface = *"SDNC"* ]]; then
489 store_logs "${__httpx}__${interface}"
495 #### TEST COMPLETE ####
500 auto_clean_containers