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 NGW KUBEPROXY"
26 #App names to include in the test when running kubernetes, space separated list
27 KUBE_INCLUDED_IMAGES="CP CR MR PA RICSIM SDNC KUBEPROXY NGW"
28 #Prestarted app (not started by script) to include in the test when running kubernetes, space separated list
29 KUBE_PRESTARTED_IMAGES=""
31 #Ignore image in DOCKER_INCLUDED_IMAGES, KUBE_INCLUDED_IMAGES if
32 #the image is not configured in the supplied env_file
33 #Used for images not applicable to all supported profile
34 CONDITIONALLY_IGNORED_IMAGES="NGW"
36 #Supported test environment profiles
37 SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ONAP-ISTANBUL ONAP-JAKARTA ORAN-CHERRY ORAN-D-RELEASE ORAN-E-RELEASE ORAN-F-RELEASE"
39 SUPPORTED_RUNMODES="DOCKER KUBE"
41 . ../common/testcase_common.sh $@
49 # Tested variants of REST/DMAAP/SDNC config
50 TESTED_VARIANTS="REST DMAAP REST+SDNC DMAAP+SDNC"
52 #Test agent and simulator protocol versions (others are http only)
53 TESTED_PROTOCOLS="HTTP HTTPS"
55 for __httpx in $TESTED_PROTOCOLS ; do
56 for interface in $TESTED_VARIANTS ; do
58 echo "#####################################################################"
59 echo "#####################################################################"
60 echo "### Testing agent: $interface using $__httpx"
61 echo "#####################################################################"
62 echo "#####################################################################"
64 # Clean container and start all needed containers #
69 if [ $__httpx == "HTTPS" ]; then
77 start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/$POLICY_AGENT_CONFIG_FILE
81 # Create service to be able to receive events when rics becomes available
82 # Must use rest towards the agent since dmaap is not configured yet
83 api_put_service 201 "ric-registration" 0 "$CR_SERVICE_APP_PATH_0/ric-registration"
86 if [ $__httpx == "HTTPS" ]; then
89 if [[ $interface = *"SDNC"* ]]; then
92 if [[ $interface = *"DMAAP"* ]]; then
100 if [[ $interface = *"SDNC"* ]]; then
103 if [[ $interface = *"DMAAP"* ]]; then
110 start_ric_simulators ricsim_g1 1 OSC_2.1.0
111 start_ric_simulators ricsim_g2 1 STD_1.1.3
112 if [ "$PMS_VERSION" == "V2" ]; then
113 start_ric_simulators ricsim_g3 1 STD_2.0.0
120 start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
122 if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
123 start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
126 if [ $RUNMODE == "DOCKER" ]; then
130 if [[ $interface = *"SDNC"* ]]; then
132 prepare_consul_config SDNC ".consul_config.json"
134 prepare_consul_config NOSDNC ".consul_config.json"
137 if [ $RUNMODE == "KUBE" ]; then
138 agent_load_config ".consul_config.json"
140 consul_config_app ".consul_config.json"
143 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
144 sim_put_policy_type 201 ricsim_g1_1 2 testdata/OSC/sim_2.json
146 if [ "$PMS_VERSION" == "V2" ]; then
147 sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
148 sim_put_policy_type 201 ricsim_g3_1 STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
150 api_equal json:rics 3 300
152 api_equal json:policy-types 5 120
154 api_equal json:policies 0
156 api_equal json:policy-instances 0
158 api_equal json:rics 2 300
160 api_equal json:policy_schemas 3 120
162 api_equal json:policy_types 3
164 api_equal json:policies 0
166 api_equal json:policy_ids 0
169 if [ "$PMS_VERSION" == "V2" ]; then
170 cr_equal 0 received_callbacks 3 120
171 cr_api_check_all_sync_events 200 0 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1
173 mr_equal requests_submitted 0
176 echo "############################################"
177 echo "############## Health check ################"
178 echo "############################################"
182 echo "############################################"
183 echo "##### Service registry and supervision #####"
184 echo "############################################"
186 api_get_services 404 "service1"
188 api_put_service 201 "service1" 1000 "$CR_SERVICE_APP_PATH_0/1"
190 api_put_service 200 "service1" 2000 "$CR_SERVICE_APP_PATH_0/1"
193 api_put_service 400 "service2" -1 "$CR_SERVICE_APP_PATH_0/2"
195 api_put_service 400 "service2" "wrong" "$CR_SERVICE_APP_PATH_0/2"
197 api_put_service 400 "service2" 100 "/test"
199 api_put_service 400 "service2" 100 "test-path"
201 api_put_service 201 "service2" 300 "ftp://localhost:80/test"
203 api_get_services 200 "service1" "service1" 2000 "$CR_SERVICE_APP_PATH_0/1"
205 api_get_service_ids 200 "service1" "service2" "ric-registration"
208 api_put_service 201 "service3" 5000 "$CR_SERVICE_APP_PATH_0/3"
211 api_get_service_ids 200 "service1" "service2" "service3" "ric-registration"
214 api_get_services 200 "service1" "service1" 2000 "$CR_SERVICE_APP_PATH_0/1"
216 api_get_services 200 NOSERVICE "service1" 2000 "$CR_SERVICE_APP_PATH_0/1" "service2" 300 "ftp://localhost:80/test" "service3" 5000 "$CR_SERVICE_APP_PATH_0/3" "ric-registration" 0 "$CR_SERVICE_APP_PATH_0/ric-registration"
220 deviation "TR2 - Keep alive shall return 200/201 according to doc, only 200 works - test combo $interface and $__httpx"
221 #The below should work, keept here until fixed or other decision made
222 #api_put_services_keepalive 201 "service1"
223 #Using the below until decision
224 api_put_services_keepalive 200 "service1"
226 deviation "TR2 - Keep alive shall return 200/201 according to doc, only 200 works - test combo $interface and $__httpx"
227 #The below should work, keept here until fixed or other decision made
228 #api_put_services_keepalive 201 "service3"
229 #Using the below until decision
230 api_put_services_keepalive 200 "service3"
232 api_put_services_keepalive 200 "service1"
234 api_put_services_keepalive 200 "service3"
236 api_put_services_keepalive 404 "service5"
238 api_get_service_ids 200 "service1" "service2" "service3" "ric-registration"
240 api_delete_services 204 "service1"
242 api_get_service_ids 200 "service2" "service3" "ric-registration"
245 api_put_service 201 "service1" 50 "$CR_SERVICE_APP_PATH_0/1"
247 api_get_service_ids 200 "service1" "service2" "service3" "ric-registration"
250 api_delete_services 204 "service1"
251 api_delete_services 204 "service3"
253 api_equal json:services 2
255 api_delete_services 204 "service2"
257 api_equal json:services 1
260 echo "############################################"
261 echo "############## RIC Repository ##############"
262 echo "############################################"
264 if [ "$PMS_VERSION" == "V2" ]; then
265 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"
267 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"
269 api_get_rics 200 1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
273 api_get_rics 404 "test"
275 if [ "$PMS_VERSION" == "V2" ]; then
276 api_get_ric 200 me1_ricsim_g1_1 NORIC "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
278 api_get_ric 200 me2_ricsim_g1_1 NORIC "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
280 api_get_ric 200 me1_ricsim_g2_1 NORIC "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
282 api_get_ric 200 me2_ricsim_g2_1 NORIC "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
284 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"
286 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"
288 api_get_ric 200 NOME ricsim_g1_1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
290 api_get_ric 200 NOME ricsim_g2_1 "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
292 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"
294 api_get_ric 404 NOME test1
296 api_get_ric 404 test NORIC
298 api_get_ric 400 me1_ricsim_g1_1 ricsim_g1_1
300 api_get_ric 400 me1_ricsim_g1_1 TESTRIC
302 api_get_ric 400 TESTME ricsim_g1_1
305 api_get_ric 200 me1_ricsim_g1_1 ricsim_g1_1
307 api_get_ric 200 me2_ricsim_g1_1 ricsim_g1_1
309 api_get_ric 200 me1_ricsim_g2_1 ricsim_g2_1
311 api_get_ric 200 me2_ricsim_g2_1 ricsim_g2_1
316 echo "############################################"
317 echo "########### A1 Policy Management ###########"
318 echo "############################################"
320 if [ "$PMS_VERSION" == "V2" ]; then
321 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
322 #Behaviour accepted for now
323 api_get_policy_type 200 1 testdata/OSC/1-agent-modified.json
324 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
325 #Behaviour accepted for now
326 api_get_policy_type 200 2 testdata/OSC/2-agent-modified.json
327 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
328 #Behaviour accepted for now
329 api_get_policy_type 200 STD_QOS_0_2_0 testdata/STD2/qos-agent-modified.json
330 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
331 #Behaviour accepted for now
332 api_get_policy_type 200 STD_QOS2_0.1.0 testdata/STD2/qos2-agent-modified.json
334 api_get_policy_type 404 3
336 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
337 #Behaviour accepted for now
338 api_get_policy_schema 200 1 testdata/OSC/1-agent-modified.json
339 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
340 #Behaviour accepted for now
341 api_get_policy_schema 200 2 testdata/OSC/2-agent-modified.json
343 api_get_policy_schema 404 3
346 if [ "$PMS_VERSION" == "V2" ]; then
347 api_get_policy_schemas 404
349 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
350 #Behaviour accepted for now
351 api_get_policy_schemas 200 NORIC testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json NOFILE
352 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
353 #Behaviour accepted for now
354 api_get_policy_schemas 200 ricsim_g1_1 testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json
356 api_get_policy_schemas 200 ricsim_g2_1 NOFILE
358 api_get_policy_schemas 404 test
362 if [ "$PMS_VERSION" == "V2" ]; then
363 api_get_policy_types 200 NORIC 1 2 EMPTY STD_QOS_0_2_0 STD_QOS2_0.1.0
365 api_get_policy_types 200 NORIC 1 2 EMPTY
368 api_get_policy_types 200 ricsim_g1_1 1 2
370 api_get_policy_types 200 ricsim_g2_1 EMPTY
372 if [ "$PMS_VERSION" == "V2" ]; then
373 api_get_policy_types 200 ricsim_g3_1 STD_QOS_0_2_0 STD_QOS2_0.1.0
376 api_get_policy_types 404 dummy-ric
380 api_put_service 201 "service10" 3600 "$CR_SERVICE_APP_PATH_0/1"
382 if [ "$PMS_VERSION" == "V2" ]; then
383 notificationurl=$CR_SERVICE_APP_PATH_0"/test"
387 deviation "TR10 - agent allows policy creation on unregistered service (orig problem) - test combo $interface and $__httpx"
389 #api_put_policy 400 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json
391 api_put_policy 201 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
393 api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
394 api_put_policy 200 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
396 api_put_policy 200 "service10" ricsim_g1_1 1 5000 true $notificationurl testdata/OSC/pi1_template.json
397 api_put_policy 200 "service10" ricsim_g1_1 1 5000 false $notificationurl testdata/OSC/pi1_template.json
399 api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
400 api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
402 api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 true $notificationurl testdata/STD/pi1_template.json
403 api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 false $notificationurl testdata/STD/pi1_template.json
405 if [ "$PMS_VERSION" == "V2" ]; then
406 api_put_policy 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json
407 api_put_policy 200 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json
409 api_put_policy 200 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 true $notificationurl testdata/STD2/pi_qos2_template.json
410 api_put_policy 200 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 false $notificationurl testdata/STD2/pi_qos2_template.json
414 api_get_policy_status 200 5000 OSC "$VAL" "false"
415 api_get_policy_status 200 5100 STD "UNDEFINED"
416 if [ "$PMS_VERSION" == "V2" ]; then
417 api_get_policy_status 200 5200 STD2 EMPTY EMPTY
421 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
423 #api_equal json:policies 2
425 if [ "$PMS_VERSION" == "V2" ]; then
426 api_equal json:policies 4
428 api_equal json:policies 3
431 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
433 #api_equal json:policy_ids 2
435 if [ "$PMS_VERSION" == "V2" ]; then
436 api_equal json:policy-instances 4
438 api_equal json:policy_ids 3
441 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
443 #api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100
444 #Allow policy create with unregistered service for now
445 if [ "$PMS_VERSION" == "V2" ]; then
446 api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100 2000 5200
448 api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100 2000
451 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
453 #api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000
454 #Allow policy create with unregistered service for now
455 if [ "$PMS_VERSION" == "V2" ]; then
456 api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000 2000
458 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100
460 api_get_policy_ids 200 ricsim_g3_1 NOSERVICE NOTYPE 5200
462 api_get_policy_ids 200 NORIC "service10" NOTYPE 5000 5100 5200
464 api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000 2000
466 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100
469 api_get_policy_ids 200 NORIC "service10" NOTYPE 5000 5100
472 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
474 #api_get_policy_ids 200 NORIC NOSERVICE 1 5000
475 #Allow policy create with unregistered service for now
477 api_get_policy_ids 200 NORIC NOSERVICE 1 5000 2000
479 api_get_policy_ids 200 NORIC NOSERVICE 2 NOID
481 if [ "$PMS_VERSION" == "V2" ]; then
482 api_get_policy_ids 200 NORIC NOSERVICE STD_QOS2_0.1.0 5200
485 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE 1 NOID
487 if [ "$PMS_VERSION" == "V2" ]; then
488 api_get_policy 200 5000 testdata/OSC/pi1_template.json "service10" ricsim_g1_1 1 false $notificationurl
490 api_get_policy 200 5100 testdata/STD/pi1_template.json "service10" ricsim_g2_1 NOTYPE false $notificationurl
492 api_get_policy 200 5200 testdata/STD2/pi_qos2_template.json "service10" ricsim_g3_1 STD_QOS2_0.1.0 false $notificationurl
494 api_get_policies 200 ricsim_g1_1 "service10" 1 5000 ricsim_g1_1 "service10" 1 false $notificationurl testdata/OSC/pi1_template.json
496 api_get_policy 200 5000 testdata/OSC/pi1_template.json
498 api_get_policy 200 5100 testdata/STD/pi1_template.json
500 api_get_policies 200 ricsim_g1_1 "service10" 1 5000 ricsim_g1_1 "service10" 1 testdata/OSC/pi1_template.json
503 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
505 #api_delete_policy 404 2000
506 #Allow policy create with unregistered service for now
507 api_delete_policy 204 2000
509 api_delete_policy 404 1500
511 api_delete_policy 204 5000
513 if [ "$PMS_VERSION" == "V2" ]; then
515 api_delete_policy 204 5200
518 api_equal json:policies 1
521 if [ "$PMS_VERSION" == "V2" ]; then
522 api_equal json:policy-instances 1
524 api_equal json:policy_ids 1
527 api_delete_policy 204 5100
529 api_equal json:policies 0
531 if [ "$PMS_VERSION" == "V2" ]; then
532 api_equal json:policy-instances 0
534 api_equal json:policy_ids 0
537 if [ "$PMS_VERSION" == "V2" ]; then
538 cr_equal 0 received_callbacks 3
541 if [[ $interface = *"DMAAP"* ]]; then
542 mr_greater requests_submitted 0
543 VAL=$(mr_read requests_submitted)
544 mr_equal requests_fetched $VAL
545 mr_equal responses_submitted $VAL
546 mr_equal responses_fetched $VAL
547 mr_equal current_requests 0
548 mr_equal current_responses 0
550 mr_equal requests_submitted 0
553 if [[ $interface = *"SDNC"* ]]; then
554 sim_contains_str ricsim_g1_1 remote_hosts $SDNC_APP_NAME
555 sim_contains_str ricsim_g2_1 remote_hosts $SDNC_APP_NAME
556 if [ "$PMS_VERSION" == "V2" ]; then
557 sim_contains_str ricsim_g3_1 remote_hosts $SDNC_APP_NAME
560 sim_contains_str ricsim_g1_1 remote_hosts $POLICY_AGENT_APP_NAME
561 sim_contains_str ricsim_g2_1 remote_hosts $POLICY_AGENT_APP_NAME
562 if [ "$PMS_VERSION" == "V2" ]; then
563 sim_contains_str ricsim_g3_1 remote_hosts $POLICY_AGENT_APP_NAME
567 check_policy_agent_logs
569 if [[ $interface = *"SDNC"* ]]; then
573 store_logs "${__httpx}__${interface}"
579 #### TEST COMPLETE ####
584 auto_clean_environment