blob: 71ea39800707216a44426d11803e745766cd2a2e [file] [log] [blame]
BjornMagnussonXA70e878f2020-05-11 14:11:30 +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
BjornMagnussonXAad047782020-06-08 15:54:11 +020020TC_ONELINE_DESCR="Preparation for test of the Control Panel and the Health Check app - populating a number of ric simulators with types and instances"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020021
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="CP CR MR PA RICSIM 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
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020040. ../common/testcase_common.sh $@
41. ../common/agent_api_functions.sh
42. ../common/ricsimulator_api_functions.sh
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010043. ../common/mr_api_functions.sh
44. ../common/control_panel_api_functions.sh
45. ../common/controller_api_functions.sh
BjornMagnussonXAc963b732021-01-20 14:24:13 +010046. ../common/consul_cbs_functions.sh
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010047. ../common/kube_proxy_api_functions.sh
48. ../common/gateway_api_functions.sh
BjornMagnussonXAfec823b2021-08-03 14:14:05 +020049. ../common/cr_api_functions.sh
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010050
51setup_testenvironment
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020052
53#### TEST BEGIN ####
54
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010055clean_environment
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020056
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010057if [ $RUNMODE == "KUBE" ]; then
58 start_kube_proxy
59fi
60
BjornMagnussonXA048aaa12020-06-04 07:48:37 +020061OSC_NUM_RICS=6
62STD_NUM_RICS=5
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020063
BjornMagnussonXAad047782020-06-08 15:54:11 +020064start_ric_simulators $RIC_SIM_PREFIX"_g1" $OSC_NUM_RICS OSC_2.1.0
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020065
BjornMagnussonXAad047782020-06-08 15:54:11 +020066start_ric_simulators $RIC_SIM_PREFIX"_g2" $STD_NUM_RICS STD_1.1.3
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020067
BjornMagnussonXA4207b832020-11-03 09:52:49 +010068if [ "$PMS_VERSION" == "V2" ]; then
69 start_ric_simulators $RIC_SIM_PREFIX"_g3" $STD_NUM_RICS STD_2.0.0
70fi
71
BjornMagnussonXA048aaa12020-06-04 07:48:37 +020072start_mr #Just to prevent errors in the agent log...
73
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010074start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020075
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010076if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
77 start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
78fi
79
80start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/$POLICY_AGENT_CONFIG_FILE
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020081
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020082use_agent_rest_http
83
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010084if [ $RUNMODE == "DOCKER" ]; then
85 start_consul_cbs
86fi
87
88prepare_consul_config NOSDNC ".consul_config.json"
89
90if [ $RUNMODE == "KUBE" ]; then
91 agent_load_config ".consul_config.json"
92else
93 consul_config_app ".consul_config.json"
94fi
95
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020096api_get_status 200
97
BjornMagnussonXA048aaa12020-06-04 07:48:37 +020098# Print the A1 version for OSC
99for ((i=1; i<=$OSC_NUM_RICS; i++))
100do
BjornMagnussonXAad047782020-06-08 15:54:11 +0200101 sim_print $RIC_SIM_PREFIX"_g1_"$i interface
BjornMagnussonXA048aaa12020-06-04 07:48:37 +0200102done
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200103
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200104
BjornMagnussonXA048aaa12020-06-04 07:48:37 +0200105# Print the A1 version for STD
106for ((i=1; i<=$STD_NUM_RICS; i++))
107do
BjornMagnussonXAad047782020-06-08 15:54:11 +0200108 sim_print $RIC_SIM_PREFIX"_g2_"$i interface
BjornMagnussonXA048aaa12020-06-04 07:48:37 +0200109done
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200110
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100111if [ "$PMS_VERSION" == "V2" ]; then
112 # Print the A1 version for STD 2.X
113 for ((i=1; i<=$STD_NUM_RICS; i++))
114 do
115 sim_print $RIC_SIM_PREFIX"_g3_"$i interface
116 done
117fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200118
BjornMagnussonXA048aaa12020-06-04 07:48:37 +0200119# Load the polictypes in osc
120for ((i=1; i<=$OSC_NUM_RICS; i++))
121do
BjornMagnussonXAad047782020-06-08 15:54:11 +0200122 sim_put_policy_type 201 $RIC_SIM_PREFIX"_g1_"$i 2 testdata/OSC/sim_hw.json
123 sim_put_policy_type 201 $RIC_SIM_PREFIX"_g1_"$i 100 testdata/OSC/sim_qos.json
124 sim_put_policy_type 201 $RIC_SIM_PREFIX"_g1_"$i 20008 testdata/OSC/sim_tsa.json
BjornMagnussonXA048aaa12020-06-04 07:48:37 +0200125done
126
127
128#Check the number of schemas and the individual schemas in OSC
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100129if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100130 api_equal json:policy-types 4 300
BjornMagnussonXA048aaa12020-06-04 07:48:37 +0200131
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100132 for ((i=1; i<=$OSC_NUM_RICS; i++))
133 do
134 api_equal json:policy-types?ric_id=$RIC_SIM_PREFIX"_g1_"$i 3 120
135 done
BjornMagnussonXA048aaa12020-06-04 07:48:37 +0200136
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100137 # Check the schemas in OSC
138 for ((i=1; i<=$OSC_NUM_RICS; i++))
139 do
140 api_get_policy_type 200 2 testdata/OSC/hw-agent-modified.json
141 api_get_policy_type 200 100 testdata/OSC/qos-agent-modified.json
142 api_get_policy_type 200 20008 testdata/OSC/tsa-agent-modified.json
143 done
144else
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100145 api_equal json:policy_types 4 300
BjornMagnussonXA048aaa12020-06-04 07:48:37 +0200146
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100147 for ((i=1; i<=$OSC_NUM_RICS; i++))
148 do
149 api_equal json:policy_types?ric=$RIC_SIM_PREFIX"_g1_"$i 3 120
150 done
151
152 # Check the schemas in OSC
153 for ((i=1; i<=$OSC_NUM_RICS; i++))
154 do
155 api_get_policy_schema 200 2 testdata/OSC/hw-agent-modified.json
156 api_get_policy_schema 200 100 testdata/OSC/qos-agent-modified.json
157 api_get_policy_schema 200 20008 testdata/OSC/tsa-agent-modified.json
158 done
159fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200160
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100161if [ "$PMS_VERSION" == "V2" ]; then
162
163 # Load the polictypes in std
164 for ((i=1; i<=$STD_NUM_RICS; i++))
165 do
166 sim_put_policy_type 201 $RIC_SIM_PREFIX"_g3_"$i STD_QOS_0_2_0 demo-testdata/STD2/sim_qos.json
167 sim_put_policy_type 201 $RIC_SIM_PREFIX"_g3_"$i STD_QOS2_0.1.0 demo-testdata/STD2/sim_qos2.json
168 done
169
170 #Check the number of schemas and the individual schemas in STD
171 api_equal json:policy-types 6 120
172
173 for ((i=1; i<=$STD_NUM_RICS; i++))
174 do
175 api_equal json:policy-types?ric_id=$RIC_SIM_PREFIX"_g3_"$i 2 120
176 done
177
178 # Check the schemas in STD
179 for ((i=1; i<=$STD_NUM_RICS; i++))
180 do
181 api_get_policy_type 200 STD_QOS_0_2_0 demo-testdata/STD2/qos-agent-modified.json
182 api_get_policy_type 200 'STD_QOS2_0.1.0' demo-testdata/STD2/qos2-agent-modified.json
183 done
184fi
185
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200186# Create policies
187use_agent_rest_http
188
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100189api_put_service 201 "Emergency-response-app" 0 "$CR_SERVICE_PATH/1"
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200190
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100191if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100192 notificationurl=$CR_SERVICE_PATH"/test"
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100193else
194 notificationurl=""
195fi
196
BjornMagnussonXA048aaa12020-06-04 07:48:37 +0200197# Create policies in OSC
198for ((i=1; i<=$OSC_NUM_RICS; i++))
199do
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +0100200 generate_policy_uuid
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100201 api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 2 $((2000+$i)) NOTRANSIENT $notificationurl testdata/OSC/pihw_template.json 1
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +0100202 generate_policy_uuid
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100203 api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 100 $((3000+$i)) NOTRANSIENT $notificationurl testdata/OSC/piqos_template.json 1
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +0100204 generate_policy_uuid
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100205 api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 20008 $((4000+$i)) NOTRANSIENT $notificationurl testdata/OSC/pitsa_template.json 1
BjornMagnussonXA048aaa12020-06-04 07:48:37 +0200206done
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200207
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200208
BjornMagnussonXA048aaa12020-06-04 07:48:37 +0200209# Check the number of policies in OSC
210for ((i=1; i<=$OSC_NUM_RICS; i++))
211do
BjornMagnussonXAad047782020-06-08 15:54:11 +0200212 sim_equal $RIC_SIM_PREFIX"_g1_"$i num_instances 3
BjornMagnussonXA048aaa12020-06-04 07:48:37 +0200213done
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200214
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200215
BjornMagnussonXA048aaa12020-06-04 07:48:37 +0200216# Create policies in STD
217for ((i=1; i<=$STD_NUM_RICS; i++))
218do
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +0100219 generate_policy_uuid
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100220 api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g2_"$i NOTYPE $((2100+$i)) NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100221 if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +0100222 generate_policy_uuid
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100223 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 +0100224 generate_policy_uuid
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100225 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
226 fi
BjornMagnussonXA048aaa12020-06-04 07:48:37 +0200227done
228
229
230# Check the number of policies in STD
231for ((i=1; i<=$STD_NUM_RICS; i++))
232do
BjornMagnussonXAad047782020-06-08 15:54:11 +0200233 sim_equal $RIC_SIM_PREFIX"_g2_"$i num_instances 1
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100234 if [ "$PMS_VERSION" == "V2" ]; then
235 sim_equal $RIC_SIM_PREFIX"_g3_"$i num_instances 2
236 fi
BjornMagnussonXA048aaa12020-06-04 07:48:37 +0200237done
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200238
239check_policy_agent_logs
240
241#### TEST COMPLETE ####
242
243store_logs END
244
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +0100245print_result
246
247auto_clean_environment