blob: 567faccbf74555a1c9ee0083136ca2f52cfb325a [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
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010023DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM NGW"
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
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010064if [ $RUNMODE == "KUBE" ]; then
65 start_kube_proxy
66fi
67
BjornMagnussonXA80a92002020-03-19 14:31:06 +010068start_ric_simulators ricsim_g1 3 OSC_2.1.0
69
70start_ric_simulators ricsim_g2 5 STD_1.1.3
71
BjornMagnussonXA4207b832020-11-03 09:52:49 +010072if [ "$PMS_VERSION" == "V2" ]; then
73 start_ric_simulators ricsim_g3 1 STD_2.0.0
74fi
75
BjornMagnussonXA80a92002020-03-19 14:31:06 +010076start_mr
77
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010078start_cr
BjornMagnussonXA80a92002020-03-19 14:31:06 +010079
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010080if [ $RUNMODE == "DOCKER" ]; then
81 start_consul_cbs
82fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +010083
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010084start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
BjornMagnussonXA80a92002020-03-19 14:31:06 +010085
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010086if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
87 start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
88fi
89
90start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/$POLICY_AGENT_CONFIG_FILE
BjornMagnussonXA80a92002020-03-19 14:31:06 +010091
BjornMagnussonXA72667f12020-04-24 09:20:18 +020092set_agent_debug
93
94use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010095
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010096prepare_consul_config NOSDNC ".consul_config.json"
97
98if [ $RUNMODE == "KUBE" ]; then
99 agent_load_config ".consul_config.json"
100else
101 consul_config_app ".consul_config.json"
102fi
103
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100104api_get_status 200
105
106sim_print ricsim_g1_1 interface
107
108sim_print ricsim_g2_1 interface
109
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100110if [ "$PMS_VERSION" == "V2" ]; then
111 sim_print ricsim_g3_1 interface
112fi
113
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100114sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
115
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100116if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100117 sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100118 api_equal json:policy-types 3 300
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100119else
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100120 api_equal json:policy_types 2 300
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100121fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100122
123# Create policies
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100124
125if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100126 notificationurl=$CR_SERVICE_PATH"/test"
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100127else
128 notificationurl=""
129fi
130
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200131use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100132
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100133api_put_service 201 "service1" 3600 "$CR_SERVICE_PATH/1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100134
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100135api_put_policy 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100136
137sim_equal ricsim_g1_1 num_instances 1
138
139
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200140use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100141
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100142api_put_policy 201 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100143
144sim_equal ricsim_g1_1 num_instances 2
145
146
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200147use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100148
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100149api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100150
151sim_equal ricsim_g2_1 num_instances 1
152
153
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200154use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100155
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100156api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100157
158sim_equal ricsim_g2_1 num_instances 2
159
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100160if [ "$PMS_VERSION" == "V2" ]; then
161 use_agent_rest_http
162
163 api_put_policy 201 "service1" ricsim_g3_1 STD_QOS_0_2_0 2200 true $notificationurl testdata/STD2/pi_qos_template.json 1
164
165 sim_equal ricsim_g3_1 num_instances 1
166
167 use_agent_dmaap_http
168
169 api_put_policy 201 "service1" ricsim_g3_1 STD_QOS_0_2_0 3200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos_template.json 1
170
171 sim_equal ricsim_g3_1 num_instances 2
172
173fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100174
175#Update policies
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200176use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100177
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100178api_put_service 200 "service1" 3600 "$CR_SERVICE_PATH/1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100179
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100180api_put_policy 200 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100181
182sim_equal ricsim_g1_1 num_instances 2
183
184
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200185use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100186
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100187api_put_policy 200 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100188
189sim_equal ricsim_g1_1 num_instances 2
190
191
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200192use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100193
194
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100195api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100196
197sim_equal ricsim_g2_1 num_instances 2
198
199
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200200use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100201
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100202api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100203
204sim_equal ricsim_g2_1 num_instances 2
205
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100206if [ "$PMS_VERSION" == "V2" ]; then
207 use_agent_rest_http
208
209 api_put_policy 200 "service1" ricsim_g3_1 STD_QOS_0_2_0 2200 true $notificationurl testdata/STD2/pi_qos_template.json 1
210
211 sim_equal ricsim_g3_1 num_instances 2
212
213
214 use_agent_dmaap_http
215
216 api_put_policy 200 "service1" ricsim_g3_1 STD_QOS_0_2_0 3200 true $notificationurl testdata/STD2/pi_qos_template.json 1
217
218 sim_equal ricsim_g3_1 num_instances 2
219fi
220
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100221# Check policies
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100222if [ "$PMS_VERSION" == "V2" ]; then
223 api_get_policy 200 2000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
224 api_get_policy 200 3000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
225 api_get_policy 200 2100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
226 api_get_policy 200 3100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100227 api_get_policy 200 2200 testdata/STD2/pi_qos_template.json "service1" ricsim_g3_1 STD_QOS_0_2_0 true $notificationurl
228 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 +0100229else
230 api_get_policy 200 2000 testdata/OSC/pi1_template.json
231 api_get_policy 200 3000 testdata/OSC/pi1_template.json
232 api_get_policy 200 2100 testdata/STD/pi1_template.json
233 api_get_policy 200 3100 testdata/STD/pi1_template.json
234fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100235
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100236sim_equal ricsim_g1_1 num_instances 2
237sim_equal ricsim_g2_1 num_instances 2
238
239if [ "$PMS_VERSION" == "V2" ]; then
240 sim_equal ricsim_g3_1 num_instances 2
241fi
242
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100243# Remove policies
244
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200245use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100246api_delete_policy 204 2000
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200247use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100248api_delete_policy 204 3000
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200249use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100250api_delete_policy 204 2100
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200251use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100252api_delete_policy 204 3100
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100253if [ "$PMS_VERSION" == "V2" ]; then
254 use_agent_dmaap_http
255 api_delete_policy 204 2200
256 use_agent_rest_http
257 api_delete_policy 204 3200
258fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100259
260sim_equal ricsim_g1_1 num_instances 0
261sim_equal ricsim_g2_1 num_instances 0
262
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100263if [ "$PMS_VERSION" == "V2" ]; then
264 sim_equal ricsim_g3_1 num_instances 0
265fi
266
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200267# Check remote host access to simulator
268
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100269sim_contains_str ricsim_g1_1 remote_hosts $POLICY_AGENT_APP_NAME
270sim_contains_str ricsim_g2_1 remote_hosts $POLICY_AGENT_APP_NAME
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100271if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100272 sim_contains_str ricsim_g3_1 remote_hosts $POLICY_AGENT_APP_NAME
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100273fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200274
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100275# Check policy removal
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200276use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100277api_get_policy 404 2000
278api_get_policy 404 3000
279api_get_policy 404 2100
280api_get_policy 404 3100
281
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100282if [ "$PMS_VERSION" == "V2" ]; then
283 api_get_policy 404 2200
284 api_get_policy 404 3200
285fi
286
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100287# Remove the service
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200288use_agent_dmaap_http
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200289api_delete_services 204 "service1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100290
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200291api_get_services 404 "service1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100292
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100293check_policy_agent_logs
294
295#### TEST COMPLETE ####
296
297store_logs END
298
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200299print_result
300
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100301auto_clean_environment