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 exclude checking pulling images for, space separated list
24 EXCLUDED_IMAGES="SDNC_ONAP"
26 . ../common/testcase_common.sh $@
27 . ../common/agent_api_functions.sh
28 . ../common/ricsimulator_api_functions.sh
34 #Local vars in test script
35 ##########################
37 # Path to callback receiver
38 CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
40 # Tested variants of REST/DMAAP/SDNC config
41 TESTED_VARIANTS="REST DMAAP REST+SDNC DMAAP+SDNC"
42 #Test agent and simulator protocol versions (others are http only)
43 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 "#####################################################################"
54 # Clean container and start all needed containers #
57 if [ $__httpx == "HTTPS" ]; then
58 #"Using secure ports towards simulators"
61 #"Using non-secure ports towards simulators"
65 start_ric_simulators ricsim_g1 1 OSC_2.1.0
66 start_ric_simulators ricsim_g2 1 STD_1.1.3
70 if [ $__httpx == "HTTPS" ]; then
71 #echo "Using secure ports between agent and MR"
74 #"Using non-secure ports between agent and MR"
80 if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
84 if [ $__httpx == "HTTPS" ]; then
85 # "Using secure ports towards SDNC"
88 #"Using non-secure ports towards SDNC"
95 if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
96 prepare_consul_config SDNC ".consul_config.json"
98 prepare_consul_config NOSDNC ".consul_config.json"
101 consul_config_app ".consul_config.json"
109 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
112 if [ $__httpx == "HTTPS" ]; then
113 #"Using secure ports towards the agent"
116 #"Using non-secure ports towards the agent"
122 cr_equal received_callbacks 0
123 mr_equal requests_submitted 0
125 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
126 sim_put_policy_type 201 ricsim_g1_1 2 testdata/OSC/sim_2.json
128 api_equal json:rics 2 60
130 api_equal json:policy_schemas 3 120
132 api_equal json:policy_types 3
134 api_equal json:policies 0
136 api_equal json:policy_ids 0
141 echo "############################################"
142 echo "############## Health check ################"
143 echo "############################################"
147 echo "############################################"
148 echo "##### Service registry and supervision #####"
149 echo "############################################"
151 api_get_services 404 "service1"
153 api_put_service 201 "service1" 1000 "$CR_PATH/1"
155 api_put_service 200 "service1" 2000 "$CR_PATH/1"
158 api_put_service 400 "service2" -1 "$CR_PATH/2"
160 api_put_service 400 "service2" "wrong" "$CR_PATH/2"
162 api_put_service 400 "service2" 100 "/test"
164 api_put_service 400 "service2" 100 "test-path"
166 api_put_service 201 "service2" 300 "ftp://localhost:80/test"
168 api_get_services 200 "service1" "service1" 2000 "$CR_PATH/1"
170 api_get_service_ids 200 "service1" "service2"
173 api_put_service 201 "service3" 5000 "$CR_PATH/3"
176 api_get_service_ids 200 "service1" "service2" "service3"
179 api_get_services 200 "service1" "service1" 2000 "$CR_PATH/1"
181 api_get_services 200 NOSERVICE "service1" 2000 "$CR_PATH/1" "service2" 300 "ftp://localhost:80/test" "service3" 5000 "$CR_PATH/3"
185 deviation "TR2 - Keep alive shall return 200/201 according to doc, only 200 works - test combo $interface and $__httpx"
186 #The below should work, keept here until fixed or other decision made
187 #api_put_services_keepalive 201 "service1"
188 #Using the below until decision
189 api_put_services_keepalive 200 "service1"
191 deviation "TR2 - Keep alive shall return 200/201 according to doc, only 200 works - test combo $interface and $__httpx"
192 #The below should work, keept here until fixed or other decision made
193 #api_put_services_keepalive 201 "service3"
194 #Using the below until decision
195 api_put_services_keepalive 200 "service3"
197 api_put_services_keepalive 200 "service1"
199 api_put_services_keepalive 200 "service3"
201 api_put_services_keepalive 404 "service5"
203 api_get_service_ids 200 "service1" "service2" "service3"
205 api_delete_services 204 "service1"
207 api_get_service_ids 200 "service2" "service3"
210 api_put_service 201 "service1" 50 "$CR_PATH/1"
212 api_get_service_ids 200 "service1" "service2" "service3"
215 api_delete_services 204 "service1"
216 api_delete_services 204 "service3"
218 api_equal json:services 1
220 api_delete_services 204 "service2"
222 api_equal json:services 0
225 echo "############################################"
226 echo "############## RIC Repository ##############"
227 echo "############################################"
229 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"
231 api_get_rics 200 1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
235 api_get_rics 404 "test"
238 api_get_ric 200 me1_ricsim_g1_1 ricsim_g1_1
240 api_get_ric 200 me2_ricsim_g1_1 ricsim_g1_1
242 api_get_ric 200 me1_ricsim_g2_1 ricsim_g2_1
244 api_get_ric 200 me2_ricsim_g2_1 ricsim_g2_1
249 echo "############################################"
250 echo "########### A1 Policy Management ###########"
251 echo "############################################"
252 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
253 #Behaviour accepted for now
254 api_get_policy_schema 200 1 testdata/OSC/1-agent-modified.json
255 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
256 #Behaviour accepted for now
257 api_get_policy_schema 200 2 testdata/OSC/2-agent-modified.json
259 api_get_policy_schema 404 3
260 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
261 #Behaviour accepted for now
262 api_get_policy_schemas 200 NORIC testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json NOFILE
263 deviation "TR9 - agent modify the type with type id - test combo $interface and $__httpx"
264 #Behaviour accepted for now
265 api_get_policy_schemas 200 ricsim_g1_1 testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json
267 api_get_policy_schemas 200 ricsim_g2_1 NOFILE
269 api_get_policy_schemas 404 test
273 api_get_policy_types 200 NORIC 1 2 EMPTY
275 api_get_policy_types 200 ricsim_g1_1 1 2
277 api_get_policy_types 200 ricsim_g2_1 EMPTY
279 api_get_policy_types 404 dummy-ric
283 api_put_service 201 "service10" 3600 "$CR_PATH/1"
285 deviation "TR10 - agent allows policy creation on unregistered service (orig problem) - test combo $interface and $__httpx"
287 #api_put_policy 400 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json
289 api_put_policy 201 "unregistered-service" ricsim_g1_1 1 2000 NOTRANSIENT testdata/OSC/pi1_template.json
291 api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json
292 api_put_policy 200 "service10" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json
294 api_put_policy 200 "service10" ricsim_g1_1 1 5000 true testdata/OSC/pi1_template.json
295 api_put_policy 200 "service10" ricsim_g1_1 1 5000 false testdata/OSC/pi1_template.json
297 api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT testdata/STD/pi1_template.json
298 api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT testdata/STD/pi1_template.json
300 api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 true testdata/STD/pi1_template.json
301 api_put_policy 200 "service10" ricsim_g2_1 NOTYPE 5100 false testdata/STD/pi1_template.json
304 api_get_policy_status 200 5000 OSC "$VAL" "false"
305 api_get_policy_status 200 5100 STD "UNDEFINED"
308 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
310 #api_equal json:policies 2
312 api_equal json:policies 3
314 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
316 #api_equal json:policy_ids 2
318 api_equal json:policy_ids 3
320 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
322 #api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100
323 #Allow policy create with unregistered service for now
324 api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100 2000
327 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
329 #api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000
330 #Allow policy create with unregistered service for now
331 api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000 2000
333 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100
336 api_get_policy_ids 200 NORIC "service10" NOTYPE 5000 5100
338 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
340 #api_get_policy_ids 200 NORIC NOSERVICE 1 5000
341 #Allow policy create with unregistered service for now
342 api_get_policy_ids 200 NORIC NOSERVICE 1 5000 2000
344 api_get_policy_ids 200 NORIC NOSERVICE 2 NOID
346 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE 1 NOID
349 api_get_policy 200 5000 testdata/OSC/pi1_template.json
351 api_get_policy 200 5100 testdata/STD/pi1_template.json
354 api_get_policies 200 ricsim_g1_1 "service10" 1 5000 ricsim_g1_1 "service10" 1 testdata/OSC/pi1_template.json
357 deviation "TR10 - agent allows policy creation on unregistered service (side effect of orig. problem)- test combo $interface and $__httpx"
359 #api_delete_policy 404 2000
360 #Allow policy create with unregistered service for now
361 api_delete_policy 204 2000
363 api_delete_policy 404 1500
365 api_delete_policy 204 5000
367 api_equal json:policies 1
369 api_equal json:policy_ids 1
371 api_delete_policy 204 5100
373 api_equal json:policies 0
375 api_equal json:policy_ids 0
377 cr_equal received_callbacks 0
379 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
380 mr_greater requests_submitted 0
381 VAL=$(mr_read requests_submitted)
382 mr_equal requests_fetched $VAL
383 mr_equal responses_submitted $VAL
384 mr_equal responses_fetched $VAL
385 mr_equal current_requests 0
386 mr_equal current_responses 0
388 mr_equal requests_submitted 0
391 if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
392 sim_contains_str ricsim_g1_1 remote_hosts "a1-controller"
393 sim_contains_str ricsim_g2_1 remote_hosts "a1-controller"
395 sim_contains_str ricsim_g1_1 remote_hosts "policy-agent"
396 sim_contains_str ricsim_g2_1 remote_hosts "policy-agent"
399 check_policy_agent_logs
400 check_control_panel_logs
402 store_logs "${__httpx}__${interface}"
408 #### TEST COMPLETE ####
413 auto_clean_containers