blob: e4ffe75b7dccf55d2661059f6023203065b6bcc0 [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
BjornMagnussonXA663566c2021-11-08 10:25:07 +010024DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR DMAAPMR PA RICSIM SDNC NGW KUBEPROXY"
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
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +010027KUBE_INCLUDED_IMAGES="CP CR MR DMAAPMR PA RICSIM SDNC NGW KUBEPROXY "
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
BjornMagnussonXAfec823b2021-08-03 14:14:05 +020037SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ONAP-ISTANBUL ORAN-CHERRY ORAN-D-RELEASE ORAN-E-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
BjornMagnussonXA663566c2021-11-08 10:25:07 +010074 start_kube_proxy
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010075
BjornMagnussonXA496156d2020-08-10 14:16:24 +020076 if [ $__httpx == "HTTPS" ]; then
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010077 use_agent_rest_https
78 else
79 use_agent_rest_http
80 fi
81
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010082 start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/$POLICY_AGENT_CONFIG_FILE
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010083
84 set_agent_trace
85
86 # Create service to be able to receive events when rics becomes available
87 # Must use rest towards the agent since dmaap is not configured yet
BjornMagnussonXA663566c2021-11-08 10:25:07 +010088 api_put_service 201 "ric-registration" 0 "$CR_SERVICE_APP_PATH/ric-registration"
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010089
90 if [ $__httpx == "HTTPS" ]; then
BjornMagnussonXA496156d2020-08-10 14:16:24 +020091 use_cr_https
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +020092 use_simulator_https
93 use_mr_https
94 if [[ $interface = *"SDNC"* ]]; then
95 use_sdnc_https
96 fi
97 if [[ $interface = *"DMAAP"* ]]; then
98 use_agent_dmaap_https
99 else
100 use_agent_rest_https
101 fi
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200102 else
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200103 use_cr_http
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +0200104 use_simulator_http
105 use_mr_http
106 if [[ $interface = *"SDNC"* ]]; then
107 use_sdnc_http
108 fi
109 if [[ $interface = *"DMAAP"* ]]; then
110 use_agent_dmaap_http
111 else
112 use_agent_rest_http
113 fi
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200114 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200115
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200116 start_ric_simulators ricsim_g1 1 OSC_2.1.0
117 start_ric_simulators ricsim_g2 1 STD_1.1.3
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100118 if [ "$PMS_VERSION" == "V2" ]; then
119 start_ric_simulators ricsim_g3 1 STD_2.0.0
120 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200121
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +0100122 start_mr "$MR_READ_TOPIC" "/events" "users/policy-agent" \
123 "$MR_WRITE_TOPIC" "/events" "users/mr-stub"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200124
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200125 start_cr
126
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +0100127 start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
128
129 if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
130 start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
131 fi
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100132
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100133 if [ $RUNMODE == "DOCKER" ]; then
134 start_consul_cbs
135 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200136
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +0200137 if [[ $interface = *"SDNC"* ]]; then
138 start_sdnc
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200139 prepare_consul_config SDNC ".consul_config.json"
140 else
141 prepare_consul_config NOSDNC ".consul_config.json"
142 fi
143
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100144 if [ $RUNMODE == "KUBE" ]; then
145 agent_load_config ".consul_config.json"
146 else
147 consul_config_app ".consul_config.json"
148 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200149
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200150 mr_equal requests_submitted 0
151
152 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
153
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100154 if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100155
156 sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
157
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100158 api_equal json:rics 3 300
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200159
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100160 api_equal json:policy-types 3 120
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200161
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100162 api_equal json:policies 0
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200163
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100164 api_equal json:policy-instances 0
165
166 cr_equal received_callbacks 3 120
167
168 cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1
169
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100170 else
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100171 api_equal json:rics 2 300
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100172
173 api_equal json:policy_schemas 2 120
174
175 api_equal json:policy_types 2
176
177 api_equal json:policies 0
178
179 api_equal json:policy_ids 0
180 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200181
182 echo "############################################"
183 echo "############## Health check ################"
184 echo "############################################"
185
186 api_get_status 200
187
188 echo "############################################"
189 echo "##### Service registry and supervision #####"
190 echo "############################################"
191
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100192 api_put_service 201 "serv1" 1000 "$CR_SERVICE_APP_PATH/1"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200193
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100194 api_get_service_ids 200 "serv1" "ric-registration"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200195
196 api_put_services_keepalive 200 "serv1"
197
198 echo "############################################"
199 echo "############## RIC Repository ##############"
200 echo "############################################"
201
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100202 if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100203 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 +0100204 else
205 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"
206 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200207
208 echo "############################################"
209 echo "########### A1 Policy Management ###########"
210 echo "############################################"
211
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100212 if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100213 notificationurl=$CR_SERVICE_APP_PATH"/test"
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100214 else
215 notificationurl=""
216 fi
217 api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
218 api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100219 if [ "$PMS_VERSION" == "V2" ]; then
220 api_put_policy 201 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json
221 api_put_policy 200 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json
222 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200223
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100224 api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
225 api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200226
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100227 if [ "$PMS_VERSION" == "V2" ]; then
228 api_equal json:policies 3
229 else
230 api_equal json:policies 2
231 fi
232
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200233 api_delete_policy 204 5000
234
235 api_delete_policy 204 5100
236
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100237 if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100238 api_delete_policy 204 5200
239 fi
240
241 if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100242 api_equal json:policies 0
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200243
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100244 api_equal json:policy-instances 0
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100245 else
246 api_equal json:policies 0
247
248 api_equal json:policy_ids 0
249 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200250
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100251 if [ "$PMS_VERSION" == "V2" ]; then
252 cr_equal received_callbacks 3
253 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200254
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +0200255 if [[ $interface = *"DMAAP"* ]]; then
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100256
257 if [ "$PMS_VERSION" == "V2" ]; then
258 VAL=14 # Number of Agent API calls over DMAAP
259 else
260 VAL=11 # Number of Agent API calls over DMAAP
261 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200262 mr_equal requests_fetched $VAL
263 mr_equal responses_submitted $VAL
264 mr_equal responses_fetched $VAL
265 mr_equal current_requests 0
266 mr_equal current_responses 0
267 else
268 mr_equal requests_submitted 0
269 fi
270
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +0200271 if [[ $interface = *"SDNC"* ]]; then
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100272 sim_contains_str ricsim_g1_1 remote_hosts $SDNC_APP_NAME
273 sim_contains_str ricsim_g2_1 remote_hosts $SDNC_APP_NAME
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100274 if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100275 sim_contains_str ricsim_g3_1 remote_hosts $SDNC_APP_NAME
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100276 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200277 else
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100278 sim_contains_str ricsim_g1_1 remote_hosts $POLICY_AGENT_APP_NAME
279 sim_contains_str ricsim_g2_1 remote_hosts $POLICY_AGENT_APP_NAME
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100280 if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100281 sim_contains_str ricsim_g3_1 remote_hosts $POLICY_AGENT_APP_NAME
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100282 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200283 fi
284
285 check_policy_agent_logs
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +0100286
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200287
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100288 if [[ $interface = *"SDNC"* ]]; then
289 check_sdnc_logs
290 fi
291
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200292 store_logs "${__httpx}__${interface}"
293
294 done
295
296done
297
298#### TEST COMPLETE ####
299
300
301print_result
302
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100303auto_clean_environment