Merge "First version link failure use case"
[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 PA RICSIM NGW"
24
25 #App names to include in the test when running kubernetes, space separated list
26 KUBE_INCLUDED_IMAGES=" MR CR PA 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="NGW"
34
35 #Supported test environment profiles
36 SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ONAP-ISTANBUL ORAN-CHERRY ORAN-DAWN"
37 #Supported run modes
38 SUPPORTED_RUNMODES="DOCKER KUBE"
39
40 . ../common/testcase_common.sh $@
41 . ../common/agent_api_functions.sh
42 . ../common/consul_cbs_functions.sh
43 . ../common/control_panel_api_functions.sh
44 . ../common/controller_api_functions.sh
45 . ../common/cr_api_functions.sh
46 . ../common/mr_api_functions.sh
47 . ../common/ricsimulator_api_functions.sh
48 . ../common/kube_proxy_api_functions.sh
49 . ../common/gateway_api_functions.sh
50
51 setup_testenvironment
52
53 #### TEST BEGIN ####
54
55 generate_policy_uuid
56
57 use_simulator_http
58 use_mr_http
59 use_agent_rest_http
60
61
62 clean_environment
63
64 if [ $RUNMODE == "KUBE" ]; then
65     start_kube_proxy
66 fi
67
68 start_ric_simulators  ricsim_g1 3 OSC_2.1.0
69
70 start_ric_simulators  ricsim_g2 5 STD_1.1.3
71
72 if [ "$PMS_VERSION" == "V2" ]; then
73     start_ric_simulators ricsim_g3 1  STD_2.0.0
74 fi
75
76 start_mr
77
78 start_cr
79
80 if [ $RUNMODE == "DOCKER" ]; then
81     start_consul_cbs
82 fi
83
84 start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
85
86 if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
87     start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
88 fi
89
90 start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/$POLICY_AGENT_CONFIG_FILE
91
92 set_agent_debug
93
94 use_agent_rest_http
95
96 prepare_consul_config      NOSDNC  ".consul_config.json"
97
98 if [ $RUNMODE == "KUBE" ]; then
99     agent_load_config                       ".consul_config.json"
100 else
101     consul_config_app                      ".consul_config.json"
102 fi
103
104 api_get_status 200
105
106 sim_print ricsim_g1_1 interface
107
108 sim_print ricsim_g2_1 interface
109
110 if [ "$PMS_VERSION" == "V2" ]; then
111     sim_print ricsim_g3_1 interface
112 fi
113
114 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
115
116 if [ "$PMS_VERSION" == "V2" ]; then
117     sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
118     api_equal json:policy-types 3 300
119 else
120     api_equal json:policy_types 2 300
121 fi
122
123 # Create policies
124
125 if [ "$PMS_VERSION" == "V2" ]; then
126     notificationurl=$CR_SERVICE_PATH"/test"
127 else
128     notificationurl=""
129 fi
130
131 use_agent_rest_http
132
133 api_put_service 201 "service1" 3600 "$CR_SERVICE_PATH/1"
134
135 api_put_policy 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
136
137 sim_equal ricsim_g1_1 num_instances 1
138
139
140 use_agent_dmaap_http
141
142 api_put_policy 201 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
143
144 sim_equal ricsim_g1_1 num_instances 2
145
146
147 use_agent_rest_http
148
149 api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
150
151 sim_equal ricsim_g2_1 num_instances 1
152
153
154 use_agent_dmaap_http
155
156 api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
157
158 sim_equal ricsim_g2_1 num_instances 2
159
160 if [ "$PMS_VERSION" == "V2" ]; then
161     use_agent_rest_http
162
163     api_put_policy 201 "service1" ricsim_g3_1 STD_QOS_0_2_0 2200 true $notificationurl testdata/STD2/pi_qos_template.json 1
164
165     sim_equal ricsim_g3_1 num_instances 1
166
167     use_agent_dmaap_http
168
169     api_put_policy 201 "service1" ricsim_g3_1 STD_QOS_0_2_0 3200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos_template.json 1
170
171     sim_equal ricsim_g3_1 num_instances 2
172
173 fi
174
175 #Update policies
176 use_agent_rest_http
177
178 api_put_service 200 "service1" 3600 "$CR_SERVICE_PATH/1"
179
180 api_put_policy 200 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
181
182 sim_equal ricsim_g1_1 num_instances 2
183
184
185 use_agent_dmaap_http
186
187 api_put_policy 200 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
188
189 sim_equal ricsim_g1_1 num_instances 2
190
191
192 use_agent_rest_http
193
194
195 api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
196
197 sim_equal ricsim_g2_1 num_instances 2
198
199
200 use_agent_dmaap_http
201
202 api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
203
204 sim_equal ricsim_g2_1 num_instances 2
205
206 if [ "$PMS_VERSION" == "V2" ]; then
207     use_agent_rest_http
208
209     api_put_policy 200 "service1" ricsim_g3_1 STD_QOS_0_2_0 2200 true $notificationurl testdata/STD2/pi_qos_template.json 1
210
211     sim_equal ricsim_g3_1 num_instances 2
212
213
214     use_agent_dmaap_http
215
216     api_put_policy 200 "service1" ricsim_g3_1 STD_QOS_0_2_0 3200 true $notificationurl testdata/STD2/pi_qos_template.json 1
217
218     sim_equal ricsim_g3_1 num_instances 2
219 fi
220
221 # Check policies
222 if [ "$PMS_VERSION" == "V2" ]; then
223     api_get_policy 200 2000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
224     api_get_policy 200 3000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
225     api_get_policy 200 2100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
226     api_get_policy 200 3100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
227     api_get_policy 200 2200 testdata/STD2/pi_qos_template.json "service1" ricsim_g3_1 STD_QOS_0_2_0 true $notificationurl
228     api_get_policy 200 3200 testdata/STD2/pi_qos_template.json "service1" ricsim_g3_1 STD_QOS_0_2_0 true $notificationurl
229 else
230     api_get_policy 200 2000 testdata/OSC/pi1_template.json
231     api_get_policy 200 3000 testdata/OSC/pi1_template.json
232     api_get_policy 200 2100 testdata/STD/pi1_template.json
233     api_get_policy 200 3100 testdata/STD/pi1_template.json
234 fi
235
236 sim_equal ricsim_g1_1 num_instances 2
237 sim_equal ricsim_g2_1 num_instances 2
238
239 if [ "$PMS_VERSION" == "V2" ]; then
240     sim_equal ricsim_g3_1 num_instances 2
241 fi
242
243 # Remove policies
244
245 use_agent_dmaap_http
246 api_delete_policy 204 2000
247 use_agent_rest_http
248 api_delete_policy 204 3000
249 use_agent_dmaap_http
250 api_delete_policy 204 2100
251 use_agent_rest_http
252 api_delete_policy 204 3100
253 if [ "$PMS_VERSION" == "V2" ]; then
254     use_agent_dmaap_http
255     api_delete_policy 204 2200
256     use_agent_rest_http
257     api_delete_policy 204 3200
258 fi
259
260 sim_equal ricsim_g1_1 num_instances 0
261 sim_equal ricsim_g2_1 num_instances 0
262
263 if [ "$PMS_VERSION" == "V2" ]; then
264     sim_equal ricsim_g3_1 num_instances 0
265 fi
266
267 # Check remote host access to simulator
268
269 sim_contains_str ricsim_g1_1 remote_hosts $POLICY_AGENT_APP_NAME
270 sim_contains_str ricsim_g2_1 remote_hosts $POLICY_AGENT_APP_NAME
271 if [ "$PMS_VERSION" == "V2" ]; then
272     sim_contains_str ricsim_g3_1 remote_hosts $POLICY_AGENT_APP_NAME
273 fi
274
275 # Check policy removal
276 use_agent_rest_http
277 api_get_policy 404 2000
278 api_get_policy 404 3000
279 api_get_policy 404 2100
280 api_get_policy 404 3100
281
282 if [ "$PMS_VERSION" == "V2" ]; then
283     api_get_policy 404 2200
284     api_get_policy 404 3200
285 fi
286
287 # Remove the service
288 use_agent_dmaap_http
289 api_delete_services 204 "service1"
290
291 api_get_services 404 "service1"
292
293 check_policy_agent_logs
294
295 #### TEST COMPLETE ####
296
297 store_logs          END
298
299 print_result
300
301 auto_clean_environment