blob: 625346b73a6b6b620bd3c5eaf0712f80966f829d [file] [log] [blame]
BjornMagnussonXA70e878f2020-05-11 14:11:30 +02001#!/bin/bash
BjornMagnussonXA80a92002020-03-19 14:31:06 +01002
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
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020020TC_ONELINE_DESCR="Basic use case, register service, create/update policy, delete policy, de-register service using both STD and OSC interface while mixing REST and Dmaap"
BjornMagnussonXA80a92002020-03-19 14:31:06 +010021
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010022#App names to include in the test when running docker, space separated list
BjornMagnussonXA663566c2021-11-08 10:25:07 +010023DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM NGW KUBEPROXY"
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020024
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010025#App names to include in the test when running kubernetes, space separated list
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010026KUBE_INCLUDED_IMAGES=" MR CR PA RICSIM CP KUBEPROXY NGW"
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010027#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list
28KUBE_PRESTARTED_IMAGES=""
29
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010030#Ignore image in DOCKER_INCLUDED_IMAGES, KUBE_INCLUDED_IMAGES if
31#the image is not configured in the supplied env_file
32#Used for images not applicable to all supported profile
33CONDITIONALLY_IGNORED_IMAGES="NGW"
34
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010035#Supported test environment profiles
BjornMagnussonXAfec823b2021-08-03 14:14:05 +020036SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ONAP-ISTANBUL ORAN-CHERRY ORAN-D-RELEASE ORAN-E-RELEASE"
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010037#Supported run modes
38SUPPORTED_RUNMODES="DOCKER KUBE"
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010039
BjornMagnussonXA80a92002020-03-19 14:31:06 +010040. ../common/testcase_common.sh $@
41. ../common/agent_api_functions.sh
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010042. ../common/consul_cbs_functions.sh
43. ../common/control_panel_api_functions.sh
44. ../common/controller_api_functions.sh
45. ../common/cr_api_functions.sh
46. ../common/mr_api_functions.sh
BjornMagnussonXA72667f12020-04-24 09:20:18 +020047. ../common/ricsimulator_api_functions.sh
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010048. ../common/kube_proxy_api_functions.sh
49. ../common/gateway_api_functions.sh
50
51setup_testenvironment
BjornMagnussonXA80a92002020-03-19 14:31:06 +010052
53#### TEST BEGIN ####
54
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010055generate_policy_uuid
BjornMagnussonXAad047782020-06-08 15:54:11 +020056
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +020057use_simulator_http
58use_mr_http
59use_agent_rest_http
60
BjornMagnussonXA80a92002020-03-19 14:31:06 +010061
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010062clean_environment
BjornMagnussonXA80a92002020-03-19 14:31:06 +010063
BjornMagnussonXA663566c2021-11-08 10:25:07 +010064start_kube_proxy
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010065
BjornMagnussonXA80a92002020-03-19 14:31:06 +010066start_ric_simulators ricsim_g1 3 OSC_2.1.0
67
68start_ric_simulators ricsim_g2 5 STD_1.1.3
69
BjornMagnussonXA4207b832020-11-03 09:52:49 +010070if [ "$PMS_VERSION" == "V2" ]; then
71 start_ric_simulators ricsim_g3 1 STD_2.0.0
72fi
73
BjornMagnussonXA80a92002020-03-19 14:31:06 +010074start_mr
75
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010076start_cr
BjornMagnussonXA80a92002020-03-19 14:31:06 +010077
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010078if [ $RUNMODE == "DOCKER" ]; then
79 start_consul_cbs
80fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +010081
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010082start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
BjornMagnussonXA80a92002020-03-19 14:31:06 +010083
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010084if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
85 start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
86fi
87
88start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/$POLICY_AGENT_CONFIG_FILE
BjornMagnussonXA80a92002020-03-19 14:31:06 +010089
BjornMagnussonXA72667f12020-04-24 09:20:18 +020090set_agent_debug
91
92use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010093
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010094prepare_consul_config NOSDNC ".consul_config.json"
95
96if [ $RUNMODE == "KUBE" ]; then
97 agent_load_config ".consul_config.json"
98else
99 consul_config_app ".consul_config.json"
100fi
101
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100102api_get_status 200
103
104sim_print ricsim_g1_1 interface
105
106sim_print ricsim_g2_1 interface
107
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100108if [ "$PMS_VERSION" == "V2" ]; then
109 sim_print ricsim_g3_1 interface
110fi
111
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100112sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
113
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100114if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100115 sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100116 api_equal json:policy-types 3 300
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100117else
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100118 api_equal json:policy_types 2 300
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100119fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100120
121# Create policies
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100122
123if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100124 notificationurl=$CR_SERVICE_APP_PATH"/test"
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100125else
126 notificationurl=""
127fi
128
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200129use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100130
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100131api_put_service 201 "service1" 3600 "$CR_SERVICE_APP_PATH/1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100132
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100133api_put_policy 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100134
135sim_equal ricsim_g1_1 num_instances 1
136
137
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200138use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100139
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100140api_put_policy 201 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100141
142sim_equal ricsim_g1_1 num_instances 2
143
144
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200145use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100146
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100147api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100148
149sim_equal ricsim_g2_1 num_instances 1
150
151
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200152use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100153
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100154api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100155
156sim_equal ricsim_g2_1 num_instances 2
157
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100158if [ "$PMS_VERSION" == "V2" ]; then
159 use_agent_rest_http
160
161 api_put_policy 201 "service1" ricsim_g3_1 STD_QOS_0_2_0 2200 true $notificationurl testdata/STD2/pi_qos_template.json 1
162
163 sim_equal ricsim_g3_1 num_instances 1
164
165 use_agent_dmaap_http
166
167 api_put_policy 201 "service1" ricsim_g3_1 STD_QOS_0_2_0 3200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos_template.json 1
168
169 sim_equal ricsim_g3_1 num_instances 2
170
171fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100172
173#Update policies
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200174use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100175
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100176api_put_service 200 "service1" 3600 "$CR_SERVICE_APP_PATH/1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100177
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100178api_put_policy 200 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100179
180sim_equal ricsim_g1_1 num_instances 2
181
182
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200183use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100184
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100185api_put_policy 200 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100186
187sim_equal ricsim_g1_1 num_instances 2
188
189
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200190use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100191
192
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100193api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100194
195sim_equal ricsim_g2_1 num_instances 2
196
197
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200198use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100199
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100200api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100201
202sim_equal ricsim_g2_1 num_instances 2
203
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100204if [ "$PMS_VERSION" == "V2" ]; then
205 use_agent_rest_http
206
207 api_put_policy 200 "service1" ricsim_g3_1 STD_QOS_0_2_0 2200 true $notificationurl testdata/STD2/pi_qos_template.json 1
208
209 sim_equal ricsim_g3_1 num_instances 2
210
211
212 use_agent_dmaap_http
213
214 api_put_policy 200 "service1" ricsim_g3_1 STD_QOS_0_2_0 3200 true $notificationurl testdata/STD2/pi_qos_template.json 1
215
216 sim_equal ricsim_g3_1 num_instances 2
217fi
218
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100219# Check policies
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100220if [ "$PMS_VERSION" == "V2" ]; then
221 api_get_policy 200 2000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
222 api_get_policy 200 3000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
223 api_get_policy 200 2100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
224 api_get_policy 200 3100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100225 api_get_policy 200 2200 testdata/STD2/pi_qos_template.json "service1" ricsim_g3_1 STD_QOS_0_2_0 true $notificationurl
226 api_get_policy 200 3200 testdata/STD2/pi_qos_template.json "service1" ricsim_g3_1 STD_QOS_0_2_0 true $notificationurl
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100227else
228 api_get_policy 200 2000 testdata/OSC/pi1_template.json
229 api_get_policy 200 3000 testdata/OSC/pi1_template.json
230 api_get_policy 200 2100 testdata/STD/pi1_template.json
231 api_get_policy 200 3100 testdata/STD/pi1_template.json
232fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100233
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100234sim_equal ricsim_g1_1 num_instances 2
235sim_equal ricsim_g2_1 num_instances 2
236
237if [ "$PMS_VERSION" == "V2" ]; then
238 sim_equal ricsim_g3_1 num_instances 2
239fi
240
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100241# Remove policies
242
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200243use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100244api_delete_policy 204 2000
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200245use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100246api_delete_policy 204 3000
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200247use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100248api_delete_policy 204 2100
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200249use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100250api_delete_policy 204 3100
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100251if [ "$PMS_VERSION" == "V2" ]; then
252 use_agent_dmaap_http
253 api_delete_policy 204 2200
254 use_agent_rest_http
255 api_delete_policy 204 3200
256fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100257
258sim_equal ricsim_g1_1 num_instances 0
259sim_equal ricsim_g2_1 num_instances 0
260
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100261if [ "$PMS_VERSION" == "V2" ]; then
262 sim_equal ricsim_g3_1 num_instances 0
263fi
264
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200265# Check remote host access to simulator
266
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100267sim_contains_str ricsim_g1_1 remote_hosts $POLICY_AGENT_APP_NAME
268sim_contains_str ricsim_g2_1 remote_hosts $POLICY_AGENT_APP_NAME
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100269if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100270 sim_contains_str ricsim_g3_1 remote_hosts $POLICY_AGENT_APP_NAME
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100271fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200272
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100273# Check policy removal
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200274use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100275api_get_policy 404 2000
276api_get_policy 404 3000
277api_get_policy 404 2100
278api_get_policy 404 3100
279
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100280if [ "$PMS_VERSION" == "V2" ]; then
281 api_get_policy 404 2200
282 api_get_policy 404 3200
283fi
284
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100285# Remove the service
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200286use_agent_dmaap_http
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200287api_delete_services 204 "service1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100288
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200289api_get_services 404 "service1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100290
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100291check_policy_agent_logs
292
293#### TEST COMPLETE ####
294
295store_logs END
296
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200297print_result
298
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100299auto_clean_environment