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"
27 #SUPPORTED TEST ENV FILE
28 SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-CHERRY"
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
69 # Create service to be able to receive events when rics becomes available
70 # Must use rest towards the agent since dmaap is not configured yet
71 api_put_service 201 "ric-registration" 0 "$CR_PATH/ric-registration"
74 if [ $__httpx == "HTTPS" ]; then
77 if [[ $interface = *"SDNC"* ]]; then
80 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 sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
126 sim_put_policy_type 201 ricsim_g3_1 STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
128 api_equal json:rics 3 60
130 api_equal json:policy-types 5 120
132 api_equal json:policies 0
134 api_equal json:policy-instances 0
136 api_equal json:rics 2 60
138 api_equal json:policy_schemas 3 120
140 api_equal json:policy_types 3
142 api_equal json:policies 0
144 api_equal json:policy_ids 0
147 if [ "$PMS_VERSION" == "V2" ]; then
148 cr_equal received_callbacks 3 120
149 cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1
151 mr_equal requests_submitted 0
154 echo "############################################"
155 echo "############## Health check ################"
156 echo "############################################"
160 echo "############################################"
161 echo "##### Service registry and supervision #####"
162 echo "############################################"
164 api_get_services 404 "service1"
166 api_put_service 201 "service1" 1000 "$CR_PATH/1"
168 api_put_service 200 "service1" 2000 "$CR_PATH/1"
171 api_put_service 400 "service2" -1 "$CR_PATH/2"
173 api_put_service 400 "service2" "wrong" "$CR_PATH/2"
175 api_put_service 400 "service2" 100 "/test"
177 api_put_service 400 "service2" 100 "test-path"
179 api_put_service 201 "service2" 300 "ftp://localhost:80/test"
181 api_get_services 200 "service1" "service1" 2000 "$CR_PATH/1"
183 api_get_service_ids 200 "service1" "service2" "ric-registration"
186 api_put_service 201 "service3" 5000 "$CR_PATH/3"
189 api_get_service_ids 200 "service1" "service2" "service3" "ric-registration"
192 api_get_services 200 "service1" "service1" 2000 "$CR_PATH/1"
194 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"
198 deviation "TR2 - Keep alive shall return 200/201 according to doc, only 200 works - test combo $interface and $__httpx"
199 #The below should work, keept here until fixed or other decision made
200 #api_put_services_keepalive 201 "service1"
201 #Using the below until decision
202 api_put_services_keepalive 200 "service1"
204 deviation "TR2 - Keep alive shall return 200/201 according to doc, only 200 works - test combo $interface and $__httpx"
205 #The below should work, keept here until fixed or other decision made
206 #api_put_services_keepalive 201 "service3"
207 #Using the below until decision
208 api_put_services_keepalive 200 "service3"
210 api_put_services_keepalive 200 "service1"
212 api_put_services_keepalive 200 "service3"
214 api_put_services_keepalive 404 "service5"
216 api_get_service_ids 200 "service1" "service2" "service3" "ric-registration"
218 api_delete_services 204 "service1"
220 api_get_service_ids 200 "service2" "service3" "ric-registration"
223 api_put_service 201 "service1" 50 "$CR_PATH/1"
225 api_get_service_ids 200 "service1" "service2" "service3" "ric-registration"
228 api_delete_services 204 "service1"
229 api_delete_services 204 "service3"
231 api_equal json:services 2
233 api_delete_services 204 "service2"
235 api_equal json:services 1
238 echo "############################################"
239 echo "############## RIC Repository ##############"
240 echo "############################################"
242 if [ "$PMS_VERSION" == "V2" ]; then
243 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"
245 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"
247 api_get_rics 200 1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
251 api_get_rics 404 "test"
253 if [ "$PMS_VERSION" == "V2" ]; then
254 api_get_ric 200 me1_ricsim_g1_1 NORIC "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
256 api_get_ric 200 me2_ricsim_g1_1 NORIC "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
258 api_get_ric 200 me1_ricsim_g2_1 NORIC "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
260 api_get_ric 200 me2_ricsim_g2_1 NORIC "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
262 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"
264 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"
266 api_get_ric 200 NOME ricsim_g1_1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
268 api_get_ric 200 NOME ricsim_g2_1 "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
270 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"
272 api_get_ric 404 NOME test1
274 api_get_ric 404 test NORIC
276 api_get_ric 400 me1_ricsim_g1_1 ricsim_g1_1
278 api_get_ric 400 me1_ricsim_g1_1 TESTRIC
280 api_get_ric 400 TESTME ricsim_g1_1
283 api_get_ric 200 me1_ricsim_g1_1 ricsim_g1_1
285 api_get_ric 200 me2_ricsim_g1_1 ricsim_g1_1
287 api_get_ric 200 me1_ricsim_g2_1 ricsim_g2_1
289 api_get_ric 200 me2_ricsim_g2_1 ricsim_g2_1
294 echo "############################################"
295 echo "########### A1 Policy Management ###########"
296 echo "############################################"
298 if [ "$PMS_VERSION" == "V2" ]; then
299 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
300 #Behaviour accepted for now
301 api_get_policy_type 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_type 200 2 testdata/OSC/2-agent-modified.json
305 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
306 #Behaviour accepted for now
307 api_get_policy_type 200 STD_QOS_0_2_0 testdata/STD2/qos-agent-modified.json
308 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
309 #Behaviour accepted for now
310 api_get_policy_type 200 STD_QOS2_0.1.0 testdata/STD2/qos2-agent-modified.json
312 api_get_policy_type 404 3
314 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
315 #Behaviour accepted for now
316 api_get_policy_schema 200 1 testdata/OSC/1-agent-modified.json
317 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
318 #Behaviour accepted for now
319 api_get_policy_schema 200 2 testdata/OSC/2-agent-modified.json
321 api_get_policy_schema 404 3
324 if [ "$PMS_VERSION" == "V2" ]; then
325 api_get_policy_schemas 404
327 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
328 #Behaviour accepted for now
329 api_get_policy_schemas 200 NORIC testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json NOFILE
330 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
331 #Behaviour accepted for now
332 api_get_policy_schemas 200 ricsim_g1_1 testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json
334 api_get_policy_schemas 200 ricsim_g2_1 NOFILE
336 api_get_policy_schemas 404 test
340 if [ "$PMS_VERSION" == "V2" ]; then
341 api_get_policy_types 200 NORIC 1 2 EMPTY STD_QOS_0_2_0 STD_QOS2_0.1.0
343 api_get_policy_types 200 NORIC 1 2 EMPTY
346 api_get_policy_types 200 ricsim_g1_1 1 2
348 api_get_policy_types 200 ricsim_g2_1 EMPTY
350 if [ "$PMS_VERSION" == "V2" ]; then
351 api_get_policy_types 200 ricsim_g3_1 STD_QOS_0_2_0 STD_QOS2_0.1.0
354 api_get_policy_types 404 dummy-ric
358 api_put_service 201 "service10" 3600 "$CR_PATH/1"
360 if [ "$PMS_VERSION" == "V2" ]; then
361 notificationurl=$CR_PATH"/test"
365 deviation "TR10 - agent allows policy creation on unregistered service (orig problem) - test combo $interface and $__httpx"
367 #api_put_policy 400 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json
369 api_put_policy 201 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
371 api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
372 api_put_policy 200 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
374 api_put_policy 200 "service10" ricsim_g1_1 1 5000 true $notificationurl testdata/OSC/pi1_template.json
375 api_put_policy 200 "service10" ricsim_g1_1 1 5000 false $notificationurl testdata/OSC/pi1_template.json
377 api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
378 api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
380 api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 true $notificationurl testdata/STD/pi1_template.json
381 api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 false $notificationurl testdata/STD/pi1_template.json
383 if [ "$PMS_VERSION" == "V2" ]; then
384 api_put_policy 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json
385 api_put_policy 200 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json
387 api_put_policy 200 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 true $notificationurl testdata/STD2/pi_qos2_template.json
388 api_put_policy 200 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 false $notificationurl testdata/STD2/pi_qos2_template.json
392 api_get_policy_status 200 5000 OSC "$VAL" "false"
393 api_get_policy_status 200 5100 STD "UNDEFINED"
394 if [ "$PMS_VERSION" == "V2" ]; then
395 api_get_policy_status 200 5200 STD2 EMPTY EMPTY
399 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
401 #api_equal json:policies 2
403 if [ "$PMS_VERSION" == "V2" ]; then
404 api_equal json:policies 4
406 api_equal json:policies 3
409 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
411 #api_equal json:policy_ids 2
413 if [ "$PMS_VERSION" == "V2" ]; then
414 api_equal json:policy-instances 4
416 api_equal json:policy_ids 3
419 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
421 #api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100
422 #Allow policy create with unregistered service for now
423 if [ "$PMS_VERSION" == "V2" ]; then
424 api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100 2000 5200
426 api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100 2000
429 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
431 #api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000
432 #Allow policy create with unregistered service for now
433 if [ "$PMS_VERSION" == "V2" ]; then
434 api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000 2000
436 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100
438 api_get_policy_ids 200 ricsim_g3_1 NOSERVICE NOTYPE 5200
440 api_get_policy_ids 200 NORIC "service10" NOTYPE 5000 5100 5200
442 api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000 2000
444 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100
447 api_get_policy_ids 200 NORIC "service10" NOTYPE 5000 5100
450 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
452 #api_get_policy_ids 200 NORIC NOSERVICE 1 5000
453 #Allow policy create with unregistered service for now
455 api_get_policy_ids 200 NORIC NOSERVICE 1 5000 2000
457 api_get_policy_ids 200 NORIC NOSERVICE 2 NOID
459 if [ "$PMS_VERSION" == "V2" ]; then
460 api_get_policy_ids 200 NORIC NOSERVICE STD_QOS2_0.1.0 5200
463 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE 1 NOID
465 if [ "$PMS_VERSION" == "V2" ]; then
466 api_get_policy 200 5000 testdata/OSC/pi1_template.json "service10" ricsim_g1_1 1 false $notificationurl
468 api_get_policy 200 5100 testdata/STD/pi1_template.json "service10" ricsim_g2_1 NOTYPE false $notificationurl
470 api_get_policy 200 5200 testdata/STD2/pi_qos2_template.json "service10" ricsim_g3_1 STD_QOS2_0.1.0 false $notificationurl
472 api_get_policies 200 ricsim_g1_1 "service10" 1 5000 ricsim_g1_1 "service10" 1 false $notificationurl testdata/OSC/pi1_template.json
474 api_get_policy 200 5000 testdata/OSC/pi1_template.json
476 api_get_policy 200 5100 testdata/STD/pi1_template.json
478 api_get_policies 200 ricsim_g1_1 "service10" 1 5000 ricsim_g1_1 "service10" 1 testdata/OSC/pi1_template.json
481 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
483 #api_delete_policy 404 2000
484 #Allow policy create with unregistered service for now
485 api_delete_policy 204 2000
487 api_delete_policy 404 1500
489 api_delete_policy 204 5000
491 if [ "$PMS_VERSION" == "V2" ]; then
493 api_delete_policy 204 5200
496 api_equal json:policies 1
499 if [ "$PMS_VERSION" == "V2" ]; then
500 api_equal json:policy-instances 1
502 api_equal json:policy_ids 1
505 api_delete_policy 204 5100
507 api_equal json:policies 0
509 if [ "$PMS_VERSION" == "V2" ]; then
510 api_equal json:policy-instances 0
512 api_equal json:policy_ids 0
515 if [ "$PMS_VERSION" == "V2" ]; then
516 cr_equal received_callbacks 3
519 if [[ $interface = *"DMAAP"* ]]; then
520 mr_greater requests_submitted 0
521 VAL=$(mr_read requests_submitted)
522 mr_equal requests_fetched $VAL
523 mr_equal responses_submitted $VAL
524 mr_equal responses_fetched $VAL
525 mr_equal current_requests 0
526 mr_equal current_responses 0
528 mr_equal requests_submitted 0
531 if [[ $interface = *"SDNC"* ]]; then
532 sim_contains_str ricsim_g1_1 remote_hosts "a1-controller"
533 sim_contains_str ricsim_g2_1 remote_hosts "a1-controller"
534 if [ "$PMS_VERSION" == "V2" ]; then
535 sim_contains_str ricsim_g3_1 remote_hosts "a1-controller"
538 sim_contains_str ricsim_g1_1 remote_hosts "policy-agent"
539 sim_contains_str ricsim_g2_1 remote_hosts "policy-agent"
540 if [ "$PMS_VERSION" == "V2" ]; then
541 sim_contains_str ricsim_g3_1 remote_hosts "policy-agent"
545 check_policy_agent_logs
546 check_control_panel_logs
548 if [[ $interface = *"SDNC"* ]]; then
552 store_logs "${__httpx}__${interface}"
558 #### TEST COMPLETE ####
563 auto_clean_containers