blob: a67e7e07b9d9d0a63d3c4778a006c8d7bc344d82 [file] [log] [blame]
BjornMagnussonXA7b36db62020-11-23 10:57:57 +01001#!/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
BjornMagnussonXA007b6452021-11-29 08:03:38 +010020TC_ONELINE_DESCR="Preparation demo setup - policy management and information information"
BjornMagnussonXA7b36db62020-11-23 10:57:57 +010021
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 ICS PRODSTUB RC HTTPPROXY KUBEPROXY NGW"
BjornMagnussonXA7b36db62020-11-23 10:57:57 +010024
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=" MR CR A1PMS RC PRODSTUB RICSIM CP ICS SDNC HTTPPROXY 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
BjornMagnussonXAe60d04e2021-12-27 13:38:01 +010036SUPPORTED_PROFILES="ONAP-HONOLULU ONAP-ISTANBUL ONAP-JAKARTA ORAN-CHERRY ORAN-D-RELEASE ORAN-E-RELEASE ORAN-F-RELEASE"
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010037#Supported run modes
38SUPPORTED_RUNMODES="DOCKER KUBE"
BjornMagnussonXA7b36db62020-11-23 10:57:57 +010039
40. ../common/testcase_common.sh $@
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010041
42setup_testenvironment
BjornMagnussonXA7b36db62020-11-23 10:57:57 +010043
44#### TEST BEGIN ####
45
46#Local vars in test script
47##########################
48
49use_cr_https
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +010050use_a1pms_rest_https
BjornMagnussonXA7b36db62020-11-23 10:57:57 +010051use_sdnc_https
52use_simulator_https
BjornMagnussonXA007b6452021-11-29 08:03:38 +010053use_ics_rest_https
BjornMagnussonXA7b36db62020-11-23 10:57:57 +010054use_prod_stub_https
BjornMagnussonXA007b6452021-11-29 08:03:38 +010055if [ $ICS_VERSION == "V1-1" ]; then
BjornMagnussonXAc963b732021-01-20 14:24:13 +010056 use_rapp_catalogue_http # https not yet supported
57else
58 use_rapp_catalogue_https
59fi
60
BjornMagnussonXA7b36db62020-11-23 10:57:57 +010061
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +010062if [ "$A1PMS_VERSION" == "V2" ]; then
BjornMagnussonXA79e37002021-11-22 13:36:04 +010063 notificationurl=$CR_SERVICE_APP_PATH_0"/test"
BjornMagnussonXA7b36db62020-11-23 10:57:57 +010064else
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +010065 echo "A1PMS VERSION 2 (V2) is required"
BjornMagnussonXA7b36db62020-11-23 10:57:57 +010066 exit 1
67fi
68
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010069clean_environment
BjornMagnussonXA7b36db62020-11-23 10:57:57 +010070
BjornMagnussonXA663566c2021-11-08 10:25:07 +010071start_kube_proxy
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010072
BjornMagnussonXA7b36db62020-11-23 10:57:57 +010073STD_NUM_RICS=2
74
BjornMagnussonXAc963b732021-01-20 14:24:13 +010075#start_http_proxy #Remove the comment on this line, comment out 'start_sdnc' and change SDNC to NOSDNC a few lines below to run with proxy
76
BjornMagnussonXA7b36db62020-11-23 10:57:57 +010077start_ric_simulators $RIC_SIM_PREFIX"_g3" $STD_NUM_RICS STD_2.0.0
78
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +010079start_mr #Just to prevent errors in the a1pms log...
BjornMagnussonXA7b36db62020-11-23 10:57:57 +010080
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +010081start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
82
83if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
84 start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
85fi
BjornMagnussonXA7b36db62020-11-23 10:57:57 +010086
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +010087start_sdnc # Comment this line to run A1PMS with proxy
BjornMagnussonXA7b36db62020-11-23 10:57:57 +010088
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +010089start_a1pms PROXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010090
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +010091prepare_consul_config SDNC ".consul_config.json" #Change to NOSDNC if running A1PMS with proxy
BjornMagnussonXA7b36db62020-11-23 10:57:57 +010092
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010093if [ $RUNMODE == "KUBE" ]; then
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +010094 a1pms_load_config ".consul_config.json"
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010095else
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +010096 if [[ "$A1PMS_FEATURE_LEVEL" == *"NOCONSUL"* ]]; then
97 a1pms_api_put_configuration 200 ".consul_config.json"
BjornMagnussonXA8fbb2262022-01-24 15:20:15 +010098 else
99 start_consul_cbs
100 consul_config_app ".consul_config.json"
101 fi
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100102fi
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100103
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100104start_cr 1
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100105
106start_prod_stub
107
BjornMagnussonXA007b6452021-11-29 08:03:38 +0100108start_ics PROXY $SIM_GROUP/$ICS_COMPOSE_DIR/$ICS_CONFIG_FILE
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100109
BjornMagnussonXAde4d0f82020-11-29 16:04:06 +0100110start_rapp_catalogue
111
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100112set_a1pms_trace
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100113
BjornMagnussonXA007b6452021-11-29 08:03:38 +0100114set_ics_trace
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100115
BjornMagnussonXAce4b14c2021-05-11 15:40:03 +0200116use_info_jobs=false #Set flag if interface supporting info-types is used
BjornMagnussonXA007b6452021-11-29 08:03:38 +0100117if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
BjornMagnussonXAce4b14c2021-05-11 15:40:03 +0200118 use_info_jobs=true
119fi
120
BjornMagnussonXAde4d0f82020-11-29 16:04:06 +0100121rapp_cat_api_get_services 200 EMPTY
122
123rapp_cat_api_put_service 201 "Emergency-response-app" v1 "Emergency-response-app" "Emergency-response-app"
124
125rapp_cat_api_get_services 200 "Emergency-response-app" v1 "Emergency-response-app" "Emergency-response-app"
126
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100127a1pms_api_get_status 200
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100128
129# Print the A1 version for STD 2.X
130for ((i=1; i<=$STD_NUM_RICS; i++))
131do
132 sim_print $RIC_SIM_PREFIX"_g3_"$i interface
133done
134# Load the polictypes in std
135for ((i=1; i<=$STD_NUM_RICS; i++))
136do
137 sim_put_policy_type 201 $RIC_SIM_PREFIX"_g3_"$i STD_QOS_0_2_0 demo-testdata/STD2/sim_qos.json
138 sim_put_policy_type 201 $RIC_SIM_PREFIX"_g3_"$i STD_QOS2_0.1.0 demo-testdata/STD2/sim_qos2.json
139done
140
141#Check the number of schemas and the individual schemas in STD
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100142a1pms_equal json:policy-types 2 120
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100143
144for ((i=1; i<=$STD_NUM_RICS; i++))
145do
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100146 a1pms_equal json:policy-types?ric_id=$RIC_SIM_PREFIX"_g3_"$i 2 120
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100147done
148
149# Check the schemas in STD
150for ((i=1; i<=$STD_NUM_RICS; i++))
151do
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100152 a1pms_api_get_policy_type 200 STD_QOS_0_2_0 demo-testdata/STD2/qos-a1pms-modified.json
153 a1pms_api_get_policy_type 200 'STD_QOS2_0.1.0' demo-testdata/STD2/qos2-a1pms-modified.json
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100154done
155
156#Check the number of types
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100157a1pms_equal json:policy-types 2 300
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100158
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100159a1pms_api_put_service 201 "Emergency-response-app" 0 "$CR_SERVICE_APP_PATH_0/1"
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100160
161# Create policies in STD
162for ((i=1; i<=$STD_NUM_RICS; i++))
163do
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +0100164 generate_policy_uuid
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100165 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 +0100166 generate_policy_uuid
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100167 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
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100168done
169
170
171# Check the number of policies in STD
172for ((i=1; i<=$STD_NUM_RICS; i++))
173do
174 sim_equal $RIC_SIM_PREFIX"_g3_"$i num_instances 2
175done
176
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100177# Print calling hosts STD 2.X
178for ((i=1; i<=$STD_NUM_RICS; i++))
179do
180 sim_print $RIC_SIM_PREFIX"_g3_"$i remote_hosts
181done
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100182
183FLAT_A1_EI="1"
184
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100185CB_JOB="$PROD_STUB_SERVICE_PATH$PROD_STUB_JOB_CALLBACK"
186CB_SV="$PROD_STUB_SERVICE_PATH$PROD_STUB_SUPERVISION_CALLBACK"
187RIC_G1_1=$RIC_SIM_PREFIX"_g3_1"
188RIC_G1_2=$RIC_SIM_PREFIX"_g3_2"
189if [ $RUNMODE == "KUBE" ]; then
190 RIC_G1_1=$(get_kube_sim_host $RIC_G1_1)
191 RIC_G1_2=$(get_kube_sim_host $RIC_G1_2)
192fi
193TARGET1="$RIC_SIM_HTTPX://$RIC_G1_1:$RIC_SIM_PORT/datadelivery"
194TARGET2="$RIC_SIM_HTTPX://$RIC_G1_1:$RIC_SIM_PORT/datadelivery"
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100195
BjornMagnussonXA79e37002021-11-22 13:36:04 +0100196STATUS1="$CR_SERVICE_APP_PATH_0/callbacks/job1-status"
197STATUS2="$CR_SERVICE_APP_PATH_0/callbacks/job2-status"
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100198
199prodstub_arm_producer 200 prod-a
200prodstub_arm_type 200 prod-a type1
201prodstub_arm_job_create 200 prod-a job1
202prodstub_arm_job_create 200 prod-a job2
203
BjornMagnussonXA007b6452021-11-29 08:03:38 +0100204### ics status
205ics_api_service_status 200
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100206
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100207## Setup prod-a
BjornMagnussonXA007b6452021-11-29 08:03:38 +0100208if [ $ICS_VERSION == "V1-1" ]; then
209 ics_api_edp_put_producer 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ics/ei-type-1.json
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100210
BjornMagnussonXA007b6452021-11-29 08:03:38 +0100211 ics_api_edp_get_producer 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ics/ei-type-1.json
BjornMagnussonXA27db02f2021-01-19 08:13:00 +0100212else
BjornMagnussonXA007b6452021-11-29 08:03:38 +0100213 ics_api_edp_put_type_2 201 type1 testdata/ics/ei-type-1.json
BjornMagnussonXA27db02f2021-01-19 08:13:00 +0100214
BjornMagnussonXA007b6452021-11-29 08:03:38 +0100215 ics_api_edp_put_producer_2 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1
BjornMagnussonXA27db02f2021-01-19 08:13:00 +0100216
BjornMagnussonXA007b6452021-11-29 08:03:38 +0100217 ics_api_edp_get_producer_2 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1
BjornMagnussonXA27db02f2021-01-19 08:13:00 +0100218fi
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100219
BjornMagnussonXA007b6452021-11-29 08:03:38 +0100220ics_api_edp_get_producer_status 200 prod-a ENABLED
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100221
222
223## Create a job for prod-a
224## job1 - prod-a
225if [ -z "$FLAT_A1_EI" ]; then
BjornMagnussonXA007b6452021-11-29 08:03:38 +0100226 ics_api_a1_put_job 201 type1 job1 $TARGET1 ricsim_g3_1 testdata/ics/job-template.json
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100227else
BjornMagnussonXA007b6452021-11-29 08:03:38 +0100228 ics_api_a1_put_job 201 job1 type1 $TARGET1 ricsim_g3_1 $STATUS1 testdata/ics/job-template.json
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100229fi
230
231# Check the job data in the producer
BjornMagnussonXA007b6452021-11-29 08:03:38 +0100232if [ $ICS_VERSION == "V1-1" ]; then
233 prodstub_check_jobdata 200 prod-a job1 type1 $TARGET1 ricsim_g3_1 testdata/ics/job-template.json
BjornMagnussonXAc963b732021-01-20 14:24:13 +0100234else
BjornMagnussonXAce4b14c2021-05-11 15:40:03 +0200235 if [ $use_info_jobs ]; then
BjornMagnussonXA007b6452021-11-29 08:03:38 +0100236 prodstub_check_jobdata_3 200 prod-a job1 type1 $TARGET1 ricsim_g3_1 testdata/ics/job-template.json
BjornMagnussonXAce4b14c2021-05-11 15:40:03 +0200237 else
BjornMagnussonXA007b6452021-11-29 08:03:38 +0100238 prodstub_check_jobdata_2 200 prod-a job1 type1 $TARGET1 ricsim_g3_1 testdata/ics/job-template.json
BjornMagnussonXAce4b14c2021-05-11 15:40:03 +0200239 fi
BjornMagnussonXAc963b732021-01-20 14:24:13 +0100240fi
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100241
242
243## Create a second job for prod-a
244## job2 - prod-a
245if [ -z "$FLAT_A1_EI" ]; then
BjornMagnussonXA007b6452021-11-29 08:03:38 +0100246 ics_api_a1_put_job 201 type1 job2 $TARGET2 ricsim_g3_2 testdata/ics/job-template.json
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100247else
BjornMagnussonXA007b6452021-11-29 08:03:38 +0100248 ics_api_a1_put_job 201 job2 type1 $TARGET2 ricsim_g3_2 $STATUS2 testdata/ics/job-template.json
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100249fi
250
251# Check the job data in the producer
BjornMagnussonXA007b6452021-11-29 08:03:38 +0100252if [ $ICS_VERSION == "V1-1" ]; then
253 prodstub_check_jobdata 200 prod-a job2 type1 $TARGET2 ricsim_g3_2 testdata/ics/job-template.json
BjornMagnussonXAc963b732021-01-20 14:24:13 +0100254else
BjornMagnussonXAce4b14c2021-05-11 15:40:03 +0200255 if [ $use_info_jobs ]; then
BjornMagnussonXA007b6452021-11-29 08:03:38 +0100256 prodstub_check_jobdata_3 200 prod-a job2 type1 $TARGET2 ricsim_g3_2 testdata/ics/job-template.json
BjornMagnussonXAce4b14c2021-05-11 15:40:03 +0200257 else
BjornMagnussonXA007b6452021-11-29 08:03:38 +0100258 prodstub_check_jobdata_2 200 prod-a job2 type1 $TARGET2 ricsim_g3_2 testdata/ics/job-template.json
BjornMagnussonXAce4b14c2021-05-11 15:40:03 +0200259 fi
BjornMagnussonXAc963b732021-01-20 14:24:13 +0100260fi
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100261
BjornMagnussonXAd2aeca82022-03-07 11:04:55 +0100262check_a1pms_logs
BjornMagnussonXA007b6452021-11-29 08:03:38 +0100263check_ics_logs
BjornMagnussonXA7b36db62020-11-23 10:57:57 +0100264check_sdnc_logs
265
266#### TEST COMPLETE ####
267
268store_logs END
269
270print_result
BjornMagnussonXAbe9a07f2021-02-25 10:51:46 +0100271
272auto_clean_environment