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"
40 for interface in $TESTED_VARIANTS ; do
42 echo "#####################################################################"
43 echo "#####################################################################"
44 echo "### Testing agent: "$interface
45 echo "#####################################################################"
46 echo "#####################################################################"
49 # Clean container and start all needed containers #
52 start_ric_simulators ricsim_g1 1 OSC_2.1.0
53 start_ric_simulators ricsim_g2 1 STD_1.1.3
61 if [ $interface == "SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
62 prepare_consul_config SDNC ".consul_config.json"
64 prepare_consul_config NOSDNC ".consul_config.json"
67 consul_config_app ".consul_config.json"
71 if [ $interface == "SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
77 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
84 cr_equal received_callbacks 0
85 mr_equal requests_submitted 0
87 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
88 sim_put_policy_type 201 ricsim_g1_1 2 testdata/OSC/sim_2.json
90 api_equal json:rics 2 60
92 api_equal json:policy_schemas 3 120
94 api_equal json:policy_types 3
96 api_equal json:policies 0
98 api_equal json:policy_ids 0
103 echo "############################################"
104 echo "############## Health check ################"
105 echo "############################################"
109 echo "############################################"
110 echo "##### Service registry and supervision #####"
111 echo "############################################"
113 api_get_services 404 "rapp1"
115 api_put_service 201 "rapp1" 1000 "$CR_PATH/1"
117 api_put_service 200 "rapp1" 2000 "$CR_PATH/1"
120 api_put_service 400 "rapp2" -1 "$CR_PATH/2"
122 api_put_service 400 "rapp2" "wrong" "$CR_PATH/2"
124 api_put_service 400 "rapp2" 100 "/test"
126 api_put_service 400 "rapp2" 100 "test-path"
128 api_put_service 201 "rapp2" 300 "ftp://localhost:80/test"
130 api_get_services 200 "rapp1" "rapp1" 2000 "$CR_PATH/1"
132 api_get_service_ids 200 "rapp1" "rapp2"
135 api_put_service 201 "rapp3" 5000 "$CR_PATH/3"
138 api_get_service_ids 200 "rapp1" "rapp2" "rapp3"
141 api_get_services 200 "rapp1" "rapp1" 2000 "$CR_PATH/1"
143 api_get_services 200 NOSERVICE "rapp1" 2000 "$CR_PATH/1" "rapp2" 300 "ftp://localhost:80/test" "rapp3" 5000 "$CR_PATH/3"
147 echo -e $YELLOW"TR2"$EYELLOW
148 api_put_services_keepalive 201 "rapp1"
149 echo -e $YELLOW"TR2"$EYELLOW
150 api_put_services_keepalive 201 "rapp3"
152 api_put_services_keepalive 200 "rapp1"
154 api_put_services_keepalive 200 "rapp3"
156 api_put_services_keepalive 404 "rapp5"
158 api_get_service_ids 200 "rapp1" "rapp2" "rapp3"
160 api_delete_services 204 "rapp1"
162 api_get_service_ids 200 "rapp2" "rapp3"
165 api_put_service 201 "rapp1" 50 "$CR_PATH/1"
167 api_get_service_ids 200 "rapp1" "rapp2" "rapp3"
170 api_delete_services 204 "rapp1"
171 api_delete_services 204 "rapp3"
173 api_equal json:services 1
175 api_delete_services 204 "rapp2"
177 api_equal json:services 0
180 echo "############################################"
181 echo "############## RIC Repository ##############"
182 echo "############################################"
184 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"
186 api_get_rics 200 1 "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1,2:AVAILABLE"
190 api_get_rics 404 "test"
193 api_get_ric 200 me1_ricsim_g1_1 ricsim_g1_1
195 api_get_ric 200 me2_ricsim_g1_1 ricsim_g1_1
197 api_get_ric 200 me1_ricsim_g2_1 ricsim_g2_1
199 api_get_ric 200 me2_ricsim_g2_1 ricsim_g2_1
204 echo "############################################"
205 echo "########### A1 Policy Management ###########"
206 echo "############################################"
207 echo -e $YELLOW"TR9"$EYELLOW
208 api_get_policy_schema 200 1 testdata/OSC/1.json
209 echo -e $YELLOW"TR9"$EYELLOW
210 api_get_policy_schema 200 2 testdata/OSC/2.json
212 api_get_policy_schema 404 3
213 echo -e $YELLOW"TR9"$EYELLOW
214 api_get_policy_schemas 200 NORIC testdata/OSC/1.json testdata/OSC/2.json NOFILE
215 echo -e $YELLOW"TR9"$EYELLOW
216 api_get_policy_schemas 200 ricsim_g1_1 testdata/OSC/1.json testdata/OSC/2.json
218 api_get_policy_schemas 200 ricsim_g2_1 NOFILE
220 api_get_policy_schemas 404 test
224 api_get_policy_types 200 NORIC 1 2 EMPTY
226 api_get_policy_types 200 ricsim_g1_1 1 2
228 api_get_policy_types 200 ricsim_g2_1 EMPTY
230 api_get_policy_types 404 dummy-ric
234 api_put_service 201 "rapp10" 3600 "$CR_PATH/1"
235 echo -e $YELLOW"TR10"$EYELLOW
236 api_put_policy 400 "unregistered-r-app" ricsim_g1_1 1 2000 testdata/OSC/pi1_template.json
238 api_put_policy 201 "rapp10" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json
239 api_put_policy 200 "rapp10" ricsim_g1_1 1 5000 testdata/OSC/pi1_template.json
241 api_put_policy 201 "rapp10" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json
242 api_put_policy 200 "rapp10" ricsim_g2_1 NOTYPE 5100 testdata/STD/pi1_template.json
245 api_get_policy_status 200 5000 OSC "$VAL" "false"
246 api_get_policy_status 200 5100 STD "UNDEFINED"
249 echo -e $YELLOW"TR10"$EYELLOW
250 api_equal json:policies 2
251 echo -e $YELLOW"TR10"$EYELLOW
252 api_equal json:policy_ids 2
253 echo -e $YELLOW"TR10"$EYELLOW
254 api_get_policy_ids 200 NORIC NOSERVICE NOTYPE 5000 5100
255 echo -e $YELLOW"TR10"$EYELLOW
256 api_get_policy_ids 200 ricsim_g1_1 NOSERVICE NOTYPE 5000
258 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE NOTYPE 5100
261 api_get_policy_ids 200 NORIC "rapp10" NOTYPE 5000 5100
262 echo -e $YELLOW"TR10"$EYELLOW
263 api_get_policy_ids 200 NORIC NOSERVICE 1 5000
265 api_get_policy_ids 200 NORIC NOSERVICE 2 NOID
267 api_get_policy_ids 200 ricsim_g2_1 NOSERVICE 1 NOID
270 api_get_policy 200 5000 testdata/OSC/pi1_template.json
272 api_get_policy 200 5100 testdata/STD/pi1_template.json
276 api_get_policies 200 ricsim_g1_1 "rapp10" 1 5000 ricsim_g1_1 "rapp10" 1 testdata/OSC/pi1_template.json
281 echo -e $YELLOW"TR10"$EYELLOW
282 api_delete_policy 404 2000
284 api_delete_policy 404 1500
286 api_delete_policy 204 5000
288 api_equal json:policies 1
290 api_equal json:policy_ids 1
292 api_delete_policy 204 5100
294 api_equal json:policies 0
296 api_equal json:policy_ids 0
298 cr_equal received_callbacks 0
300 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
301 mr_greater requests_submitted 0
302 VAL=$(mr_read requests_submitted)
303 mr_equal requests_fetched $VAL
304 mr_equal responses_submitted $VAL
305 mr_equal responses_fetched $VAL
306 mr_equal current_requests 0
307 mr_equal current_responses 0
309 mr_equal requests_submitted 0
312 check_policy_agent_logs
313 check_control_panel_logs
315 store_logs $interface
319 #### TEST COMPLETE ####
324 auto_clean_containers