blob: a561cc6bbcbb46592f078703fdb4f34eb1a47e5e [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 $@
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010041
42setup_testenvironment
BjornMagnussonXA80a92002020-03-19 14:31:06 +010043
44#### TEST BEGIN ####
45
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010046generate_policy_uuid
BjornMagnussonXAad047782020-06-08 15:54:11 +020047
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +020048use_simulator_http
49use_mr_http
50use_agent_rest_http
51
BjornMagnussonXA80a92002020-03-19 14:31:06 +010052
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010053clean_environment
BjornMagnussonXA80a92002020-03-19 14:31:06 +010054
BjornMagnussonXA663566c2021-11-08 10:25:07 +010055start_kube_proxy
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010056
BjornMagnussonXA80a92002020-03-19 14:31:06 +010057start_ric_simulators ricsim_g1 3 OSC_2.1.0
58
59start_ric_simulators ricsim_g2 5 STD_1.1.3
60
BjornMagnussonXA4207b832020-11-03 09:52:49 +010061if [ "$PMS_VERSION" == "V2" ]; then
62 start_ric_simulators ricsim_g3 1 STD_2.0.0
63fi
64
BjornMagnussonXA80a92002020-03-19 14:31:06 +010065start_mr
66
BjornMagnussonXA79e37002021-11-22 13:36:04 +010067start_cr 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +010068
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010069if [ $RUNMODE == "DOCKER" ]; then
70 start_consul_cbs
71fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +010072
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010073start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
BjornMagnussonXA80a92002020-03-19 14:31:06 +010074
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010075if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
76 start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
77fi
78
79start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/$POLICY_AGENT_CONFIG_FILE
BjornMagnussonXA80a92002020-03-19 14:31:06 +010080
BjornMagnussonXA72667f12020-04-24 09:20:18 +020081set_agent_debug
82
83use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010084
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010085prepare_consul_config NOSDNC ".consul_config.json"
86
87if [ $RUNMODE == "KUBE" ]; then
88 agent_load_config ".consul_config.json"
89else
90 consul_config_app ".consul_config.json"
91fi
92
BjornMagnussonXA80a92002020-03-19 14:31:06 +010093api_get_status 200
94
95sim_print ricsim_g1_1 interface
96
97sim_print ricsim_g2_1 interface
98
BjornMagnussonXA4207b832020-11-03 09:52:49 +010099if [ "$PMS_VERSION" == "V2" ]; then
100 sim_print ricsim_g3_1 interface
101fi
102
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100103sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
104
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100105if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100106 sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100107 api_equal json:policy-types 3 300
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100108else
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100109 api_equal json:policy_types 2 300
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100110fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100111
112# Create policies
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100113
114if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100115 notificationurl=$CR_SERVICE_APP_PATH_0"/test"
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100116else
117 notificationurl=""
118fi
119
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200120use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100121
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100122api_put_service 201 "service1" 3600 "$CR_SERVICE_APP_PATH_0/1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100123
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100124api_put_policy 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100125
126sim_equal ricsim_g1_1 num_instances 1
127
128
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200129use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100130
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100131api_put_policy 201 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100132
133sim_equal ricsim_g1_1 num_instances 2
134
135
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200136use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100137
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100138api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100139
140sim_equal ricsim_g2_1 num_instances 1
141
142
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200143use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100144
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100145api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100146
147sim_equal ricsim_g2_1 num_instances 2
148
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100149if [ "$PMS_VERSION" == "V2" ]; then
150 use_agent_rest_http
151
152 api_put_policy 201 "service1" ricsim_g3_1 STD_QOS_0_2_0 2200 true $notificationurl testdata/STD2/pi_qos_template.json 1
153
154 sim_equal ricsim_g3_1 num_instances 1
155
156 use_agent_dmaap_http
157
158 api_put_policy 201 "service1" ricsim_g3_1 STD_QOS_0_2_0 3200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos_template.json 1
159
160 sim_equal ricsim_g3_1 num_instances 2
161
162fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100163
164#Update policies
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200165use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100166
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100167api_put_service 200 "service1" 3600 "$CR_SERVICE_APP_PATH_0/1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100168
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100169api_put_policy 200 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100170
171sim_equal ricsim_g1_1 num_instances 2
172
173
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200174use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100175
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100176api_put_policy 200 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100177
178sim_equal ricsim_g1_1 num_instances 2
179
180
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200181use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100182
183
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100184api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100185
186sim_equal ricsim_g2_1 num_instances 2
187
188
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200189use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100190
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100191api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100192
193sim_equal ricsim_g2_1 num_instances 2
194
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100195if [ "$PMS_VERSION" == "V2" ]; then
196 use_agent_rest_http
197
198 api_put_policy 200 "service1" ricsim_g3_1 STD_QOS_0_2_0 2200 true $notificationurl testdata/STD2/pi_qos_template.json 1
199
200 sim_equal ricsim_g3_1 num_instances 2
201
202
203 use_agent_dmaap_http
204
205 api_put_policy 200 "service1" ricsim_g3_1 STD_QOS_0_2_0 3200 true $notificationurl testdata/STD2/pi_qos_template.json 1
206
207 sim_equal ricsim_g3_1 num_instances 2
208fi
209
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100210# Check policies
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100211if [ "$PMS_VERSION" == "V2" ]; then
212 api_get_policy 200 2000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
213 api_get_policy 200 3000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
214 api_get_policy 200 2100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
215 api_get_policy 200 3100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100216 api_get_policy 200 2200 testdata/STD2/pi_qos_template.json "service1" ricsim_g3_1 STD_QOS_0_2_0 true $notificationurl
217 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 +0100218else
219 api_get_policy 200 2000 testdata/OSC/pi1_template.json
220 api_get_policy 200 3000 testdata/OSC/pi1_template.json
221 api_get_policy 200 2100 testdata/STD/pi1_template.json
222 api_get_policy 200 3100 testdata/STD/pi1_template.json
223fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100224
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100225sim_equal ricsim_g1_1 num_instances 2
226sim_equal ricsim_g2_1 num_instances 2
227
228if [ "$PMS_VERSION" == "V2" ]; then
229 sim_equal ricsim_g3_1 num_instances 2
230fi
231
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100232# Remove policies
233
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200234use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100235api_delete_policy 204 2000
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200236use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100237api_delete_policy 204 3000
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200238use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100239api_delete_policy 204 2100
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200240use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100241api_delete_policy 204 3100
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100242if [ "$PMS_VERSION" == "V2" ]; then
243 use_agent_dmaap_http
244 api_delete_policy 204 2200
245 use_agent_rest_http
246 api_delete_policy 204 3200
247fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100248
249sim_equal ricsim_g1_1 num_instances 0
250sim_equal ricsim_g2_1 num_instances 0
251
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100252if [ "$PMS_VERSION" == "V2" ]; then
253 sim_equal ricsim_g3_1 num_instances 0
254fi
255
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200256# Check remote host access to simulator
257
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100258sim_contains_str ricsim_g1_1 remote_hosts $POLICY_AGENT_APP_NAME
259sim_contains_str ricsim_g2_1 remote_hosts $POLICY_AGENT_APP_NAME
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100260if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100261 sim_contains_str ricsim_g3_1 remote_hosts $POLICY_AGENT_APP_NAME
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100262fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200263
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100264# Check policy removal
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200265use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100266api_get_policy 404 2000
267api_get_policy 404 3000
268api_get_policy 404 2100
269api_get_policy 404 3100
270
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100271if [ "$PMS_VERSION" == "V2" ]; then
272 api_get_policy 404 2200
273 api_get_policy 404 3200
274fi
275
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100276# Remove the service
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200277use_agent_dmaap_http
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200278api_delete_services 204 "service1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100279
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200280api_get_services 404 "service1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100281
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100282check_policy_agent_logs
283
284#### TEST COMPLETE ####
285
286store_logs END
287
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200288print_result
289
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100290auto_clean_environment