blob: a8bc7f4439197da59cd67982a803e49648545a6d [file] [log] [blame]
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +02001#!/usr/bin/env 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
20TC_ONELINE_DESCR="Preparation demo setup - populating a number of ric simulators with types and instances"
21
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010022#App names to include in the test when running docker, space separated list
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +010023DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR A1PMS RICSIM SDNC NGW KUBEPROXY"
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +020024
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010025#App names to include in the test when running kubernetes, space separated list
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +010026KUBE_INCLUDED_IMAGES="CP CR MR A1PMS RICSIM SDNC 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
BjornMagnussonXA8fbb2262022-01-24 15:20:15 +010033CONDITIONALLY_IGNORED_IMAGES="CBS CONSUL NGW"
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010034
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010035#Supported test environment profiles
BjornMagnussonXA23d69b42023-02-03 15:13:53 +010036SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ONAP-ISTANBUL ONAP-JAKARTA ONAP-KOHN ONAP-LONDON ORAN-CHERRY ORAN-D-RELEASE ORAN-E-RELEASE ORAN-F-RELEASE ORAN-G-RELEASE ORAN-H-RELEASE"
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010037#Supported run modes
38SUPPORTED_RUNMODES="DOCKER KUBE"
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010039
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +020040. ../common/testcase_common.sh $@
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010041
42setup_testenvironment
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +020043
44#### TEST BEGIN ####
45
46#Local vars in test script
47##########################
BjornMagnussonXA4207b832020-11-03 09:52:49 +010048
BjornMagnussonXA7b36db62020-11-23 10:57:57 +010049use_cr_https
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +010050use_a1pms_rest_https
BjornMagnussonXA7b36db62020-11-23 10:57:57 +010051use_sdnc_https
52use_simulator_https
53
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +010054if [ "$A1PMS_VERSION" == "V2" ]; then
BjornMagnussonXA79e37002021-11-22 13:36:04 +010055 notificationurl=$CR_SERVICE_APP_PATH_0"/test"
BjornMagnussonXA4207b832020-11-03 09:52:49 +010056else
57 notificationurl=""
58fi
59
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010060clean_environment
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +020061
BjornMagnussonXA663566c2021-11-08 10:25:07 +010062start_kube_proxy
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010063
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +020064OSC_NUM_RICS=6
65STD_NUM_RICS=5
66
67start_ric_simulators $RIC_SIM_PREFIX"_g1" $OSC_NUM_RICS OSC_2.1.0
68
69start_ric_simulators $RIC_SIM_PREFIX"_g2" $STD_NUM_RICS STD_1.1.3
70
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +010071if [ "$A1PMS_VERSION" == "V2" ]; then
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010072 start_ric_simulators $RIC_SIM_PREFIX"_g3" $STD_NUM_RICS STD_2.0.0
73fi
74
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +010075start_mr #Just to prevent errors in the a1pms log...
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +020076
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010077start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
78
79if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
80 start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
81fi
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +020082
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +020083start_sdnc
84
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +010085start_a1pms NORPOXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +020086
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +010087set_a1pms_trace
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010088
BjornMagnussonXAf81090f2022-08-24 09:17:44 +020089__CONFIG_HEADER="NOHEADER"
90if [ $RUNMODE == "KUBE" ]; then
91 __CONFIG_HEADER="HEADER"
92else
93 if [[ "$A1PMS_FEATURE_LEVEL" == *"NOCONSUL"* ]]; then
94 __CONFIG_HEADER="HEADER"
95 fi
96 fi
97
98prepare_consul_config SDNC ".consul_config.json" $__CONFIG_HEADER
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010099
100if [ $RUNMODE == "KUBE" ]; then
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100101 a1pms_load_config ".consul_config.json"
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100102else
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100103 if [[ "$A1PMS_FEATURE_LEVEL" == *"NOCONSUL"* ]]; then
104 a1pms_api_put_configuration 200 ".consul_config.json"
BjornMagnussonXA8fbb2262022-01-24 15:20:15 +0100105 else
106 start_consul_cbs
107 consul_config_app ".consul_config.json"
108 fi
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100109fi
110
BjornMagnussonXAf4a7e422022-09-01 16:35:17 +0200111sleep_wait 120 "Let A1PMS cofiguration take effect"
112
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100113a1pms_api_get_status 200
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +0200114
115# Print the A1 version for OSC
116for ((i=1; i<=$OSC_NUM_RICS; i++))
117do
118 sim_print $RIC_SIM_PREFIX"_g1_"$i interface
119done
120
121
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100122# Print the A1 version for STD 1.X
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +0200123for ((i=1; i<=$STD_NUM_RICS; i++))
124do
125 sim_print $RIC_SIM_PREFIX"_g2_"$i interface
126done
127
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100128if [ "$A1PMS_VERSION" == "V2" ]; then
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100129 # Print the A1 version for STD 2.X
130 for ((i=1; i<=$STD_NUM_RICS; i++))
131 do
132 sim_print $RIC_SIM_PREFIX"_g3_"$i interface
133 done
134fi
135
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +0200136
137# Load the polictypes in osc
138for ((i=1; i<=$OSC_NUM_RICS; i++))
139do
140 sim_put_policy_type 201 $RIC_SIM_PREFIX"_g1_"$i 100 demo-testdata/OSC/sim_qos.json
141 sim_put_policy_type 201 $RIC_SIM_PREFIX"_g1_"$i 20008 demo-testdata/OSC/sim_tsa.json
142done
143
144
145#Check the number of schemas and the individual schemas in OSC
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100146if [ "$A1PMS_VERSION" == "V2" ]; then
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100147
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100148 a1pms_equal json:policy-types 3 300
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +0200149
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100150 for ((i=1; i<=$OSC_NUM_RICS; i++))
151 do
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100152 a1pms_equal json:policy-types?ric_id=$RIC_SIM_PREFIX"_g1_"$i 2 120
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100153 done
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +0200154
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100155 # Check the schemas in OSC
156 for ((i=1; i<=$OSC_NUM_RICS; i++))
157 do
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100158 a1pms_api_get_policy_type 200 100 demo-testdata/OSC/qos-a1pms-modified.json
159 a1pms_api_get_policy_type 200 20008 demo-testdata/OSC/tsa-a1pms-modified.json
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100160 done
161else
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100162 a1pms_equal json:policy_types 3 300
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100163
164 for ((i=1; i<=$OSC_NUM_RICS; i++))
165 do
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100166 a1pms_equal json:policy_types?ric=$RIC_SIM_PREFIX"_g1_"$i 2 120
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100167 done
168
169 # Check the schemas in OSC
170 for ((i=1; i<=$OSC_NUM_RICS; i++))
171 do
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100172 a1pms_api_get_policy_schema 200 100 demo-testdata/OSC/qos-a1pms-modified.json
173 a1pms_api_get_policy_schema 200 20008 demo-testdata/OSC/tsa-a1pms-modified.json
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100174 done
175fi
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +0200176
177
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100178
179
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100180if [ "$A1PMS_VERSION" == "V2" ]; then
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100181
182 # Load the polictypes in std
183 for ((i=1; i<=$STD_NUM_RICS; i++))
184 do
185 sim_put_policy_type 201 $RIC_SIM_PREFIX"_g3_"$i STD_QOS_0_2_0 demo-testdata/STD2/sim_qos.json
186 sim_put_policy_type 201 $RIC_SIM_PREFIX"_g3_"$i STD_QOS2_0.1.0 demo-testdata/STD2/sim_qos2.json
187 done
188
189 #Check the number of schemas and the individual schemas in STD
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100190 a1pms_equal json:policy-types 5 120
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100191
192 for ((i=1; i<=$STD_NUM_RICS; i++))
193 do
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100194 a1pms_equal json:policy-types?ric_id=$RIC_SIM_PREFIX"_g3_"$i 2 120
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100195 done
196
197 # Check the schemas in STD
198 for ((i=1; i<=$STD_NUM_RICS; i++))
199 do
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100200 a1pms_api_get_policy_type 200 STD_QOS_0_2_0 demo-testdata/STD2/qos-a1pms-modified.json
201 a1pms_api_get_policy_type 200 'STD_QOS2_0.1.0' demo-testdata/STD2/qos2-a1pms-modified.json
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100202 done
203fi
204
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100205#Check the number of types
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100206if [ "$A1PMS_VERSION" == "V2" ]; then
207 a1pms_equal json:policy-types 5 120
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100208else
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100209 a1pms_equal json:policy_types 3 120
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100210fi
211
212
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +0200213# Create policies
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100214use_a1pms_rest_http
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +0200215
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100216a1pms_api_put_service 201 "Emergency-response-app" 0 "$CR_SERVICE_APP_PATH_0/1"
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +0200217
218# Create policies in OSC
219for ((i=1; i<=$OSC_NUM_RICS; i++))
220do
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +0100221 generate_policy_uuid
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100222 a1pms_api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 100 $((3000+$i)) NOTRANSIENT $notificationurl demo-testdata/OSC/piqos_template.json 1
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +0100223 generate_policy_uuid
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100224 a1pms_api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 20008 $((4000+$i)) NOTRANSIENT $notificationurl demo-testdata/OSC/pitsa_template.json 1
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +0200225done
226
227
228# Check the number of policies in OSC
229for ((i=1; i<=$OSC_NUM_RICS; i++))
230do
231 sim_equal $RIC_SIM_PREFIX"_g1_"$i num_instances 2
232done
233
234
235# Create policies in STD
236for ((i=1; i<=$STD_NUM_RICS; i++))
237do
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +0100238 generate_policy_uuid
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100239 a1pms_api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g2_"$i NOTYPE $((2100+$i)) NOTRANSIENT $notificationurl demo-testdata/STD/pi1_template.json 1
240 if [ "$A1PMS_VERSION" == "V2" ]; then
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +0100241 generate_policy_uuid
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100242 a1pms_api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g3_"$i STD_QOS_0_2_0 $((2300+$i)) NOTRANSIENT $notificationurl demo-testdata/STD2/pi1_template.json 1
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +0100243 generate_policy_uuid
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100244 a1pms_api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g3_"$i 'STD_QOS2_0.1.0' $((2400+$i)) NOTRANSIENT $notificationurl demo-testdata/STD2/pi1_template.json 1
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100245 fi
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +0200246done
247
248
249# Check the number of policies in STD
250for ((i=1; i<=$STD_NUM_RICS; i++))
251do
252 sim_equal $RIC_SIM_PREFIX"_g2_"$i num_instances 1
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100253 if [ "$A1PMS_VERSION" == "V2" ]; then
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100254 sim_equal $RIC_SIM_PREFIX"_g3_"$i num_instances 2
255 fi
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +0200256done
257
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100258check_a1pms_logs
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +0100259check_sdnc_logs
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +0200260
261#### TEST COMPLETE ####
262
263store_logs END
264
265print_result
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +0100266
267auto_clean_environment