blob: 01ba86f83c2175db09c313d441e6aa7d067df654 [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
23DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM"
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
26KUBE_INCLUDED_IMAGES=" MR CR PA RICSIM CP"
27#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list
28KUBE_PRESTARTED_IMAGES=""
29
30#Supported test environment profiles
BjornMagnussonXA89b64ab2020-12-16 09:21:01 +010031SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN"
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010032#Supported run modes
33SUPPORTED_RUNMODES="DOCKER KUBE"
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010034
BjornMagnussonXA80a92002020-03-19 14:31:06 +010035. ../common/testcase_common.sh $@
36. ../common/agent_api_functions.sh
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010037. ../common/consul_cbs_functions.sh
38. ../common/control_panel_api_functions.sh
39. ../common/controller_api_functions.sh
40. ../common/cr_api_functions.sh
41. ../common/mr_api_functions.sh
BjornMagnussonXA72667f12020-04-24 09:20:18 +020042. ../common/ricsimulator_api_functions.sh
BjornMagnussonXA80a92002020-03-19 14:31:06 +010043
44#### TEST BEGIN ####
45
BjornMagnussonXAad047782020-06-08 15:54:11 +020046generate_uuid
47
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
55start_ric_simulators ricsim_g1 3 OSC_2.1.0
56
57start_ric_simulators ricsim_g2 5 STD_1.1.3
58
BjornMagnussonXA4207b832020-11-03 09:52:49 +010059if [ "$PMS_VERSION" == "V2" ]; then
60 start_ric_simulators ricsim_g3 1 STD_2.0.0
61fi
62
BjornMagnussonXA80a92002020-03-19 14:31:06 +010063start_mr
64
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010065start_cr
BjornMagnussonXA80a92002020-03-19 14:31:06 +010066
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010067if [ $RUNMODE == "DOCKER" ]; then
68 start_consul_cbs
69fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +010070
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010071start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/application.properties
BjornMagnussonXA80a92002020-03-19 14:31:06 +010072
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010073start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/application.yaml
BjornMagnussonXA80a92002020-03-19 14:31:06 +010074
BjornMagnussonXA72667f12020-04-24 09:20:18 +020075set_agent_debug
76
77use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010078
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +010079prepare_consul_config NOSDNC ".consul_config.json"
80
81if [ $RUNMODE == "KUBE" ]; then
82 agent_load_config ".consul_config.json"
83else
84 consul_config_app ".consul_config.json"
85fi
86
BjornMagnussonXA80a92002020-03-19 14:31:06 +010087api_get_status 200
88
89sim_print ricsim_g1_1 interface
90
91sim_print ricsim_g2_1 interface
92
BjornMagnussonXA4207b832020-11-03 09:52:49 +010093if [ "$PMS_VERSION" == "V2" ]; then
94 sim_print ricsim_g3_1 interface
95fi
96
BjornMagnussonXA80a92002020-03-19 14:31:06 +010097sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
98
BjornMagnussonXA4207b832020-11-03 09:52:49 +010099if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100100 sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100101 api_equal json:policy-types 3 300
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100102else
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100103 api_equal json:policy_types 2 300
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100104fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100105
106# Create policies
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100107
108if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100109 notificationurl=$CR_SERVICE_PATH"/test"
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100110else
111 notificationurl=""
112fi
113
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200114use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100115
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100116api_put_service 201 "service1" 3600 "$CR_SERVICE_PATH/1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100117
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100118api_put_policy 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100119
120sim_equal ricsim_g1_1 num_instances 1
121
122
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200123use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100124
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100125api_put_policy 201 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100126
127sim_equal ricsim_g1_1 num_instances 2
128
129
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200130use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100131
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100132api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100133
134sim_equal ricsim_g2_1 num_instances 1
135
136
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200137use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100138
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100139api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100140
141sim_equal ricsim_g2_1 num_instances 2
142
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100143if [ "$PMS_VERSION" == "V2" ]; then
144 use_agent_rest_http
145
146 api_put_policy 201 "service1" ricsim_g3_1 STD_QOS_0_2_0 2200 true $notificationurl testdata/STD2/pi_qos_template.json 1
147
148 sim_equal ricsim_g3_1 num_instances 1
149
150 use_agent_dmaap_http
151
152 api_put_policy 201 "service1" ricsim_g3_1 STD_QOS_0_2_0 3200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos_template.json 1
153
154 sim_equal ricsim_g3_1 num_instances 2
155
156fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100157
158#Update policies
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200159use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100160
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100161api_put_service 200 "service1" 3600 "$CR_SERVICE_PATH/1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100162
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100163api_put_policy 200 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100164
165sim_equal ricsim_g1_1 num_instances 2
166
167
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200168use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100169
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100170api_put_policy 200 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100171
172sim_equal ricsim_g1_1 num_instances 2
173
174
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200175use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100176
177
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100178api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100179
180sim_equal ricsim_g2_1 num_instances 2
181
182
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200183use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100184
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100185api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100186
187sim_equal ricsim_g2_1 num_instances 2
188
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100189if [ "$PMS_VERSION" == "V2" ]; then
190 use_agent_rest_http
191
192 api_put_policy 200 "service1" ricsim_g3_1 STD_QOS_0_2_0 2200 true $notificationurl testdata/STD2/pi_qos_template.json 1
193
194 sim_equal ricsim_g3_1 num_instances 2
195
196
197 use_agent_dmaap_http
198
199 api_put_policy 200 "service1" ricsim_g3_1 STD_QOS_0_2_0 3200 true $notificationurl testdata/STD2/pi_qos_template.json 1
200
201 sim_equal ricsim_g3_1 num_instances 2
202fi
203
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100204# Check policies
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100205if [ "$PMS_VERSION" == "V2" ]; then
206 api_get_policy 200 2000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
207 api_get_policy 200 3000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
208 api_get_policy 200 2100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
209 api_get_policy 200 3100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100210 api_get_policy 200 2200 testdata/STD2/pi_qos_template.json "service1" ricsim_g3_1 STD_QOS_0_2_0 true $notificationurl
211 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 +0100212else
213 api_get_policy 200 2000 testdata/OSC/pi1_template.json
214 api_get_policy 200 3000 testdata/OSC/pi1_template.json
215 api_get_policy 200 2100 testdata/STD/pi1_template.json
216 api_get_policy 200 3100 testdata/STD/pi1_template.json
217fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100218
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100219sim_equal ricsim_g1_1 num_instances 2
220sim_equal ricsim_g2_1 num_instances 2
221
222if [ "$PMS_VERSION" == "V2" ]; then
223 sim_equal ricsim_g3_1 num_instances 2
224fi
225
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100226# Remove policies
227
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200228use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100229api_delete_policy 204 2000
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200230use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100231api_delete_policy 204 3000
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200232use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100233api_delete_policy 204 2100
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200234use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100235api_delete_policy 204 3100
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100236if [ "$PMS_VERSION" == "V2" ]; then
237 use_agent_dmaap_http
238 api_delete_policy 204 2200
239 use_agent_rest_http
240 api_delete_policy 204 3200
241fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100242
243sim_equal ricsim_g1_1 num_instances 0
244sim_equal ricsim_g2_1 num_instances 0
245
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100246if [ "$PMS_VERSION" == "V2" ]; then
247 sim_equal ricsim_g3_1 num_instances 0
248fi
249
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200250# Check remote host access to simulator
251
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100252sim_contains_str ricsim_g1_1 remote_hosts $POLICY_AGENT_APP_NAME
253sim_contains_str ricsim_g2_1 remote_hosts $POLICY_AGENT_APP_NAME
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100254if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100255 sim_contains_str ricsim_g3_1 remote_hosts $POLICY_AGENT_APP_NAME
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100256fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200257
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100258# Check policy removal
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200259use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100260api_get_policy 404 2000
261api_get_policy 404 3000
262api_get_policy 404 2100
263api_get_policy 404 3100
264
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100265if [ "$PMS_VERSION" == "V2" ]; then
266 api_get_policy 404 2200
267 api_get_policy 404 3200
268fi
269
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100270# Remove the service
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200271use_agent_dmaap_http
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200272api_delete_services 204 "service1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100273
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200274api_get_services 404 "service1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100275
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100276check_policy_agent_logs
277
278#### TEST COMPLETE ####
279
280store_logs END
281
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200282print_result
283
BjornMagnussonXAe0b665e2021-01-08 22:19:18 +0100284auto_clean_environment