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 walkthrough using agent REST/DMAAP and with/without SDNC A1 Controller"
23 #App names to include in the test when running docker, space separated list
24 DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
26 #App names to include in the test when running kubernetes, space separated list
27 KUBE_INCLUDED_IMAGES="CP CR MR PA RICSIM SDNC"
28 #Prestarted app (not started by script) to include in the test when running kubernetes, space separated list
29 KUBE_PRESTARTED_IMAGES=""
31 #Supported test environment profiles
32 SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN"
34 SUPPORTED_RUNMODES="DOCKER KUBE"
36 . ../common/testcase_common.sh $@
37 . ../common/agent_api_functions.sh
38 . ../common/consul_cbs_functions.sh
39 . ../common/control_panel_api_functions.sh
40 . ../common/controller_api_functions.sh
41 . ../common/cr_api_functions.sh
42 . ../common/mr_api_functions.sh
43 . ../common/ricsimulator_api_functions.sh
50 # Tested variants of REST/DMAAP/SDNC config
51 TESTED_VARIANTS="REST DMAAP REST+SDNC DMAAP+SDNC"
53 #Test agent and simulator protocol versions (others are http only)
54 TESTED_PROTOCOLS="HTTP HTTPS"
56 for __httpx in $TESTED_PROTOCOLS ; do
57 for interface in $TESTED_VARIANTS ; do
59 echo "#####################################################################"
60 echo "#####################################################################"
61 echo "### Testing agent: $interface using $__httpx"
62 echo "#####################################################################"
63 echo "#####################################################################"
65 # Clean container and start all needed containers #
68 if [ $__httpx == "HTTPS" ]; then
76 start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/application.yaml
80 # Create service to be able to receive events when rics becomes available
81 # Must use rest towards the agent since dmaap is not configured yet
82 api_put_service 201 "ric-registration" 0 "$CR_SERVICE_PATH/ric-registration"
85 if [ $__httpx == "HTTPS" ]; then
88 if [[ $interface = *"SDNC"* ]]; then
91 if [[ $interface = *"DMAAP"* ]]; then
99 if [[ $interface = *"SDNC"* ]]; then
102 if [[ $interface = *"DMAAP"* ]]; then
109 start_ric_simulators ricsim_g1 1 OSC_2.1.0
110 start_ric_simulators ricsim_g2 1 STD_1.1.3
111 if [ "$PMS_VERSION" == "V2" ]; then
112 start_ric_simulators ricsim_g3 1 STD_2.0.0
119 start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/application.properties
121 if [ $RUNMODE == "DOCKER" ]; then
125 if [[ $interface = *"SDNC"* ]]; then
127 prepare_consul_config SDNC ".consul_config.json"
129 prepare_consul_config NOSDNC ".consul_config.json"
132 if [ $RUNMODE == "KUBE" ]; then
133 agent_load_config ".consul_config.json"
135 consul_config_app ".consul_config.json"
138 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
139 sim_put_policy_type 201 ricsim_g1_1 2 testdata/OSC/sim_2.json
141 if [ "$PMS_VERSION" == "V2" ]; then
142 sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
143 sim_put_policy_type 201 ricsim_g3_1 STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
145 api_equal json:rics 3 300
147 api_equal json:policy-types 5 120
149 api_equal json:policies 0
151 api_equal json:policy-instances 0
153 api_equal json:rics 2 300
155 api_equal json:policy_schemas 3 120
157 api_equal json:policy_types 3
159 api_equal json:policies 0
161 api_equal json:policy_ids 0
164 if [ "$PMS_VERSION" == "V2" ]; then
165 cr_equal received_callbacks 3 120
166 cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1
168 mr_equal requests_submitted 0
171 echo "############################################"
172 echo "############## Health check ################"
173 echo "############################################"
177 echo "############################################"
178 echo "##### Service registry and supervision #####"
179 echo "############################################"
181 api_get_services 404 "service1"
183 api_put_service 201 "service1" 1000 "$CR_SERVICE_PATH/1"
185 api_put_service 200 "service1" 2000 "$CR_SERVICE_PATH/1"
188 api_put_service 400 "service2" -1 "$CR_SERVICE_PATH/2"
190 api_put_service 400 "service2" "wrong" "$CR_SERVICE_PATH/2"
192 api_put_service 400 "service2" 100 "/test"
194 api_put_service 400 "service2" 100 "test-path"
196 api_put_service 201 "service2" 300 "ftp://localhost:80/test"
198 api_get_services 200 "service1" "service1" 2000 "$CR_SERVICE_PATH/1"
200 api_get_service_ids 200 "service1" "service2" "ric-registration"
203 api_put_service 201 "service3" 5000 "$CR_SERVICE_PATH/3"
206 api_get_service_ids 200 "service1" "service2" "service3" "ric-registration"
209 api_get_services 200 "service1" "service1" 2000 "$CR_SERVICE_PATH/1"
211 api_get_services 200 NOSERVICE "service1" 2000 "$CR_SERVICE_PATH/1" "service2" 300 "ftp://localhost:80/test" "service3" 5000 "$CR_SERVICE_PATH/3" "ric-registration" 0 "$CR_SERVICE_PATH/ric-registration"
215 deviation "TR2 - Keep alive shall return 200/201 according to doc, only 200 works - test combo $interface and $__httpx"
216 #The below should work, keept here until fixed or other decision made
217 #api_put_services_keepalive 201 "service1"
218 #Using the below until decision
219 api_put_services_keepalive 200 "service1"
221 deviation "TR2 - Keep alive shall return 200/201 according to doc, only 200 works - test combo $interface and $__httpx"
222 #The below should work, keept here until fixed or other decision made
223 #api_put_services_keepalive 201 "service3"
224 #Using the below until decision
225 api_put_services_keepalive 200 "service3"
227 api_put_services_keepalive 200 "service1"
229 api_put_services_keepalive 200 "service3"
231 api_put_services_keepalive 404 "service5"
233 api_get_service_ids 200 "service1" "service2" "service3" "ric-registration"
235 api_delete_services 204 "service1"
237 api_get_service_ids 200 "service2" "service3" "ric-registration"
240 api_put_service 201 "service1" 50 "$CR_SERVICE_PATH/1"
242 api_get_service_ids 200 "service1" "service2" "service3" "ric-registration"
245 api_delete_services 204 "service1"
246 api_delete_services 204 "service3"
248 api_equal json:services 2
250 api_delete_services 204 "service2"
252 api_equal json:services 1
255 echo "############################################"
256 echo "############## RIC Repository ##############"
257 echo "############################################"
259 if [ "$PMS_VERSION" == "V2" ]; then
260 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:STD_QOS_0_2_0,STD_QOS2_0.1.0:AVAILABLE"
262 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"
264 api_get_rics 200 1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
268 api_get_rics 404 "test"
270 if [ "$PMS_VERSION" == "V2" ]; then
271 api_get_ric 200 me1_ricsim_g1_1 NORIC "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
273 api_get_ric 200 me2_ricsim_g1_1 NORIC "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
275 api_get_ric 200 me1_ricsim_g2_1 NORIC "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
277 api_get_ric 200 me2_ricsim_g2_1 NORIC "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
279 api_get_ric 200 me1_ricsim_g3_1 NORIC "ricsim_g3_1:me1_ricsim_g3_1,me2_ricsim_g3_1:STD_QOS_0_2_0,STD_QOS2_0.1.0:AVAILABLE"
281 api_get_ric 200 me2_ricsim_g3_1 NORIC "ricsim_g3_1:me1_ricsim_g3_1,me2_ricsim_g3_1:STD_QOS_0_2_0,STD_QOS2_0.1.0:AVAILABLE"
283 api_get_ric 200 NOME ricsim_g1_1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
285 api_get_ric 200 NOME ricsim_g2_1 "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
287 api_get_ric 200 NOME ricsim_g3_1 "ricsim_g3_1:me1_ricsim_g3_1,me2_ricsim_g3_1:STD_QOS_0_2_0,STD_QOS2_0.1.0:AVAILABLE"
289 api_get_ric 404 NOME test1
291 api_get_ric 404 test NORIC
293 api_get_ric 400 me1_ricsim_g1_1 ricsim_g1_1
295 api_get_ric 400 me1_ricsim_g1_1 TESTRIC
297 api_get_ric 400 TESTME ricsim_g1_1
300 api_get_ric 200 me1_ricsim_g1_1 ricsim_g1_1
302 api_get_ric 200 me2_ricsim_g1_1 ricsim_g1_1
304 api_get_ric 200 me1_ricsim_g2_1 ricsim_g2_1
306 api_get_ric 200 me2_ricsim_g2_1 ricsim_g2_1
311 echo "############################################"
312 echo "########### A1 Policy Management ###########"
313 echo "############################################"
315 if [ "$PMS_VERSION" == "V2" ]; then
316 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
317 #Behaviour accepted for now
318 api_get_policy_type 200 1 testdata/OSC/1-agent-modified.json
319 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
320 #Behaviour accepted for now
321 api_get_policy_type 200 2 testdata/OSC/2-agent-modified.json
322 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
323 #Behaviour accepted for now
324 api_get_policy_type 200 STD_QOS_0_2_0 testdata/STD2/qos-agent-modified.json
325 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
326 #Behaviour accepted for now
327 api_get_policy_type 200 STD_QOS2_0.1.0 testdata/STD2/qos2-agent-modified.json
329 api_get_policy_type 404 3
331 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
332 #Behaviour accepted for now
333 api_get_policy_schema 200 1 testdata/OSC/1-agent-modified.json
334 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
335 #Behaviour accepted for now
336 api_get_policy_schema 200 2 testdata/OSC/2-agent-modified.json
338 api_get_policy_schema 404 3
341 if [ "$PMS_VERSION" == "V2" ]; then
342 api_get_policy_schemas 404
344 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
345 #Behaviour accepted for now
346 api_get_policy_schemas 200 NORIC testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json NOFILE
347 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
348 #Behaviour accepted for now
349 api_get_policy_schemas 200 ricsim_g1_1 testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json
351 api_get_policy_schemas 200 ricsim_g2_1 NOFILE
353 api_get_policy_schemas 404 test
357 if [ "$PMS_VERSION" == "V2" ]; then
358 api_get_policy_types 200 NORIC 1 2 EMPTY STD_QOS_0_2_0 STD_QOS2_0.1.0
360 api_get_policy_types 200 NORIC 1 2 EMPTY
363 api_get_policy_types 200 ricsim_g1_1 1 2
365 api_get_policy_types 200 ricsim_g2_1 EMPTY
367 if [ "$PMS_VERSION" == "V2" ]; then
368 api_get_policy_types 200 ricsim_g3_1 STD_QOS_0_2_0 STD_QOS2_0.1.0
371 api_get_policy_types 404 dummy-ric
375 api_put_service 201 "service10" 3600 "$CR_SERVICE_PATH/1"
377 if [ "$PMS_VERSION" == "V2" ]; then
378 notificationurl=$CR_SERVICE_PATH"/test"
382 deviation "TR10 - agent allows policy creation on unregistered service (orig problem) - test combo $interface and $__httpx"
384 #api_put_policy 400 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json
386 api_put_policy 201 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
388 api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
389 api_put_policy 200 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
391 api_put_policy 200 "service10" ricsim_g1_1 1 5000 true $notificationurl testdata/OSC/pi1_template.json
392 api_put_policy 200 "service10" ricsim_g1_1 1 5000 false $notificationurl testdata/OSC/pi1_template.json
394 api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
395 api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
397 api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 true $notificationurl testdata/STD/pi1_template.json
398 api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 false $notificationurl testdata/STD/pi1_template.json
400 if [ "$PMS_VERSION" == "V2" ]; then
401 api_put_policy 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json
402 api_put_policy 200 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json
404 api_put_policy 200 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 true $notificationurl testdata/STD2/pi_qos2_template.json
405 api_put_policy 200 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 false $notificationurl testdata/STD2/pi_qos2_template.json
409 api_get_policy_status 200 5000 OSC "$VAL" "false"
410 api_get_policy_status 200 5100 STD "UNDEFINED"
411 if [ "$PMS_VERSION" == "V2" ]; then
412 api_get_policy_status 200 5200 STD2 EMPTY EMPTY
416 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
418 #api_equal json:policies 2
420 if [ "$PMS_VERSION" == "V2" ]; then
421 api_equal json:policies 4
423 api_equal json:policies 3
426 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
428 #api_equal json:policy_ids 2
430 if [ "$PMS_VERSION" == "V2" ]; then
431 api_equal json:policy-instances 4
433 api_equal json:policy_ids 3
436 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
438 #api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100
439 #Allow policy create with unregistered service for now
440 if [ "$PMS_VERSION" == "V2" ]; then
441 api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100 2000 5200
443 api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100 2000
446 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
448 #api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000
449 #Allow policy create with unregistered service for now
450 if [ "$PMS_VERSION" == "V2" ]; then
451 api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000 2000
453 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100
455 api_get_policy_ids 200 ricsim_g3_1 NOSERVICE NOTYPE 5200
457 api_get_policy_ids 200 NORIC "service10" NOTYPE 5000 5100 5200
459 api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000 2000
461 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100
464 api_get_policy_ids 200 NORIC "service10" NOTYPE 5000 5100
467 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
469 #api_get_policy_ids 200 NORIC NOSERVICE 1 5000
470 #Allow policy create with unregistered service for now
472 api_get_policy_ids 200 NORIC NOSERVICE 1 5000 2000
474 api_get_policy_ids 200 NORIC NOSERVICE 2 NOID
476 if [ "$PMS_VERSION" == "V2" ]; then
477 api_get_policy_ids 200 NORIC NOSERVICE STD_QOS2_0.1.0 5200
480 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE 1 NOID
482 if [ "$PMS_VERSION" == "V2" ]; then
483 api_get_policy 200 5000 testdata/OSC/pi1_template.json "service10" ricsim_g1_1 1 false $notificationurl
485 api_get_policy 200 5100 testdata/STD/pi1_template.json "service10" ricsim_g2_1 NOTYPE false $notificationurl
487 api_get_policy 200 5200 testdata/STD2/pi_qos2_template.json "service10" ricsim_g3_1 STD_QOS2_0.1.0 false $notificationurl
489 api_get_policies 200 ricsim_g1_1 "service10" 1 5000 ricsim_g1_1 "service10" 1 false $notificationurl testdata/OSC/pi1_template.json
491 api_get_policy 200 5000 testdata/OSC/pi1_template.json
493 api_get_policy 200 5100 testdata/STD/pi1_template.json
495 api_get_policies 200 ricsim_g1_1 "service10" 1 5000 ricsim_g1_1 "service10" 1 testdata/OSC/pi1_template.json
498 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
500 #api_delete_policy 404 2000
501 #Allow policy create with unregistered service for now
502 api_delete_policy 204 2000
504 api_delete_policy 404 1500
506 api_delete_policy 204 5000
508 if [ "$PMS_VERSION" == "V2" ]; then
510 api_delete_policy 204 5200
513 api_equal json:policies 1
516 if [ "$PMS_VERSION" == "V2" ]; then
517 api_equal json:policy-instances 1
519 api_equal json:policy_ids 1
522 api_delete_policy 204 5100
524 api_equal json:policies 0
526 if [ "$PMS_VERSION" == "V2" ]; then
527 api_equal json:policy-instances 0
529 api_equal json:policy_ids 0
532 if [ "$PMS_VERSION" == "V2" ]; then
533 cr_equal received_callbacks 3
536 if [[ $interface = *"DMAAP"* ]]; then
537 mr_greater requests_submitted 0
538 VAL=$(mr_read requests_submitted)
539 mr_equal requests_fetched $VAL
540 mr_equal responses_submitted $VAL
541 mr_equal responses_fetched $VAL
542 mr_equal current_requests 0
543 mr_equal current_responses 0
545 mr_equal requests_submitted 0
548 if [[ $interface = *"SDNC"* ]]; then
549 sim_contains_str ricsim_g1_1 remote_hosts $SDNC_APP_NAME
550 sim_contains_str ricsim_g2_1 remote_hosts $SDNC_APP_NAME
551 if [ "$PMS_VERSION" == "V2" ]; then
552 sim_contains_str ricsim_g3_1 remote_hosts $SDNC_APP_NAME
555 sim_contains_str ricsim_g1_1 remote_hosts $POLICY_AGENT_APP_NAME
556 sim_contains_str ricsim_g2_1 remote_hosts $POLICY_AGENT_APP_NAME
557 if [ "$PMS_VERSION" == "V2" ]; then
558 sim_contains_str ricsim_g3_1 remote_hosts $POLICY_AGENT_APP_NAME
562 check_policy_agent_logs
563 check_control_panel_logs
565 if [[ $interface = *"SDNC"* ]]; then
569 store_logs "${__httpx}__${interface}"
575 #### TEST COMPLETE ####
580 auto_clean_environment