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"
26 . ../common/testcase_common.sh $@
27 . ../common/agent_api_functions.sh
28 . ../common/ricsimulator_api_functions.sh
34 # Tested variants of REST/DMAAP/SDNC config
35 TESTED_VARIANTS="REST DMAAP REST+SDNC DMAAP+SDNC"
37 #Test agent and simulator protocol versions (others are http only)
38 TESTED_PROTOCOLS="HTTP HTTPS"
40 for __httpx in $TESTED_PROTOCOLS ; do
41 for interface in $TESTED_VARIANTS ; do
43 echo "#####################################################################"
44 echo "#####################################################################"
45 echo "### Testing agent: $interface using $__httpx"
46 echo "#####################################################################"
47 echo "#####################################################################"
49 if [ $__httpx == "HTTPS" ]; then
50 CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks"
54 if [[ $interface = *"SDNC"* ]]; then
57 if [[ $interface = *"DMAAP"* ]]; then
63 CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
67 if [[ $interface = *"SDNC"* ]]; then
70 if [[ $interface = *"DMAAP"* ]]; then
77 # Clean container and start all needed containers #
80 start_ric_simulators ricsim_g1 1 OSC_2.1.0
81 start_ric_simulators ricsim_g2 1 STD_1.1.3
82 if [ "$PMS_VERSION" == "V2" ]; then
83 start_ric_simulators ricsim_g3 1 STD_2.0.0
92 if [[ $interface = *"SDNC"* ]]; then
94 prepare_consul_config SDNC ".consul_config.json"
96 prepare_consul_config NOSDNC ".consul_config.json"
99 consul_config_app ".consul_config.json"
107 cr_equal received_callbacks 0
108 mr_equal requests_submitted 0
110 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
111 sim_put_policy_type 201 ricsim_g1_1 2 testdata/OSC/sim_2.json
113 if [ "$PMS_VERSION" == "V2" ]; then
114 api_equal json:rics 3 60
116 #api_equal json:policy-schemas 3 120
118 api_equal json:policy-types 3 120
120 api_equal json:policies 0
122 api_equal json:policy_instances 0
124 api_equal json:rics 2 60
126 api_equal json:policy_schemas 3 120
128 api_equal json:policy_types 3
130 api_equal json:policies 0
132 api_equal json:policy_ids 0
136 echo "############################################"
137 echo "############## Health check ################"
138 echo "############################################"
142 echo "############################################"
143 echo "##### Service registry and supervision #####"
144 echo "############################################"
146 api_get_services 404 "service1"
148 api_put_service 201 "service1" 1000 "$CR_PATH/1"
150 api_put_service 200 "service1" 2000 "$CR_PATH/1"
153 api_put_service 400 "service2" -1 "$CR_PATH/2"
155 api_put_service 400 "service2" "wrong" "$CR_PATH/2"
157 api_put_service 400 "service2" 100 "/test"
159 api_put_service 400 "service2" 100 "test-path"
161 api_put_service 201 "service2" 300 "ftp://localhost:80/test"
163 api_get_services 200 "service1" "service1" 2000 "$CR_PATH/1"
165 api_get_service_ids 200 "service1" "service2"
168 api_put_service 201 "service3" 5000 "$CR_PATH/3"
171 api_get_service_ids 200 "service1" "service2" "service3"
174 api_get_services 200 "service1" "service1" 2000 "$CR_PATH/1"
176 api_get_services 200 NOSERVICE "service1" 2000 "$CR_PATH/1" "service2" 300 "ftp://localhost:80/test" "service3" 5000 "$CR_PATH/3"
180 deviation "TR2 - Keep alive shall return 200/201 according to doc, only 200 works - test combo $interface and $__httpx"
181 #The below should work, keept here until fixed or other decision made
182 #api_put_services_keepalive 201 "service1"
183 #Using the below until decision
184 api_put_services_keepalive 200 "service1"
186 deviation "TR2 - Keep alive shall return 200/201 according to doc, only 200 works - test combo $interface and $__httpx"
187 #The below should work, keept here until fixed or other decision made
188 #api_put_services_keepalive 201 "service3"
189 #Using the below until decision
190 api_put_services_keepalive 200 "service3"
192 api_put_services_keepalive 200 "service1"
194 api_put_services_keepalive 200 "service3"
196 api_put_services_keepalive 404 "service5"
198 api_get_service_ids 200 "service1" "service2" "service3"
200 api_delete_services 204 "service1"
202 api_get_service_ids 200 "service2" "service3"
205 api_put_service 201 "service1" 50 "$CR_PATH/1"
207 api_get_service_ids 200 "service1" "service2" "service3"
210 api_delete_services 204 "service1"
211 api_delete_services 204 "service3"
213 api_equal json:services 1
215 api_delete_services 204 "service2"
217 api_equal json:services 0
220 echo "############################################"
221 echo "############## RIC Repository ##############"
222 echo "############################################"
224 if [ "$PMS_VERSION" == "V2" ]; then
225 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"
227 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"
229 api_get_rics 200 1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
233 api_get_rics 404 "test"
235 if [ "$PMS_VERSION" == "V2" ]; then
236 api_get_ric 200 me1_ricsim_g1_1 NORIC "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
238 api_get_ric 200 me2_ricsim_g1_1 NORIC "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
240 api_get_ric 200 me1_ricsim_g2_1 NORIC "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
242 api_get_ric 200 me2_ricsim_g2_1 NORIC "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
244 api_get_ric 200 NOME ricsim_g1_1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
246 api_get_ric 200 NOME ricsim_g2_1 "ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
248 api_get_ric 404 NOME test1
250 api_get_ric 404 test NORIC
252 api_get_ric 400 me1_ricsim_g1_1 ricsim_g1_1
254 api_get_ric 400 me1_ricsim_g1_1 TESTRIC
256 api_get_ric 400 TESTME ricsim_g1_1
259 api_get_ric 200 me1_ricsim_g1_1 ricsim_g1_1
261 api_get_ric 200 me2_ricsim_g1_1 ricsim_g1_1
263 api_get_ric 200 me1_ricsim_g2_1 ricsim_g2_1
265 api_get_ric 200 me2_ricsim_g2_1 ricsim_g2_1
270 echo "############################################"
271 echo "########### A1 Policy Management ###########"
272 echo "############################################"
274 if [ "$PMS_VERSION" == "V2" ]; then
275 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
276 #Behaviour accepted for now
277 api_get_policy_type 200 1 testdata/OSC/1-agent-modified.json
278 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
279 #Behaviour accepted for now
280 api_get_policy_type 200 2 testdata/OSC/2-agent-modified.json
282 api_get_policy_type 404 3
284 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
285 #Behaviour accepted for now
286 api_get_policy_schema 200 1 testdata/OSC/1-agent-modified.json
287 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
288 #Behaviour accepted for now
289 api_get_policy_schema 200 2 testdata/OSC/2-agent-modified.json
291 api_get_policy_schema 404 3
294 if [ "$PMS_VERSION" == "V2" ]; then
295 api_get_policy_schemas 404
297 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
298 #Behaviour accepted for now
299 api_get_policy_schemas 200 NORIC testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json NOFILE
300 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
301 #Behaviour accepted for now
302 api_get_policy_schemas 200 ricsim_g1_1 testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json
304 api_get_policy_schemas 200 ricsim_g2_1 NOFILE
306 api_get_policy_schemas 404 test
311 api_get_policy_types 200 NORIC 1 2 EMPTY
313 api_get_policy_types 200 ricsim_g1_1 1 2
315 api_get_policy_types 200 ricsim_g2_1 EMPTY
317 api_get_policy_types 404 dummy-ric
321 api_put_service 201 "service10" 3600 "$CR_PATH/1"
323 if [ "$PMS_VERSION" == "V2" ]; then
324 notificationurl="http://localhost:80"
328 deviation "TR10 - agent allows policy creation on unregistered service (orig problem) - test combo $interface and $__httpx"
330 #api_put_policy 400 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json
332 api_put_policy 201 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
334 api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
335 api_put_policy 200 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
337 api_put_policy 200 "service10" ricsim_g1_1 1 5000 true $notificationurl testdata/OSC/pi1_template.json
338 api_put_policy 200 "service10" ricsim_g1_1 1 5000 false $notificationurl testdata/OSC/pi1_template.json
340 api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
341 api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
343 api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 true $notificationurl testdata/STD/pi1_template.json
344 api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 false $notificationurl testdata/STD/pi1_template.json
347 api_get_policy_status 200 5000 OSC "$VAL" "false"
348 api_get_policy_status 200 5100 STD "UNDEFINED"
351 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
353 #api_equal json:policies 2
355 api_equal json:policies 3
357 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
359 #api_equal json:policy_ids 2
361 if [ "$PMS_VERSION" == "V2" ]; then
362 api_equal json:policy_instances 3
364 api_equal json:policy_ids 3
367 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
369 #api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100
370 #Allow policy create with unregistered service for now
371 api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100 2000
374 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
376 #api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000
377 #Allow policy create with unregistered service for now
378 api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000 2000
380 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100
383 api_get_policy_ids 200 NORIC "service10" NOTYPE 5000 5100
385 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
387 #api_get_policy_ids 200 NORIC NOSERVICE 1 5000
388 #Allow policy create with unregistered service for now
389 api_get_policy_ids 200 NORIC NOSERVICE 1 5000 2000
391 api_get_policy_ids 200 NORIC NOSERVICE 2 NOID
393 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE 1 NOID
395 if [ "$PMS_VERSION" == "V2" ]; then
396 api_get_policy 200 5000 testdata/OSC/pi1_template.json "service10" ricsim_g1_1 1 false $notificationurl
398 api_get_policy 200 5100 testdata/STD/pi1_template.json "service10" ricsim_g2_1 NOTYPE false $notificationurl
400 api_get_policies 200 ricsim_g1_1 "service10" 1 5000 ricsim_g1_1 "service10" 1 false $notificationurl testdata/OSC/pi1_template.json
402 api_get_policy 200 5000 testdata/OSC/pi1_template.json
404 api_get_policy 200 5100 testdata/STD/pi1_template.json
406 api_get_policies 200 ricsim_g1_1 "service10" 1 5000 ricsim_g1_1 "service10" 1 testdata/OSC/pi1_template.json
409 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
411 #api_delete_policy 404 2000
412 #Allow policy create with unregistered service for now
413 api_delete_policy 204 2000
415 api_delete_policy 404 1500
417 api_delete_policy 204 5000
419 api_equal json:policies 1
421 if [ "$PMS_VERSION" == "V2" ]; then
422 api_equal json:policy_instances 1
424 api_equal json:policy_ids 1
427 api_delete_policy 204 5100
429 api_equal json:policies 0
431 if [ "$PMS_VERSION" == "V2" ]; then
432 api_equal json:policy_instances 0
434 api_equal json:policy_ids 0
437 cr_equal received_callbacks 0
439 if [[ $interface = *"DMAAP"* ]]; then
440 mr_greater requests_submitted 0
441 VAL=$(mr_read requests_submitted)
442 mr_equal requests_fetched $VAL
443 mr_equal responses_submitted $VAL
444 mr_equal responses_fetched $VAL
445 mr_equal current_requests 0
446 mr_equal current_responses 0
448 mr_equal requests_submitted 0
451 if [[ $interface = *"SDNC"* ]]; then
452 sim_contains_str ricsim_g1_1 remote_hosts "a1-controller"
453 sim_contains_str ricsim_g2_1 remote_hosts "a1-controller"
454 if [ "$PMS_VERSION" == "V2" ]; then
455 sim_contains_str ricsim_g3_1 remote_hosts "a1-controller"
458 sim_contains_str ricsim_g1_1 remote_hosts "policy-agent"
459 sim_contains_str ricsim_g2_1 remote_hosts "policy-agent"
460 if [ "$PMS_VERSION" == "V2" ]; then
461 sim_contains_str ricsim_g3_1 remote_hosts "policy-agent"
465 check_policy_agent_logs
466 check_control_panel_logs
468 store_logs "${__httpx}__${interface}"
474 #### TEST COMPLETE ####
479 auto_clean_containers