blob: ca545b2e3a7e0e50665000686f7d95ce0d28049b [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
BjornMagnussonXAf38e1e82020-10-11 23:05:02 +020022#App names to include in the test, space separated list
23INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM"
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020024
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010025#SUPPORTED TEST ENV FILE
BjornMagnussonXAde4d0f82020-11-29 16:04:06 +010026SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-CHERRY"
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010027
BjornMagnussonXA80a92002020-03-19 14:31:06 +010028. ../common/testcase_common.sh $@
29. ../common/agent_api_functions.sh
BjornMagnussonXA72667f12020-04-24 09:20:18 +020030. ../common/ricsimulator_api_functions.sh
BjornMagnussonXA80a92002020-03-19 14:31:06 +010031
32#### TEST BEGIN ####
33
BjornMagnussonXAad047782020-06-08 15:54:11 +020034generate_uuid
35
BjornMagnussonXAbf3700b2020-10-05 08:39:40 +020036use_simulator_http
37use_mr_http
38use_agent_rest_http
39
BjornMagnussonXA80a92002020-03-19 14:31:06 +010040
41clean_containers
42
43start_ric_simulators ricsim_g1 3 OSC_2.1.0
44
45start_ric_simulators ricsim_g2 5 STD_1.1.3
46
BjornMagnussonXA4207b832020-11-03 09:52:49 +010047if [ "$PMS_VERSION" == "V2" ]; then
48 start_ric_simulators ricsim_g3 1 STD_2.0.0
49fi
50
BjornMagnussonXA80a92002020-03-19 14:31:06 +010051start_mr
52
BjornMagnussonXA80a92002020-03-19 14:31:06 +010053start_consul_cbs
54
55prepare_consul_config NOSDNC ".consul_config.json"
56consul_config_app ".consul_config.json"
57
58start_control_panel
59
BjornMagnussonXA80a92002020-03-19 14:31:06 +010060start_policy_agent
61
BjornMagnussonXA72667f12020-04-24 09:20:18 +020062set_agent_debug
63
64use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010065
66api_get_status 200
67
68sim_print ricsim_g1_1 interface
69
70sim_print ricsim_g2_1 interface
71
BjornMagnussonXA4207b832020-11-03 09:52:49 +010072if [ "$PMS_VERSION" == "V2" ]; then
73 sim_print ricsim_g3_1 interface
74fi
75
BjornMagnussonXA80a92002020-03-19 14:31:06 +010076sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
77
BjornMagnussonXA4207b832020-11-03 09:52:49 +010078if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA2791e082020-11-12 00:52:08 +010079 sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
80 api_equal json:policy-types 3 60
BjornMagnussonXA4207b832020-11-03 09:52:49 +010081else
82 api_equal json:policy_types 2 60
83fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +010084
85# Create policies
BjornMagnussonXA4207b832020-11-03 09:52:49 +010086
87if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010088 notificationurl=$CR_PATH"/test"
BjornMagnussonXA4207b832020-11-03 09:52:49 +010089else
90 notificationurl=""
91fi
92
BjornMagnussonXA72667f12020-04-24 09:20:18 +020093use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010094
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020095api_put_service 201 "service1" 3600 "$CR_PATH/1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +010096
BjornMagnussonXA4207b832020-11-03 09:52:49 +010097api_put_policy 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +010098
99sim_equal ricsim_g1_1 num_instances 1
100
101
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200102use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100103
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100104api_put_policy 201 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100105
106sim_equal ricsim_g1_1 num_instances 2
107
108
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200109use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100110
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100111api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100112
113sim_equal ricsim_g2_1 num_instances 1
114
115
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200116use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100117
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100118api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100119
120sim_equal ricsim_g2_1 num_instances 2
121
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100122if [ "$PMS_VERSION" == "V2" ]; then
123 use_agent_rest_http
124
125 api_put_policy 201 "service1" ricsim_g3_1 STD_QOS_0_2_0 2200 true $notificationurl testdata/STD2/pi_qos_template.json 1
126
127 sim_equal ricsim_g3_1 num_instances 1
128
129 use_agent_dmaap_http
130
131 api_put_policy 201 "service1" ricsim_g3_1 STD_QOS_0_2_0 3200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos_template.json 1
132
133 sim_equal ricsim_g3_1 num_instances 2
134
135fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100136
137#Update policies
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200138use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100139
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200140api_put_service 200 "service1" 3600 "$CR_PATH/1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100141
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100142api_put_policy 200 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100143
144sim_equal ricsim_g1_1 num_instances 2
145
146
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200147use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100148
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100149api_put_policy 200 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100150
151sim_equal ricsim_g1_1 num_instances 2
152
153
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200154use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100155
156
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100157api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100158
159sim_equal ricsim_g2_1 num_instances 2
160
161
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200162use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100163
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100164api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100165
166sim_equal ricsim_g2_1 num_instances 2
167
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100168if [ "$PMS_VERSION" == "V2" ]; then
169 use_agent_rest_http
170
171 api_put_policy 200 "service1" ricsim_g3_1 STD_QOS_0_2_0 2200 true $notificationurl testdata/STD2/pi_qos_template.json 1
172
173 sim_equal ricsim_g3_1 num_instances 2
174
175
176 use_agent_dmaap_http
177
178 api_put_policy 200 "service1" ricsim_g3_1 STD_QOS_0_2_0 3200 true $notificationurl testdata/STD2/pi_qos_template.json 1
179
180 sim_equal ricsim_g3_1 num_instances 2
181fi
182
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100183# Check policies
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100184if [ "$PMS_VERSION" == "V2" ]; then
185 api_get_policy 200 2000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
186 api_get_policy 200 3000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
187 api_get_policy 200 2100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
188 api_get_policy 200 3100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100189 api_get_policy 200 2200 testdata/STD2/pi_qos_template.json "service1" ricsim_g3_1 STD_QOS_0_2_0 true $notificationurl
190 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 +0100191else
192 api_get_policy 200 2000 testdata/OSC/pi1_template.json
193 api_get_policy 200 3000 testdata/OSC/pi1_template.json
194 api_get_policy 200 2100 testdata/STD/pi1_template.json
195 api_get_policy 200 3100 testdata/STD/pi1_template.json
196fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100197
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100198sim_equal ricsim_g1_1 num_instances 2
199sim_equal ricsim_g2_1 num_instances 2
200
201if [ "$PMS_VERSION" == "V2" ]; then
202 sim_equal ricsim_g3_1 num_instances 2
203fi
204
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100205# Remove policies
206
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200207use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100208api_delete_policy 204 2000
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200209use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100210api_delete_policy 204 3000
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200211use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100212api_delete_policy 204 2100
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200213use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100214api_delete_policy 204 3100
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100215if [ "$PMS_VERSION" == "V2" ]; then
216 use_agent_dmaap_http
217 api_delete_policy 204 2200
218 use_agent_rest_http
219 api_delete_policy 204 3200
220fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100221
222sim_equal ricsim_g1_1 num_instances 0
223sim_equal ricsim_g2_1 num_instances 0
224
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100225if [ "$PMS_VERSION" == "V2" ]; then
226 sim_equal ricsim_g3_1 num_instances 0
227fi
228
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200229# Check remote host access to simulator
230
ecaiyanlinuxc8ccab12020-06-09 13:29:53 +0200231sim_contains_str ricsim_g1_1 remote_hosts "policy-agent"
232sim_contains_str ricsim_g2_1 remote_hosts "policy-agent"
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100233if [ "$PMS_VERSION" == "V2" ]; then
234 sim_contains_str ricsim_g3_1 remote_hosts "policy-agent"
235fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200236
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100237# Check policy removal
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200238use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100239api_get_policy 404 2000
240api_get_policy 404 3000
241api_get_policy 404 2100
242api_get_policy 404 3100
243
BjornMagnussonXA2791e082020-11-12 00:52:08 +0100244if [ "$PMS_VERSION" == "V2" ]; then
245 api_get_policy 404 2200
246 api_get_policy 404 3200
247fi
248
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100249# Remove the service
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200250use_agent_dmaap_http
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200251api_delete_services 204 "service1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100252
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200253api_get_services 404 "service1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100254
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100255check_policy_agent_logs
256
257#### TEST COMPLETE ####
258
259store_logs END
260
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200261print_result
262
263auto_clean_containers