blob: 5347f8f0b97abafa704cea0b45c1aeeaca3d8af3 [file] [log] [blame]
BjornMagnussonXA70e878f2020-05-11 14:11:30 +02001#!/bin/bash
2
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
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
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=================================================
18#
19
20
21TC_ONELINE_DESCR="Sanity test, create service and then create,update and delete a policy using http/https and Agent REST/DMAAP with/without SDNC controller"
22
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010023#App names to include in the test when running docker, space separated list
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010024DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR DMAAPMR PA RICSIM SDNC NGW"
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020025
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010026#App names to include in the test when running kubernetes, space separated list
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010027KUBE_INCLUDED_IMAGES="CP CR MR PA RICSIM SDNC KUBEPROXY NGW"
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010028#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list
29KUBE_PRESTARTED_IMAGES=""
30
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010031#Ignore image in DOCKER_INCLUDED_IMAGES, KUBE_INCLUDED_IMAGES if
32#the image is not configured in the supplied env_file
33#Used for images not applicable to all supported profile
34CONDITIONALLY_IGNORED_IMAGES="NGW"
35
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010036#Supported test environment profiles
BjornMagnussonXA674793d2021-05-06 19:49:17 +020037SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ONAP-ISTANBUL ORAN-CHERRY ORAN-D-RELEASE"
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010038#Supported run modes
39SUPPORTED_RUNMODES="DOCKER KUBE"
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010040
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020041. ../common/testcase_common.sh $@
42. ../common/agent_api_functions.sh
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010043. ../common/consul_cbs_functions.sh
44. ../common/control_panel_api_functions.sh
45. ../common/controller_api_functions.sh
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010046. ../common/cr_api_functions.sh
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010047. ../common/mr_api_functions.sh
48. ../common/ricsimulator_api_functions.sh
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010049. ../common/http_proxy_api_functions.sh
50. ../common/kube_proxy_api_functions.sh
51. ../common/gateway_api_functions.sh
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010052
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010053setup_testenvironment
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020054
55#### TEST BEGIN ####
56
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010057generate_policy_uuid
BjornMagnussonXAad047782020-06-08 15:54:11 +020058
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020059# Tested variants of REST/DMAAP/SDNC config
60TESTED_VARIANTS="REST DMAAP REST+SDNC DMAAP+SDNC"
61#Test agent and simulator protocol versions (others are http only)
62TESTED_PROTOCOLS="HTTP HTTPS"
63for __httpx in $TESTED_PROTOCOLS ; do
64 for interface in $TESTED_VARIANTS ; do
65
66 echo "#####################################################################"
67 echo "#####################################################################"
68 echo "### Testing agent: $interface using $__httpx"
69 echo "#####################################################################"
70 echo "#####################################################################"
71
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010072 clean_environment
BjornMagnussonXA496156d2020-08-10 14:16:24 +020073
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010074 if [ $RUNMODE == "KUBE" ]; then
75 start_kube_proxy
76 fi
77
BjornMagnussonXA496156d2020-08-10 14:16:24 +020078 if [ $__httpx == "HTTPS" ]; then
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010079 use_agent_rest_https
80 else
81 use_agent_rest_http
82 fi
83
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010084 start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/$POLICY_AGENT_CONFIG_FILE
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010085
86 set_agent_trace
87
88 # Create service to be able to receive events when rics becomes available
89 # Must use rest towards the agent since dmaap is not configured yet
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010090 api_put_service 201 "ric-registration" 0 "$CR_SERVICE_PATH/ric-registration"
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010091
92 if [ $__httpx == "HTTPS" ]; then
BjornMagnussonXA496156d2020-08-10 14:16:24 +020093 use_cr_https
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +020094 use_simulator_https
95 use_mr_https
96 if [[ $interface = *"SDNC"* ]]; then
97 use_sdnc_https
98 fi
99 if [[ $interface = *"DMAAP"* ]]; then
100 use_agent_dmaap_https
101 else
102 use_agent_rest_https
103 fi
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200104 else
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200105 use_cr_http
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +0200106 use_simulator_http
107 use_mr_http
108 if [[ $interface = *"SDNC"* ]]; then
109 use_sdnc_http
110 fi
111 if [[ $interface = *"DMAAP"* ]]; then
112 use_agent_dmaap_http
113 else
114 use_agent_rest_http
115 fi
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200116 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200117
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200118 start_ric_simulators ricsim_g1 1 OSC_2.1.0
119 start_ric_simulators ricsim_g2 1 STD_1.1.3
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100120 if [ "$PMS_VERSION" == "V2" ]; then
121 start_ric_simulators ricsim_g3 1 STD_2.0.0
122 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200123
124 start_mr
125
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200126 start_cr
127
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +0100128 start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
129
130 if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
131 start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
132 fi
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100133
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100134 if [ $RUNMODE == "DOCKER" ]; then
135 start_consul_cbs
136 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200137
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +0200138 if [[ $interface = *"SDNC"* ]]; then
139 start_sdnc
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200140 prepare_consul_config SDNC ".consul_config.json"
141 else
142 prepare_consul_config NOSDNC ".consul_config.json"
143 fi
144
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100145 if [ $RUNMODE == "KUBE" ]; then
146 agent_load_config ".consul_config.json"
147 else
148 consul_config_app ".consul_config.json"
149 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200150
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200151 mr_equal requests_submitted 0
152
153 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
154
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100155 if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100156
157 sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
158
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100159 api_equal json:rics 3 300
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200160
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100161 api_equal json:policy-types 3 120
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200162
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100163 api_equal json:policies 0
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200164
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100165 api_equal json:policy-instances 0
166
167 cr_equal received_callbacks 3 120
168
169 cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1
170
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100171 else
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100172 api_equal json:rics 2 300
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100173
174 api_equal json:policy_schemas 2 120
175
176 api_equal json:policy_types 2
177
178 api_equal json:policies 0
179
180 api_equal json:policy_ids 0
181 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200182
183 echo "############################################"
184 echo "############## Health check ################"
185 echo "############################################"
186
187 api_get_status 200
188
189 echo "############################################"
190 echo "##### Service registry and supervision #####"
191 echo "############################################"
192
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100193 api_put_service 201 "serv1" 1000 "$CR_SERVICE_PATH/1"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200194
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100195 api_get_service_ids 200 "serv1" "ric-registration"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200196
197 api_put_services_keepalive 200 "serv1"
198
199 echo "############################################"
200 echo "############## RIC Repository ##############"
201 echo "############################################"
202
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100203 if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100204 api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1: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:AVAILABLE"
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100205 else
206 api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:AVAILABLE ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
207 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200208
209 echo "############################################"
210 echo "########### A1 Policy Management ###########"
211 echo "############################################"
212
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100213 if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100214 notificationurl=$CR_SERVICE_PATH"/test"
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100215 else
216 notificationurl=""
217 fi
218 api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
219 api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100220 if [ "$PMS_VERSION" == "V2" ]; then
221 api_put_policy 201 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json
222 api_put_policy 200 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json
223 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200224
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100225 api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
226 api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200227
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100228 if [ "$PMS_VERSION" == "V2" ]; then
229 api_equal json:policies 3
230 else
231 api_equal json:policies 2
232 fi
233
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200234 api_delete_policy 204 5000
235
236 api_delete_policy 204 5100
237
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100238 if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100239 api_delete_policy 204 5200
240 fi
241
242 if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100243 api_equal json:policies 0
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200244
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100245 api_equal json:policy-instances 0
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100246 else
247 api_equal json:policies 0
248
249 api_equal json:policy_ids 0
250 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200251
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100252 if [ "$PMS_VERSION" == "V2" ]; then
253 cr_equal received_callbacks 3
254 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200255
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +0200256 if [[ $interface = *"DMAAP"* ]]; then
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100257
258 if [ "$PMS_VERSION" == "V2" ]; then
259 VAL=14 # Number of Agent API calls over DMAAP
260 else
261 VAL=11 # Number of Agent API calls over DMAAP
262 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200263 mr_equal requests_fetched $VAL
264 mr_equal responses_submitted $VAL
265 mr_equal responses_fetched $VAL
266 mr_equal current_requests 0
267 mr_equal current_responses 0
268 else
269 mr_equal requests_submitted 0
270 fi
271
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +0200272 if [[ $interface = *"SDNC"* ]]; then
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100273 sim_contains_str ricsim_g1_1 remote_hosts $SDNC_APP_NAME
274 sim_contains_str ricsim_g2_1 remote_hosts $SDNC_APP_NAME
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100275 if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100276 sim_contains_str ricsim_g3_1 remote_hosts $SDNC_APP_NAME
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100277 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200278 else
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100279 sim_contains_str ricsim_g1_1 remote_hosts $POLICY_AGENT_APP_NAME
280 sim_contains_str ricsim_g2_1 remote_hosts $POLICY_AGENT_APP_NAME
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100281 if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100282 sim_contains_str ricsim_g3_1 remote_hosts $POLICY_AGENT_APP_NAME
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100283 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200284 fi
285
286 check_policy_agent_logs
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +0100287
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200288
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100289 if [[ $interface = *"SDNC"* ]]; then
290 check_sdnc_logs
291 fi
292
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200293 store_logs "${__httpx}__${interface}"
294
295 done
296
297done
298
299#### TEST COMPLETE ####
300
301
302print_result
303
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100304auto_clean_environment