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 . ../common/testcase_common.sh $@
24 . ../common/agent_api_functions.sh
25 . ../common/ricsimulator_api_functions.sh
26 . ../common/controller_api_functions.sh
30 #Local vars in test script
31 ##########################
33 # Path to callback receiver
34 CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
36 # Tested variants of REST/DMAAP/SDNC config
37 TESTED_VARIANTS="REST DMAAP REST+SDNC DMAAP+SDNC"
39 #Test agent and simulator protocol versions (others are http only)
40 TESTED_PROTOCOLS="HTTP HTTPS"
42 for __httpx in $TESTED_PROTOCOLS ; do
43 for interface in $TESTED_VARIANTS ; do
45 echo "#####################################################################"
46 echo "#####################################################################"
47 echo "### Testing agent: "$interface
48 echo "#####################################################################"
49 echo "#####################################################################"
52 # Clean container and start all needed containers #
55 if [ $__httpx == "HTTPS" ]; then
56 echo "Using secure ports towards simulators"
59 echo "Using non-secure ports towards simulators"
63 start_ric_simulators ricsim_g1 1 OSC_2.1.0
64 start_ric_simulators ricsim_g2 1 STD_1.1.3
72 if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
73 prepare_consul_config SDNC ".consul_config.json"
75 prepare_consul_config NOSDNC ".consul_config.json"
78 consul_config_app ".consul_config.json"
82 if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
88 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
91 if [ $__httpx == "HTTPS" ]; then
92 echo "Using secure ports towards the agent"
95 echo "Using non-secure ports towards the agent"
101 cr_equal received_callbacks 0
102 mr_equal requests_submitted 0
104 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
105 sim_put_policy_type 201 ricsim_g1_1 2 testdata/OSC/sim_2.json
107 api_equal json:rics 2 60
109 api_equal json:policy_schemas 3 120
111 api_equal json:policy_types 3
113 api_equal json:policies 0
115 api_equal json:policy_ids 0
120 echo "############################################"
121 echo "############## Health check ################"
122 echo "############################################"
126 echo "############################################"
127 echo "##### Service registry and supervision #####"
128 echo "############################################"
130 api_get_services 404 "rapp1"
132 api_put_service 201 "rapp1" 1000 "$CR_PATH/1"
134 api_put_service 200 "rapp1" 2000 "$CR_PATH/1"
137 api_put_service 400 "rapp2" -1 "$CR_PATH/2"
139 api_put_service 400 "rapp2" "wrong" "$CR_PATH/2"
141 api_put_service 400 "rapp2" 100 "/test"
143 api_put_service 400 "rapp2" 100 "test-path"
145 api_put_service 201 "rapp2" 300 "ftp://localhost:80/test"
147 api_get_services 200 "rapp1" "rapp1" 2000 "$CR_PATH/1"
149 api_get_service_ids 200 "rapp1" "rapp2"
152 api_put_service 201 "rapp3" 5000 "$CR_PATH/3"
155 api_get_service_ids 200 "rapp1" "rapp2" "rapp3"
158 api_get_services 200 "rapp1" "rapp1" 2000 "$CR_PATH/1"
160 api_get_services 200 NOSERVICE "rapp1" 2000 "$CR_PATH/1" "rapp2" 300 "ftp://localhost:80/test" "rapp3" 5000 "$CR_PATH/3"
164 echo -e $YELLOW"TR2"$EYELLOW
165 api_put_services_keepalive 201 "rapp1"
166 echo -e $YELLOW"TR2"$EYELLOW
167 api_put_services_keepalive 201 "rapp3"
169 api_put_services_keepalive 200 "rapp1"
171 api_put_services_keepalive 200 "rapp3"
173 api_put_services_keepalive 404 "rapp5"
175 api_get_service_ids 200 "rapp1" "rapp2" "rapp3"
177 api_delete_services 204 "rapp1"
179 api_get_service_ids 200 "rapp2" "rapp3"
182 api_put_service 201 "rapp1" 50 "$CR_PATH/1"
184 api_get_service_ids 200 "rapp1" "rapp2" "rapp3"
187 api_delete_services 204 "rapp1"
188 api_delete_services 204 "rapp3"
190 api_equal json:services 1
192 api_delete_services 204 "rapp2"
194 api_equal json:services 0
197 echo "############################################"
198 echo "############## RIC Repository ##############"
199 echo "############################################"
201 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"
203 api_get_rics 200 1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
207 api_get_rics 404 "test"
210 api_get_ric 200 me1_ricsim_g1_1 ricsim_g1_1
212 api_get_ric 200 me2_ricsim_g1_1 ricsim_g1_1
214 api_get_ric 200 me1_ricsim_g2_1 ricsim_g2_1
216 api_get_ric 200 me2_ricsim_g2_1 ricsim_g2_1
221 echo "############################################"
222 echo "########### A1 Policy Management ###########"
223 echo "############################################"
224 echo -e $YELLOW"TR9"$EYELLOW
225 api_get_policy_schema 200 1 testdata/OSC/1-agent-modified.json
226 echo -e $YELLOW"TR9"$EYELLOW
227 api_get_policy_schema 200 2 testdata/OSC/2-agent-modified.json
229 api_get_policy_schema 404 3
230 echo -e $YELLOW"TR9"$EYELLOW
231 api_get_policy_schemas 200 NORIC testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json NOFILE
232 echo -e $YELLOW"TR9"$EYELLOW
233 api_get_policy_schemas 200 ricsim_g1_1 testdata/OSC/1-agent-modified.json testdata/OSC/2-agent-modified.json
235 api_get_policy_schemas 200 ricsim_g2_1 NOFILE
237 api_get_policy_schemas 404 test
241 api_get_policy_types 200 NORIC 1 2 EMPTY
243 api_get_policy_types 200 ricsim_g1_1 1 2
245 api_get_policy_types 200 ricsim_g2_1 EMPTY
247 api_get_policy_types 404 dummy-ric
251 api_put_service 201 "rapp10" 3600 "$CR_PATH/1"
252 echo -e $YELLOW"TR10"$EYELLOW
253 api_put_policy 400 "unregistered-r-app" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json
255 api_put_policy 201 "rapp10" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json
256 api_put_policy 200 "rapp10" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json
258 api_put_policy 201 "rapp10" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json
259 api_put_policy 200 "rapp10" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json
262 api_get_policy_status 200 5000 OSC "$VAL" "false"
263 api_get_policy_status 200 5100 STD "UNDEFINED"
266 echo -e $YELLOW"TR10"$EYELLOW
267 api_equal json:policies 2
268 echo -e $YELLOW"TR10"$EYELLOW
269 api_equal json:policy_ids 2
270 echo -e $YELLOW"TR10"$EYELLOW
271 api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100
272 echo -e $YELLOW"TR10"$EYELLOW
273 api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000
275 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100
278 api_get_policy_ids 200 NORIC "rapp10" NOTYPE 5000 5100
279 echo -e $YELLOW"TR10"$EYELLOW
280 api_get_policy_ids 200 NORIC NOSERVICE 1 5000
282 api_get_policy_ids 200 NORIC NOSERVICE 2 NOID
284 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE 1 NOID
287 api_get_policy 200 5000 testdata/OSC/pi1_template.json
289 api_get_policy 200 5100 testdata/STD/pi1_template.json
293 api_get_policies 200 ricsim_g1_1 "rapp10" 1 5000 ricsim_g1_1 "rapp10" 1 testdata/OSC/pi1_template.json
298 echo -e $YELLOW"TR10"$EYELLOW
299 api_delete_policy 404 2000
301 api_delete_policy 404 1500
303 api_delete_policy 204 5000
305 api_equal json:policies 1
307 api_equal json:policy_ids 1
309 api_delete_policy 204 5100
311 api_equal json:policies 0
313 api_equal json:policy_ids 0
315 cr_equal received_callbacks 0
317 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
318 mr_greater requests_submitted 0
319 VAL=$(mr_read requests_submitted)
320 mr_equal requests_fetched $VAL
321 mr_equal responses_submitted $VAL
322 mr_equal responses_fetched $VAL
323 mr_equal current_requests 0
324 mr_equal current_responses 0
326 mr_equal requests_submitted 0
329 check_policy_agent_logs
330 check_control_panel_logs
332 store_logs $interface
338 #### TEST COMPLETE ####
343 auto_clean_containers