e7065d6d86138e90d537dd947b56db725db06a27
[nonrtric.git] / test / auto-test / FTC10.sh
1 #!/bin/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
20 TC_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"
21
22 #App names to include in the test when running docker, space separated list
23 DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR A1PMS RICSIM NGW KUBEPROXY"
24
25 #App names to include in the test when running kubernetes, space separated list
26 KUBE_INCLUDED_IMAGES=" MR CR A1PMS RICSIM CP KUBEPROXY NGW"
27 #Prestarted app (not started by script) to include in the test when running kubernetes, space separated list
28 KUBE_PRESTARTED_IMAGES=""
29
30 #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
33 CONDITIONALLY_IGNORED_IMAGES="CBS CONSUL NGW"
34
35 #Supported test environment profiles
36 SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ONAP-ISTANBUL ONAP-JAKARTA ONAP-KOHN ORAN-CHERRY ORAN-D-RELEASE ORAN-E-RELEASE ORAN-F-RELEASE ORAN-G-RELEASE"
37 #Supported run modes
38 SUPPORTED_RUNMODES="DOCKER KUBE"
39
40 . ../common/testcase_common.sh $@
41
42 setup_testenvironment
43
44 #### TEST BEGIN ####
45
46 generate_policy_uuid
47
48 use_simulator_http
49 use_mr_http
50 use_a1pms_rest_http
51
52
53 clean_environment
54
55 start_kube_proxy
56
57 start_ric_simulators  ricsim_g1 3 OSC_2.1.0
58
59 start_ric_simulators  ricsim_g2 5 STD_1.1.3
60
61 if [ "$A1PMS_VERSION" == "V2" ]; then
62     start_ric_simulators ricsim_g3 1  STD_2.0.0
63 fi
64
65 start_mr
66
67 start_cr 1
68
69 if [ $RUNMODE == "DOCKER" ]; then
70     if [[ "$A1PMS_FEATURE_LEVEL" != *"NOCONSUL"* ]]; then
71         start_consul_cbs
72     fi
73 fi
74
75 start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
76
77 if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
78     start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
79 fi
80
81 start_a1pms NORPOXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
82
83 set_a1pms_debug
84
85 use_a1pms_rest_http
86
87 __CONFIG_HEADER="NOHEADER"
88 if [ $RUNMODE == "KUBE" ]; then
89     __CONFIG_HEADER="HEADER"
90 else
91     if [[ "$A1PMS_FEATURE_LEVEL" == *"NOCONSUL"* ]]; then
92         __CONFIG_HEADER="HEADER"
93     fi
94 fi
95 prepare_consul_config      NOSDNC  ".consul_config.json" $__CONFIG_HEADER
96
97 if [ $RUNMODE == "KUBE" ]; then
98     a1pms_load_config                       ".consul_config.json"
99 else
100     if [[ "$A1PMS_FEATURE_LEVEL" == *"NOCONSUL"* ]]; then
101         a1pms_api_put_configuration 200 ".consul_config.json"
102     else
103         consul_config_app                   ".consul_config.json"
104     fi
105 fi
106
107 sleep_wait 120 "Let A1PMS cofiguration take effect"
108
109 a1pms_api_get_status 200
110
111 sim_print ricsim_g1_1 interface
112
113 sim_print ricsim_g2_1 interface
114
115 if [ "$A1PMS_VERSION" == "V2" ]; then
116     sim_print ricsim_g3_1 interface
117 fi
118
119 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
120
121 if [ "$A1PMS_VERSION" == "V2" ]; then
122     sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
123     a1pms_equal json:policy-types 3 300
124 else
125     a1pms_equal json:policy_types 2 300
126 fi
127
128 # Create policies
129
130 if [ "$A1PMS_VERSION" == "V2" ]; then
131     notificationurl=$CR_SERVICE_APP_PATH_0"/test"
132 else
133     notificationurl=""
134 fi
135
136 use_a1pms_rest_http
137
138 a1pms_api_put_service 201 "service1" 3600 "$CR_SERVICE_APP_PATH_0/1"
139
140 a1pms_api_put_policy 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
141
142 sim_equal ricsim_g1_1 num_instances 1
143
144
145 use_a1pms_dmaap_http
146
147 a1pms_api_put_policy 201 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
148
149 sim_equal ricsim_g1_1 num_instances 2
150
151
152 use_a1pms_rest_http
153
154 a1pms_api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
155
156 sim_equal ricsim_g2_1 num_instances 1
157
158
159 use_a1pms_dmaap_http
160
161 a1pms_api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
162
163 sim_equal ricsim_g2_1 num_instances 2
164
165 if [ "$A1PMS_VERSION" == "V2" ]; then
166     use_a1pms_rest_http
167
168     a1pms_api_put_policy 201 "service1" ricsim_g3_1 STD_QOS_0_2_0 2200 true $notificationurl testdata/STD2/pi_qos_template.json 1
169
170     sim_equal ricsim_g3_1 num_instances 1
171
172     use_a1pms_dmaap_http
173
174     a1pms_api_put_policy 201 "service1" ricsim_g3_1 STD_QOS_0_2_0 3200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos_template.json 1
175
176     sim_equal ricsim_g3_1 num_instances 2
177
178 fi
179
180 #Update policies
181 use_a1pms_rest_http
182
183 a1pms_api_put_service 200 "service1" 3600 "$CR_SERVICE_APP_PATH_0/1"
184
185 a1pms_api_put_policy 200 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
186
187 sim_equal ricsim_g1_1 num_instances 2
188
189
190 use_a1pms_dmaap_http
191
192 a1pms_api_put_policy 200 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
193
194 sim_equal ricsim_g1_1 num_instances 2
195
196
197 use_a1pms_rest_http
198
199
200 a1pms_api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
201
202 sim_equal ricsim_g2_1 num_instances 2
203
204
205 use_a1pms_dmaap_http
206
207 a1pms_api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
208
209 sim_equal ricsim_g2_1 num_instances 2
210
211 if [ "$A1PMS_VERSION" == "V2" ]; then
212     use_a1pms_rest_http
213
214     a1pms_api_put_policy 200 "service1" ricsim_g3_1 STD_QOS_0_2_0 2200 true $notificationurl testdata/STD2/pi_qos_template.json 1
215
216     sim_equal ricsim_g3_1 num_instances 2
217
218
219     use_a1pms_dmaap_http
220
221     a1pms_api_put_policy 200 "service1" ricsim_g3_1 STD_QOS_0_2_0 3200 true $notificationurl testdata/STD2/pi_qos_template.json 1
222
223     sim_equal ricsim_g3_1 num_instances 2
224 fi
225
226 # Check policies
227 if [ "$A1PMS_VERSION" == "V2" ]; then
228     a1pms_api_get_policy 200 2000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
229     a1pms_api_get_policy 200 3000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
230     a1pms_api_get_policy 200 2100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
231     a1pms_api_get_policy 200 3100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
232     a1pms_api_get_policy 200 2200 testdata/STD2/pi_qos_template.json "service1" ricsim_g3_1 STD_QOS_0_2_0 true $notificationurl
233     a1pms_api_get_policy 200 3200 testdata/STD2/pi_qos_template.json "service1" ricsim_g3_1 STD_QOS_0_2_0 true $notificationurl
234 else
235     a1pms_api_get_policy 200 2000 testdata/OSC/pi1_template.json
236     a1pms_api_get_policy 200 3000 testdata/OSC/pi1_template.json
237     a1pms_api_get_policy 200 2100 testdata/STD/pi1_template.json
238     a1pms_api_get_policy 200 3100 testdata/STD/pi1_template.json
239 fi
240
241 sim_equal ricsim_g1_1 num_instances 2
242 sim_equal ricsim_g2_1 num_instances 2
243
244 if [ "$A1PMS_VERSION" == "V2" ]; then
245     sim_equal ricsim_g3_1 num_instances 2
246 fi
247
248 # Remove policies
249
250 use_a1pms_dmaap_http
251 a1pms_api_delete_policy 204 2000
252 use_a1pms_rest_http
253 a1pms_api_delete_policy 204 3000
254 use_a1pms_dmaap_http
255 a1pms_api_delete_policy 204 2100
256 use_a1pms_rest_http
257 a1pms_api_delete_policy 204 3100
258 if [ "$A1PMS_VERSION" == "V2" ]; then
259     use_a1pms_dmaap_http
260     a1pms_api_delete_policy 204 2200
261     use_a1pms_rest_http
262     a1pms_api_delete_policy 204 3200
263 fi
264
265 sim_equal ricsim_g1_1 num_instances 0
266 sim_equal ricsim_g2_1 num_instances 0
267
268 if [ "$A1PMS_VERSION" == "V2" ]; then
269     sim_equal ricsim_g3_1 num_instances 0
270 fi
271
272 # Check remote host access to simulator
273
274 sim_contains_str ricsim_g1_1 remote_hosts $A1PMS_APP_NAME
275 sim_contains_str ricsim_g2_1 remote_hosts $A1PMS_APP_NAME
276 if [ "$A1PMS_VERSION" == "V2" ]; then
277     sim_contains_str ricsim_g3_1 remote_hosts $A1PMS_APP_NAME
278 fi
279
280 # Check policy removal
281 use_a1pms_rest_http
282 a1pms_api_get_policy 404 2000
283 a1pms_api_get_policy 404 3000
284 a1pms_api_get_policy 404 2100
285 a1pms_api_get_policy 404 3100
286
287 if [ "$A1PMS_VERSION" == "V2" ]; then
288     a1pms_api_get_policy 404 2200
289     a1pms_api_get_policy 404 3200
290 fi
291
292 # Remove the service
293 use_a1pms_dmaap_http
294 a1pms_api_delete_services 204 "service1"
295
296 a1pms_api_get_services 404 "service1"
297
298 check_a1pms_logs
299
300 #### TEST COMPLETE ####
301
302 store_logs          END
303
304 print_result
305
306 auto_clean_environment