blob: ee57b62a777d324422327641521a3875130290f5 [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
26SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-MASTER"
27
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
79 api_equal json:policy-types 2 60
80else
81 api_equal json:policy_types 2 60
82fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +010083
84# Create policies
BjornMagnussonXA4207b832020-11-03 09:52:49 +010085
86if [ "$PMS_VERSION" == "V2" ]; then
BjornMagnussonXA49f0e5a2020-11-08 22:41:39 +010087 notificationurl=$CR_PATH"/test"
BjornMagnussonXA4207b832020-11-03 09:52:49 +010088else
89 notificationurl=""
90fi
91
BjornMagnussonXA72667f12020-04-24 09:20:18 +020092use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +010093
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020094api_put_service 201 "service1" 3600 "$CR_PATH/1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +010095
BjornMagnussonXA4207b832020-11-03 09:52:49 +010096api_put_policy 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +010097
98sim_equal ricsim_g1_1 num_instances 1
99
100
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200101use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100102
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100103api_put_policy 201 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100104
105sim_equal ricsim_g1_1 num_instances 2
106
107
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200108use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100109
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100110api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100111
112sim_equal ricsim_g2_1 num_instances 1
113
114
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200115use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100116
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100117api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100118
119sim_equal ricsim_g2_1 num_instances 2
120
121
122#Update policies
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200123use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100124
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200125api_put_service 200 "service1" 3600 "$CR_PATH/1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100126
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100127api_put_policy 200 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100128
129sim_equal ricsim_g1_1 num_instances 2
130
131
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200132use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100133
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100134api_put_policy 200 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100135
136sim_equal ricsim_g1_1 num_instances 2
137
138
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200139use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100140
141
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100142api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100143
144sim_equal ricsim_g2_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_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100150
151sim_equal ricsim_g2_1 num_instances 2
152
153# Check policies
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100154if [ "$PMS_VERSION" == "V2" ]; then
155 api_get_policy 200 2000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
156 api_get_policy 200 3000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
157 api_get_policy 200 2100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
158 api_get_policy 200 3100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
159else
160 api_get_policy 200 2000 testdata/OSC/pi1_template.json
161 api_get_policy 200 3000 testdata/OSC/pi1_template.json
162 api_get_policy 200 2100 testdata/STD/pi1_template.json
163 api_get_policy 200 3100 testdata/STD/pi1_template.json
164fi
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100165
166# Remove policies
167
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200168use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100169api_delete_policy 204 2000
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200170use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100171api_delete_policy 204 3000
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200172use_agent_dmaap_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100173api_delete_policy 204 2100
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200174use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100175api_delete_policy 204 3100
176
177sim_equal ricsim_g1_1 num_instances 0
178sim_equal ricsim_g2_1 num_instances 0
179
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100180if [ "$PMS_VERSION" == "V2" ]; then
181 sim_equal ricsim_g3_1 num_instances 0
182fi
183
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200184# Check remote host access to simulator
185
ecaiyanlinuxc8ccab12020-06-09 13:29:53 +0200186sim_contains_str ricsim_g1_1 remote_hosts "policy-agent"
187sim_contains_str ricsim_g2_1 remote_hosts "policy-agent"
BjornMagnussonXA4207b832020-11-03 09:52:49 +0100188if [ "$PMS_VERSION" == "V2" ]; then
189 sim_contains_str ricsim_g3_1 remote_hosts "policy-agent"
190fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200191
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100192# Check policy removal
BjornMagnussonXA72667f12020-04-24 09:20:18 +0200193use_agent_rest_http
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100194api_get_policy 404 2000
195api_get_policy 404 3000
196api_get_policy 404 2100
197api_get_policy 404 3100
198
199# Remove the service
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200200use_agent_dmaap_http
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200201api_delete_services 204 "service1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100202
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200203api_get_services 404 "service1"
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100204
BjornMagnussonXA80a92002020-03-19 14:31:06 +0100205check_policy_agent_logs
206
207#### TEST COMPLETE ####
208
209store_logs END
210
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200211print_result
212
213auto_clean_containers