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, space separated list
24 INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
26 #SUPPORTED TEST ENV FILE
27 SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN"
29 . ../common/testcase_common.sh $@
30 . ../common/agent_api_functions.sh
31 . ../common/ricsimulator_api_functions.sh
32 . ../common/cr_api_functions.sh
38 # Tested variants of REST/DMAAP/SDNC config
39 TESTED_VARIANTS="REST DMAAP REST+SDNC DMAAP+SDNC"
41 #Test agent and simulator protocol versions (others are http only)
42 TESTED_PROTOCOLS="HTTP HTTPS"
44 for __httpx in $TESTED_PROTOCOLS ; do
45 for interface in $TESTED_VARIANTS ; do
47 echo "#####################################################################"
48 echo "#####################################################################"
49 echo "### Testing agent: $interface using $__httpx"
50 echo "#####################################################################"
51 echo "#####################################################################"
53 # Clean container and start all needed containers #
56 if [ $__httpx == "HTTPS" ]; then
68 # Create service to be able to receive events when rics becomes available
69 # Must use rest towards the agent since dmaap is not configured yet
70 api_put_service 201 "ric-registration" 0 "$CR_PATH/ric-registration"
73 if [ $__httpx == "HTTPS" ]; then
76 if [[ $interface = *"SDNC"* ]]; then
79 if [[ $interface = *"DMAAP"* ]]; then
87 if [[ $interface = *"SDNC"* ]]; then
90 if [[ $interface = *"DMAAP"* ]]; then
97 start_ric_simulators ricsim_g1 1 OSC_2.1.0
98 start_ric_simulators ricsim_g2 1 STD_1.1.3
99 if [ "$PMS_VERSION" == "V2" ]; then
100 start_ric_simulators ricsim_g3 1 STD_2.0.0
111 if [[ $interface = *"SDNC"* ]]; then
113 prepare_consul_config SDNC ".consul_config.json"
115 prepare_consul_config NOSDNC ".consul_config.json"
118 consul_config_app ".consul_config.json"
120 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
121 sim_put_policy_type 201 ricsim_g1_1 2 testdata/OSC/sim_2.json
123 if [ "$PMS_VERSION" == "V2" ]; then
124 sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
125 sim_put_policy_type 201 ricsim_g3_1 STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
127 api_equal json:rics 3 60
129 api_equal json:policy-types 5 120
131 api_equal json:policies 0
133 api_equal json:policy-instances 0
135 api_equal json:rics 2 60
137 api_equal json:policy_schemas 3 120
139 api_equal json:policy_types 3
141 api_equal json:policies 0
143 api_equal json:policy_ids 0
146 if [ "$PMS_VERSION" == "V2" ]; then
147 cr_equal received_callbacks 3 120
148 cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1
150 mr_equal requests_submitted 0
153 echo "############################################"
154 echo "############## Health check ################"
155 echo "############################################"
159 echo "############################################"
160 echo "##### Service registry and supervision #####"
161 echo "############################################"
163 api_get_services 404 "service1"
165 api_put_service 201 "service1" 1000 "$CR_PATH/1"
167 api_put_service 200 "service1" 2000 "$CR_PATH/1"
170 api_put_service 400 "service2" -1 "$CR_PATH/2"
172 api_put_service 400 "service2" "wrong" "$CR_PATH/2"
174 api_put_service 400 "service2" 100 "/test"
176 api_put_service 400 "service2" 100 "test-path"
178 api_put_service 201 "service2" 300 "ftp://localhost:80/test"
180 api_get_services 200 "service1" "service1" 2000 "$CR_PATH/1"
182 api_get_service_ids 200 "service1" "service2" "ric-registration"
185 api_put_service 201 "service3" 5000 "$CR_PATH/3"
188 api_get_service_ids 200 "service1" "service2" "service3" "ric-registration"
191 api_get_services 200 "service1" "service1" 2000 "$CR_PATH/1"
193 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"
197 deviation "TR2 - Keep alive shall return 200/201 according to doc, only 200 works - test combo $interface and $__httpx"
198 #The below should work, keept here until fixed or other decision made
199 #api_put_services_keepalive 201 "service1"
200 #Using the below until decision
201 api_put_services_keepalive 200 "service1"
203 deviation "TR2 - Keep alive shall return 200/201 according to doc, only 200 works - test combo $interface and $__httpx"
204 #The below should work, keept here until fixed or other decision made
205 #api_put_services_keepalive 201 "service3"
206 #Using the below until decision
207 api_put_services_keepalive 200 "service3"
209 api_put_services_keepalive 200 "service1"
211 api_put_services_keepalive 200 "service3"
213 api_put_services_keepalive 404 "service5"
215 api_get_service_ids 200 "service1" "service2" "service3" "ric-registration"
217 api_delete_services 204 "service1"
219 api_get_service_ids 200 "service2" "service3" "ric-registration"
222 api_put_service 201 "service1" 50 "$CR_PATH/1"
224 api_get_service_ids 200 "service1" "service2" "service3" "ric-registration"
227 api_delete_services 204 "service1"
228 api_delete_services 204 "service3"
230 api_equal json:services 2
232 api_delete_services 204 "service2"
234 api_equal json:services 1
237 echo "############################################"
238 echo "############## RIC Repository ##############"
239 echo "############################################"
241 if [ "$PMS_VERSION" == "V2" ]; then
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 ricsim_g3_1:me1_ricsim_g3_1,me2_ricsim_g3_1:STD_QOS_0_2_0,STD_QOS2_0.1.0:AVAILABLE"
244 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"
246 api_get_rics 200 1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
250 api_get_rics 404 "test"
252 if [ "$PMS_VERSION" == "V2" ]; then
253 api_get_ric 200 me1_ricsim_g1_1 NORIC "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
255 api_get_ric 200 me2_ricsim_g1_1 NORIC "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
257 api_get_ric 200 me1_ricsim_g2_1 NORIC "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
259 api_get_ric 200 me2_ricsim_g2_1 NORIC "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
261 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"
263 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"
265 api_get_ric 200 NOME ricsim_g1_1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
267 api_get_ric 200 NOME ricsim_g2_1 "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
269 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"
271 api_get_ric 404 NOME test1
273 api_get_ric 404 test NORIC
275 api_get_ric 400 me1_ricsim_g1_1 ricsim_g1_1
277 api_get_ric 400 me1_ricsim_g1_1 TESTRIC
279 api_get_ric 400 TESTME ricsim_g1_1
282 api_get_ric 200 me1_ricsim_g1_1 ricsim_g1_1
284 api_get_ric 200 me2_ricsim_g1_1 ricsim_g1_1
286 api_get_ric 200 me1_ricsim_g2_1 ricsim_g2_1
288 api_get_ric 200 me2_ricsim_g2_1 ricsim_g2_1
293 echo "############################################"
294 echo "########### A1 Policy Management ###########"
295 echo "############################################"
297 if [ "$PMS_VERSION" == "V2" ]; then
298 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
299 #Behaviour accepted for now
300 api_get_policy_type 200 1 testdata/OSC/1-agent-modified.json
301 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
302 #Behaviour accepted for now
303 api_get_policy_type 200 2 testdata/OSC/2-agent-modified.json
304 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
305 #Behaviour accepted for now
306 api_get_policy_type 200 STD_QOS_0_2_0 testdata/STD2/qos-agent-modified.json
307 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
308 #Behaviour accepted for now
309 api_get_policy_type 200 STD_QOS2_0.1.0 testdata/STD2/qos2-agent-modified.json
311 api_get_policy_type 404 3
313 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
314 #Behaviour accepted for now
315 api_get_policy_schema 200 1 testdata/OSC/1-agent-modified.json
316 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
317 #Behaviour accepted for now
318 api_get_policy_schema 200 2 testdata/OSC/2-agent-modified.json
320 api_get_policy_schema 404 3
323 if [ "$PMS_VERSION" == "V2" ]; then
324 api_get_policy_schemas 404
326 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
327 #Behaviour accepted for now
328 api_get_policy_schemas 200 NORIC testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json NOFILE
329 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
330 #Behaviour accepted for now
331 api_get_policy_schemas 200 ricsim_g1_1 testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json
333 api_get_policy_schemas 200 ricsim_g2_1 NOFILE
335 api_get_policy_schemas 404 test
339 if [ "$PMS_VERSION" == "V2" ]; then
340 api_get_policy_types 200 NORIC 1 2 EMPTY STD_QOS_0_2_0 STD_QOS2_0.1.0
342 api_get_policy_types 200 NORIC 1 2 EMPTY
345 api_get_policy_types 200 ricsim_g1_1 1 2
347 api_get_policy_types 200 ricsim_g2_1 EMPTY
349 if [ "$PMS_VERSION" == "V2" ]; then
350 api_get_policy_types 200 ricsim_g3_1 STD_QOS_0_2_0 STD_QOS2_0.1.0
353 api_get_policy_types 404 dummy-ric
357 api_put_service 201 "service10" 3600 "$CR_PATH/1"
359 if [ "$PMS_VERSION" == "V2" ]; then
360 notificationurl=$CR_PATH"/test"
364 deviation "TR10 - agent allows policy creation on unregistered service (orig problem) - test combo $interface and $__httpx"
366 #api_put_policy 400 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json
368 api_put_policy 201 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
370 api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
371 api_put_policy 200 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
373 api_put_policy 200 "service10" ricsim_g1_1 1 5000 true $notificationurl testdata/OSC/pi1_template.json
374 api_put_policy 200 "service10" ricsim_g1_1 1 5000 false $notificationurl testdata/OSC/pi1_template.json
376 api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
377 api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
379 api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 true $notificationurl testdata/STD/pi1_template.json
380 api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 false $notificationurl testdata/STD/pi1_template.json
382 if [ "$PMS_VERSION" == "V2" ]; then
383 api_put_policy 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json
384 api_put_policy 200 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json
386 api_put_policy 200 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 true $notificationurl testdata/STD2/pi_qos2_template.json
387 api_put_policy 200 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 false $notificationurl testdata/STD2/pi_qos2_template.json
391 api_get_policy_status 200 5000 OSC "$VAL" "false"
392 api_get_policy_status 200 5100 STD "UNDEFINED"
393 if [ "$PMS_VERSION" == "V2" ]; then
394 api_get_policy_status 200 5200 STD2 EMPTY EMPTY
398 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
400 #api_equal json:policies 2
402 if [ "$PMS_VERSION" == "V2" ]; then
403 api_equal json:policies 4
405 api_equal json:policies 3
408 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
410 #api_equal json:policy_ids 2
412 if [ "$PMS_VERSION" == "V2" ]; then
413 api_equal json:policy-instances 4
415 api_equal json:policy_ids 3
418 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
420 #api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100
421 #Allow policy create with unregistered service for now
422 if [ "$PMS_VERSION" == "V2" ]; then
423 api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100 2000 5200
425 api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100 2000
428 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
430 #api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000
431 #Allow policy create with unregistered service for now
432 if [ "$PMS_VERSION" == "V2" ]; then
433 api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000 2000
435 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100
437 api_get_policy_ids 200 ricsim_g3_1 NOSERVICE NOTYPE 5200
439 api_get_policy_ids 200 NORIC "service10" NOTYPE 5000 5100 5200
441 api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000 2000
443 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100
446 api_get_policy_ids 200 NORIC "service10" NOTYPE 5000 5100
449 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
451 #api_get_policy_ids 200 NORIC NOSERVICE 1 5000
452 #Allow policy create with unregistered service for now
454 api_get_policy_ids 200 NORIC NOSERVICE 1 5000 2000
456 api_get_policy_ids 200 NORIC NOSERVICE 2 NOID
458 if [ "$PMS_VERSION" == "V2" ]; then
459 api_get_policy_ids 200 NORIC NOSERVICE STD_QOS2_0.1.0 5200
462 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE 1 NOID
464 if [ "$PMS_VERSION" == "V2" ]; then
465 api_get_policy 200 5000 testdata/OSC/pi1_template.json "service10" ricsim_g1_1 1 false $notificationurl
467 api_get_policy 200 5100 testdata/STD/pi1_template.json "service10" ricsim_g2_1 NOTYPE false $notificationurl
469 api_get_policy 200 5200 testdata/STD2/pi_qos2_template.json "service10" ricsim_g3_1 STD_QOS2_0.1.0 false $notificationurl
471 api_get_policies 200 ricsim_g1_1 "service10" 1 5000 ricsim_g1_1 "service10" 1 false $notificationurl testdata/OSC/pi1_template.json
473 api_get_policy 200 5000 testdata/OSC/pi1_template.json
475 api_get_policy 200 5100 testdata/STD/pi1_template.json
477 api_get_policies 200 ricsim_g1_1 "service10" 1 5000 ricsim_g1_1 "service10" 1 testdata/OSC/pi1_template.json
480 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
482 #api_delete_policy 404 2000
483 #Allow policy create with unregistered service for now
484 api_delete_policy 204 2000
486 api_delete_policy 404 1500
488 api_delete_policy 204 5000
490 if [ "$PMS_VERSION" == "V2" ]; then
492 api_delete_policy 204 5200
495 api_equal json:policies 1
498 if [ "$PMS_VERSION" == "V2" ]; then
499 api_equal json:policy-instances 1
501 api_equal json:policy_ids 1
504 api_delete_policy 204 5100
506 api_equal json:policies 0
508 if [ "$PMS_VERSION" == "V2" ]; then
509 api_equal json:policy-instances 0
511 api_equal json:policy_ids 0
514 if [ "$PMS_VERSION" == "V2" ]; then
515 cr_equal received_callbacks 3
518 if [[ $interface = *"DMAAP"* ]]; then
519 mr_greater requests_submitted 0
520 VAL=$(mr_read requests_submitted)
521 mr_equal requests_fetched $VAL
522 mr_equal responses_submitted $VAL
523 mr_equal responses_fetched $VAL
524 mr_equal current_requests 0
525 mr_equal current_responses 0
527 mr_equal requests_submitted 0
530 if [[ $interface = *"SDNC"* ]]; then
531 sim_contains_str ricsim_g1_1 remote_hosts "a1-controller"
532 sim_contains_str ricsim_g2_1 remote_hosts "a1-controller"
533 if [ "$PMS_VERSION" == "V2" ]; then
534 sim_contains_str ricsim_g3_1 remote_hosts "a1-controller"
537 sim_contains_str ricsim_g1_1 remote_hosts "policy-agent"
538 sim_contains_str ricsim_g2_1 remote_hosts "policy-agent"
539 if [ "$PMS_VERSION" == "V2" ]; then
540 sim_contains_str ricsim_g3_1 remote_hosts "policy-agent"
544 check_policy_agent_logs
545 check_control_panel_logs
547 if [[ $interface = *"SDNC"* ]]; then
551 store_logs "${__httpx}__${interface}"
557 #### TEST COMPLETE ####
562 auto_clean_containers