Merge "NONRTRIC - Implement DMaaP mediator producer service in Java"
[nonrtric.git] / test / auto-test / FTC_HELM_E_RELEASE.sh
1 #!/usr/bin/env 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="Sanity test of Non-RT RIC Helm chats - all components - E-RELEASE"
21 # This script requires the helm charts for nonrtric, a1simulator and a1controller are installed
22 # There should be 2 simulator of version started
23
24 #App names to include in the test when running docker, space separated list
25 DOCKER_INCLUDED_IMAGES="" # Not used -  KUBE only test script
26
27 #App names to include in the test when running kubernetes, space separated list
28 KUBE_INCLUDED_IMAGES=" MR CR  PRODSTUB KUBEPROXY"
29 #Prestarted app (not started by script) to include in the test when running kubernetes, space separated list
30 KUBE_PRESTARTED_IMAGES=" PA RICSIM CP ECS RC SDNC DMAAPMED DMAAPADP"
31
32 #Supported test environment profiles
33 SUPPORTED_PROFILES="ORAN-E-RELEASE"
34 #Supported run modes
35 SUPPORTED_RUNMODES="KUBE"
36
37 . ../common/testcase_common.sh $@
38 . ../common/agent_api_functions.sh
39 . ../common/ricsimulator_api_functions.sh
40 . ../common/ecs_api_functions.sh
41 . ../common/prodstub_api_functions.sh
42 . ../common/cr_api_functions.sh
43 . ../common/rapp_catalogue_api_functions.sh
44 . ../common/mr_api_functions.sh
45 . ../common/control_panel_api_functions.sh
46 . ../common/controller_api_functions.sh
47 . ../common/kube_proxy_api_functions.sh
48 . ../common/dmaapmed_api_functions.sh
49 . ../common/dmaapadp_api_functions.sh
50
51 setup_testenvironment
52
53 #### TEST BEGIN ####
54
55 use_mr_http       #MR only supports http?
56 use_cr_https
57 use_agent_rest_https
58 use_sdnc_https
59 use_simulator_https
60 use_ecs_rest_https
61 use_prod_stub_https
62
63 if [ $ECS_VERSION == "V1-1" ]; then
64     use_rapp_catalogue_http # https not yet supported
65 else
66     ########################################use_rapp_catalogue_https
67     use_rapp_catalogue_http
68 fi
69
70 echo -e "$RED CHECK WHY RC HTTPS DOES NOT WORK $ERED"
71
72 ###############################use_control_panel_https
73 use_control_panel_http
74
75 if [ "$PMS_VERSION" == "V1" ]; then
76    echo "PMS VERSION 2 (V2) is required"
77    exit 1
78 fi
79
80 clean_environment
81
82 pms_kube_pvc_reset
83
84 ecs_kube_pvc_reset
85
86 start_kube_proxy
87
88 STD_NUM_RICS=2
89 OSC_NUM_RICS=2
90
91 start_ric_simulators a1-sim-osc $STD_NUM_RICS OSC_2.1.0
92 echo " RIC MAPPING a1-sim-osc-0 : ric1"
93 echo " RIC MAPPING a1-sim-osc-1 : ric2"
94
95 start_ric_simulators a1-sim-std $STD_NUM_RICS STD_1.1.3
96 echo " RIC MAPPING a1-sim-std-0 : ric3"
97 echo " RIC MAPPING a1-sim-std-1 : ric4"
98
99 start_ric_simulators a1-sim-std2 $STD_NUM_RICS STD_2.0.0
100 echo " RIC MAPPING a1-sim-std2-0 : ric5"
101 echo " RIC MAPPING a1-sim-std2-1 : ric6"
102
103 start_mr
104
105 start_control_panel
106
107 start_sdnc
108
109 start_policy_agent
110
111 start_cr
112
113 start_prod_stub
114
115 start_ecs NOPROXY
116
117 set_ecs_trace
118
119 start_rapp_catalogue
120
121 set_agent_trace
122
123 #### Test RAPP Catalogue ####
124
125 rapp_cat_api_get_services 200 EMPTY
126
127 rapp_cat_api_put_service 201 "Emergency-response-app" v1 "Emergency-response-app" "Emergency-response-app"
128
129 rapp_cat_api_get_services 200 "Emergency-response-app" v1 "Emergency-response-app" "Emergency-response-app"
130
131 #Check the number of services
132 rc_equal json:services 1
133
134 api_get_status 200
135
136 #### Test Policy Management Service ####
137
138 # Print the A1 version for STD 1.1.X
139 for ((i=0; i<$STD_NUM_RICS; i++))
140 do
141     sim_print "a1-sim-std-"$i interface
142 done
143
144 # Print the A1 version for STD 2.0.X
145 for ((i=0; i<$STD_NUM_RICS; i++))
146 do
147    sim_print "a1-sim-std2-"$i interface
148 done
149
150 # Print the A1 version for OSC 2.1.X
151 for ((i=0; i<$OSC_NUM_RICS; i++))
152 do
153     sim_print "a1-sim-osc-"$i interface
154 done
155
156 # Check the number of policies in STD and STD2
157 for ((i=0; i<$STD_NUM_RICS; i++))
158 do
159     sim_equal "a1-sim-std-"$i num_instances 0
160     sim_equal "a1-sim-std2-"$i num_instances 0
161 done
162
163 # Check the number of policies in OSC
164 for ((i=0; i<$STD_NUM_RICS; i++))
165 do
166     sim_equal "a1-sim-osc-"$i num_instances 0
167 done
168
169 #Check the number of schemas
170 api_equal json:policy-types 1
171
172 # Load the polictypes in STD 2
173 for ((i=0; i<$STD_NUM_RICS; i++))
174 do
175    sim_put_policy_type 201 "a1-sim-std2-"$i STD_QOS_0_2_0 testdata/STD2/sim_qos.json
176    sim_put_policy_type 201 "a1-sim-std2-"$i STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
177 done
178
179 # Load the polictypes in OSC
180 for ((i=0; i<$OSC_NUM_RICS; i++))
181 do
182     sim_put_policy_type 201 "a1-sim-osc-"$i 1 testdata/OSC/sim_1.json
183     sim_put_policy_type 201 "a1-sim-osc-"$i 2 testdata/OSC/sim_2.json
184 done
185
186 # Check that all rics are synced in
187 api_equal json:rics 6 300
188
189 #Check the number of schemas and the individual schemas
190 api_equal json:policy-types 5 300
191
192 for ((i=0; i<$STD_NUM_RICS; i++))
193 do
194     ricid=$((3+$i))
195     api_equal json:policy-types?ric_id=ric$ricid 1 120
196 done
197
198 for ((i=0; i<$STD_NUM_RICS; i++))
199 do
200    ricid=$((5+$i))
201    api_equal json:policy-types?ric_id=ric$ricid 2 120
202 done
203
204 for ((i=0; i<$OSC_NUM_RICS; i++))
205 do
206     ricid=$((1+$i))
207     api_equal json:policy-types?ric_id=ric$ricid 2 120
208 done
209
210 #Check the schemas in STD 2
211 for ((i=0; i<$OSC_NUM_RICS; i++))
212 do
213    ricid=$((5+$i))
214    api_get_policy_type 200 STD_QOS_0_2_0 testdata/STD2/qos-agent-modified.json
215    api_get_policy_type 200 STD_QOS2_0.1.0 testdata/STD2/qos2-agent-modified.json
216 done
217
218 # Check the schemas in OSC
219 for ((i=0; i<$OSC_NUM_RICS; i++))
220 do
221     api_get_policy_type 200 1 testdata/OSC/1-agent-modified.json
222     api_get_policy_type 200 2 testdata/OSC/2-agent-modified.json
223 done
224
225 if [ "$PMS_VERSION" == "V2" ]; then
226
227     api_equal json:policy-types 5 120
228
229     api_equal json:policies 0
230
231     api_equal json:policy-instances 0
232 else
233
234     api_equal json:policy_schemas 5 120
235
236     api_equal json:policy_types 5
237
238     api_equal json:policies 0
239
240     api_equal json:policy_ids 0
241 fi
242
243 api_put_service 201 "Emergency-response-app" 0 "$CR_SERVICE_APP_PATH/ER-app"
244
245 # Create policies in STD
246 for ((i=0; i<$STD_NUM_RICS; i++))
247 do
248     ricid=$((3+$i))
249     generate_policy_uuid
250     api_put_policy 201 "Emergency-response-app" ric$ricid NOTYPE $((1100+$i)) NOTRANSIENT $CR_SERVICE_APP_PATH/"std2" testdata/STD/pi1_template.json 1
251     generate_policy_uuid
252     api_put_policy 201 "Emergency-response-app" ric$ricid NOTYPE $((1200+$i)) NOTRANSIENT $CR_SERVICE_APP_PATH/"std2" testdata/STD/pi1_template.json 1
253 done
254
255 #Create policies in STD 2
256 for ((i=0; i<$STD_NUM_RICS; i++))
257 do
258    ricid=$((5+$i))
259    generate_policy_uuid
260    api_put_policy 201 "Emergency-response-app" ric$ricid STD_QOS_0_2_0 $((2100+$i)) NOTRANSIENT $CR_SERVICE_APP_PATH/"std2" testdata/STD2/pi_qos_template.json 1
261    generate_policy_uuid
262    api_put_policy 201 "Emergency-response-app" ric$ricid STD_QOS2_0.1.0 $((2200+$i)) NOTRANSIENT $CR_SERVICE_APP_PATH/"std2" testdata/STD2/pi_qos2_template.json 1
263 done
264
265 # Create policies in OSC
266 for ((i=0; i<$OSC_NUM_RICS; i++))
267 do
268     ricid=$((1+$i))
269     generate_policy_uuid
270     api_put_policy 201 "Emergency-response-app" ric$ricid 1 $((3100+$i)) NOTRANSIENT $CR_SERVICE_APP_PATH/"osc" testdata/OSC/pi1_template.json 1
271     generate_policy_uuid
272     api_put_policy 201 "Emergency-response-app" ric$ricid 2 $((3200+$i)) NOTRANSIENT $CR_SERVICE_APP_PATH/"osc" testdata/OSC/pi2_template.json 1
273 done
274
275
276 # Check the number of policies in STD and STD2
277 for ((i=0; i<$STD_NUM_RICS; i++))
278 do
279     sim_equal "a1-sim-std-"$i num_instances 2
280     sim_equal "a1-sim-std2-"$i num_instances 2
281 done
282
283 # Check the number of policies in OSC
284 for ((i=0; i<$STD_NUM_RICS; i++))
285 do
286     sim_equal "a1-sim-osc-"$i num_instances 2
287 done
288
289 stop_policy_agent
290
291 start_stopped_policy_agent
292
293 # Check PMS state after restart
294
295 sleep_wait 200
296
297 if [ "$PMS_VERSION" == "V2" ]; then
298
299     api_equal json:policy-types 5 120
300
301     api_equal json:policies 12
302
303     api_equal json:policy-instances 12
304 else
305
306     api_equal json:policy_schemas 5 120
307
308     api_equal json:policy_types 5
309
310     api_equal json:policies 12
311
312     api_equal json:policy_ids 12
313 fi
314
315 # Check the number of policies in STD and STD2
316 for ((i=0; i<$STD_NUM_RICS; i++))
317 do
318     sim_equal "a1-sim-std-"$i num_instances 2
319     sim_equal "a1-sim-std2-"$i num_instances 2
320 done
321
322 # Check the number of policies in OSC
323 for ((i=0; i<$STD_NUM_RICS; i++))
324 do
325     sim_equal "a1-sim-osc-"$i num_instances 2
326 done
327
328
329 echo "ADD EVENT/STATUS CHECK"
330 echo "ADD MR CHECK"
331
332 FLAT_A1_EI="1"
333
334 ecs_api_admin_reset
335
336 CB_JOB="$PROD_STUB_SERVICE_PATH$PROD_STUB_JOB_CALLBACK"
337 CB_SV="$PROD_STUB_SERVICE_PATH$PROD_STUB_SUPERVISION_CALLBACK"
338 TARGET1="$RIC_SIM_HTTPX://a1-sim-std2-0.a1-sim:$RIC_SIM_PORT/datadelivery"
339 TARGET2="$RIC_SIM_HTTPX://a1-sim-std2-1.a1-sim:$RIC_SIM_PORT/datadelivery"
340
341 STATUS1="$CR_SERVICE_APP_PATH/job1-status"
342 STATUS2="$CR_SERVICE_APP_PATH/job2-status"
343
344 prodstub_arm_producer 200 prod-a
345 prodstub_arm_type 200 prod-a type1
346 prodstub_arm_job_create 200 prod-a job1
347 prodstub_arm_job_create 200 prod-a job2
348
349
350 ### ecs status
351 ecs_api_service_status 200
352
353 ## Setup prod-a
354 if [ $ECS_VERSION == "V1-1" ]; then
355     ecs_api_edp_put_producer 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json
356
357     ecs_api_edp_get_producer 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json
358 else
359     ecs_api_edp_put_type_2 201 type1 testdata/ecs/ei-type-1.json
360     ecs_api_edp_get_type_2 200 type1
361     ecs_api_edp_get_type_ids 200 type1
362
363     ecs_api_edp_put_producer_2 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1
364     ecs_api_edp_put_producer_2 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1
365 fi
366
367 ecs_api_edp_get_producer_status 200 prod-a ENABLED
368
369
370 ## Create a job for prod-a
371 ## job1 - prod-a
372 if [  -z "$FLAT_A1_EI" ]; then
373     ecs_api_a1_put_job 201 type1 job1 $TARGET1 ricsim_g3_1 testdata/ecs/job-template.json
374 else
375     ecs_api_a1_put_job 201 job1 type1 $TARGET1 ricsim_g3_1 $STATUS1 testdata/ecs/job-template.json
376 fi
377
378 # Check the job data in the producer
379 if [ $ECS_VERSION == "V1-1" ]; then
380     prodstub_check_jobdata 200 prod-a job1 type1 $TARGET1 ricsim_g3_1 testdata/ecs/job-template.json
381 else
382     if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
383         prodstub_check_jobdata_3 200 prod-a job1 type1 $TARGET1 ricsim_g3_1 testdata/ecs/job-template.json
384     else
385         prodstub_check_jobdata_2 200 prod-a job1 type1 $TARGET1 ricsim_g3_1 testdata/ecs/job-template.json
386     fi
387 fi
388
389 ## Create a second job for prod-a
390 ## job2 - prod-a
391 if [  -z "$FLAT_A1_EI" ]; then
392     ecs_api_a1_put_job 201 type1 job2 $TARGET2 ricsim_g3_2 testdata/ecs/job-template.json
393 else
394     ecs_api_a1_put_job 201 job2 type1 $TARGET2 ricsim_g3_2 $STATUS2 testdata/ecs/job-template.json
395 fi
396
397 # Check the job data in the producer
398 if [ $ECS_VERSION == "V1-1" ]; then
399     prodstub_check_jobdata 200 prod-a job2 type1 $TARGET2 ricsim_g3_2 testdata/ecs/job-template.json
400 else
401     if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
402         prodstub_check_jobdata_3 200 prod-a job2 type1 $TARGET2 ricsim_g3_2 testdata/ecs/job-template.json
403     else
404         prodstub_check_jobdata_2 200 prod-a job2 type1 $TARGET2 ricsim_g3_2 testdata/ecs/job-template.json
405     fi
406 fi
407
408 # Dmaap mediator and adapter
409 start_dmaapadp NOPROXY $SIM_GROUP/$DMAAP_ADP_COMPOSE_DIR/$DMAAP_ADP_CONFIG_FILE $SIM_GROUP/$DMAAP_ADP_COMPOSE_DIR/$DMAAP_ADP_DATA_FILE
410
411 start_dmaapmed NOPROXY $SIM_GROUP/$DMAAP_MED_COMPOSE_DIR/$DMAAP_MED_DATA_FILE
412
413 ecs_equal json:ei-producer/v1/eiproducers 2 60
414
415 ecs_api_idc_get_type_ids 200 ExampleInformationType STD_Fault_Messages
416
417 ecs_api_edp_get_producer_ids_2 200 NOTYPE DmaapGenericInfoProducer DMaaP_Mediator_Producer
418
419 NUM_JOBS=5
420
421 for ((i=1; i<=$NUM_JOBS; i++))
422 do
423     ecs_api_idc_put_job 201 jobx$i STD_Fault_Messages $CR_SERVICE_MR_PATH/jobx-data$i info-ownerx$i $CR_SERVICE_MR_PATH/job_status_info-ownerx$i testdata/dmaap-adapter/job-template.json
424 done
425
426 for ((i=1; i<=$NUM_JOBS; i++))
427 do
428     ecs_api_idc_put_job 201 joby$i ExampleInformationType $CR_SERVICE_MR_PATH/joby-data$i info-ownery$i $CR_SERVICE_MR_PATH/job_status_info-ownery$i testdata/dmaap-adapter/job-template.json
429 done
430
431 for ((i=1; i<=$NUM_JOBS; i++))
432 do
433     ecs_api_a1_get_job_status 200 jobx$i ENABLED 30
434 done
435
436 mr_api_send_json "/events/unauthenticated.dmaapmed.json" '{"msg":"msg-0"}'
437 mr_api_send_json "/events/unauthenticated.dmaapadp.json" '{"msg":"msg-1"}'
438 mr_api_send_json "/events/unauthenticated.dmaapmed.json" '{"msg":"msg-2"}'
439 mr_api_send_json "/events/unauthenticated.dmaapadp.json" '{"msg":"msg-3"}'
440
441 cr_equal received_callbacks $(($NUM_JOBS*2*2)) 60
442 for ((i=1; i<=$NUM_JOBS; i++))
443 do
444     cr_equal received_callbacks?id=jobx-data$i 2
445     cr_equal received_callbacks?id=joby-data$i 2
446 done
447
448 for ((i=1; i<=$NUM_JOBS; i++))
449 do
450     cr_api_check_single_genric_json_event 200 jobx-data$i '{"msg":"msg-0"}'
451     cr_api_check_single_genric_json_event 200 jobx-data$i '{"msg":"msg-2"}'
452     cr_api_check_single_genric_json_event 200 joby-data$i '{"msg":"msg-1"}'
453     cr_api_check_single_genric_json_event 200 joby-data$i '{"msg":"msg-3"}'
454 done
455
456
457 stop_ecs
458
459 start_stopped_ecs
460
461 # Check ECS status after restart
462
463 if [  -z "$FLAT_A1_EI" ]; then
464     ecs_api_a1_get_job_status 200 type1 job1 DISABLED
465     ecs_api_a1_get_job_status 200 type1 job2 DISABLED
466 else
467     ecs_api_a1_get_job_status 200 job1 DISABLED
468     ecs_api_a1_get_job_status 200 job2 DISABLED
469 fi
470
471 check_policy_agent_logs
472 check_ecs_logs
473 check_sdnc_logs
474
475 #### TEST COMPLETE ####
476
477 store_logs          END
478
479 print_result