New test profile and minor updates
[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 each A1 interface 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 DMAAPMR CR  PRODSTUB KUBEPROXY KAFKAPC"
29 #Prestarted app (not started by script) to include in the test when running kubernetes, space separated list
30 KUBE_PRESTARTED_IMAGES=" A1PMS RICSIM CP ICS RC SDNC DMAAPMED DMAAPADP"
31
32 #Ignore image in DOCKER_INCLUDED_IMAGES, KUBE_INCLUDED_IMAGES if
33 #the image is not configured in the supplied env_file
34 #Used for images not applicable to all supported profile
35 CONDITIONALLY_IGNORED_IMAGES=""
36
37 #Supported test environment profiles
38 SUPPORTED_PROFILES="ORAN-E-RELEASE"
39 #Supported run modes
40 SUPPORTED_RUNMODES="KUBE"
41
42 . ../common/testcase_common.sh $@
43
44 setup_testenvironment
45
46 #### TEST BEGIN ####
47
48 use_mr_https
49 use_cr_https
50 use_a1pms_rest_https
51 use_sdnc_https
52 use_simulator_https
53 use_ics_rest_https
54 use_prod_stub_https
55 use_dmaapmed_https
56
57 if [ $ICS_VERSION == "V1-1" ]; then
58     use_rapp_catalogue_http # https not yet supported
59 else
60     ########################################use_rapp_catalogue_https
61     use_rapp_catalogue_http
62 fi
63
64 echo -e "$RED CHECK WHY RC HTTPS DOES NOT WORK $ERED"
65
66 ###############################use_control_panel_https
67 use_control_panel_http
68
69 if [ "$A1PMS_VERSION" == "V1" ]; then
70    echo "A1PMS VERSION 2 (V2) is required"
71    exit 1
72 fi
73
74 clean_environment
75
76 ics_kube_pvc_reset
77
78 a1pms_kube_pvc_reset
79
80 start_kube_proxy
81
82 STD_NUM_RICS=2
83 OSC_NUM_RICS=2
84
85 start_ric_simulators a1-sim-osc $STD_NUM_RICS OSC_2.1.0
86 echo " RIC MAPPING a1-sim-osc-0 : ric1"
87 echo " RIC MAPPING a1-sim-osc-1 : ric2"
88
89 start_ric_simulators a1-sim-std $STD_NUM_RICS STD_1.1.3
90 echo " RIC MAPPING a1-sim-std-0 : ric3"
91 echo " RIC MAPPING a1-sim-std-1 : ric4"
92
93 start_ric_simulators a1-sim-std2 $STD_NUM_RICS STD_2.0.0
94 echo " RIC MAPPING a1-sim-std2-0 : ric5"
95 echo " RIC MAPPING a1-sim-std2-1 : ric6"
96
97 start_mr    "$MR_READ_TOPIC"  "/events" "users/policy-agent" \
98             "$MR_WRITE_TOPIC" "/events" "users/mr-stub" \
99             "unauthenticated.dmaapmed.json" "/events" "dmaapmediatorproducer/STD_Fault_Messages" \
100             "unauthenticated.dmaapadp.json" "/events" "dmaapadapterproducer/msgs"
101
102 start_kafkapc
103
104 kafkapc_api_create_topic 201 "unauthenticated.dmaapadp_kafka.text" "text/plain"
105
106 kafkapc_api_start_sending 200 "unauthenticated.dmaapadp_kafka.text"
107
108 start_control_panel
109
110 start_sdnc
111
112 start_a1pms
113
114 start_cr 1
115
116 start_prod_stub
117
118 start_ics NOPROXY
119
120 set_ics_trace
121
122 start_rapp_catalogue
123
124 set_a1pms_trace
125
126 #### Test RAPP Catalogue ####
127
128 rapp_cat_api_get_services 200 EMPTY
129
130 rapp_cat_api_put_service 201 "Emergency-response-app" v1 "Emergency-response-app" "Emergency-response-app"
131
132 rapp_cat_api_get_services 200 "Emergency-response-app" v1 "Emergency-response-app" "Emergency-response-app"
133
134 #Check the number of services
135 rc_equal json:services 1
136
137 sleep_wait 120 "Let A1PMS cofiguration take effect"
138
139 a1_a1pms_api_get_status 200
140
141 #### Test Policy Management Service ####
142
143 # Print the A1 version for STD 1.1.X
144 for ((i=0; i<$STD_NUM_RICS; i++))
145 do
146     sim_print "a1-sim-std-"$i interface
147 done
148
149 # Print the A1 version for STD 2.0.X
150 for ((i=0; i<$STD_NUM_RICS; i++))
151 do
152    sim_print "a1-sim-std2-"$i interface
153 done
154
155 # Print the A1 version for OSC 2.1.X
156 for ((i=0; i<$OSC_NUM_RICS; i++))
157 do
158     sim_print "a1-sim-osc-"$i interface
159 done
160
161 # Check the number of policies in STD and STD2
162 for ((i=0; i<$STD_NUM_RICS; i++))
163 do
164     sim_equal "a1-sim-std-"$i num_instances 0
165     sim_equal "a1-sim-std2-"$i num_instances 0
166 done
167
168 # Check the number of policies in OSC
169 for ((i=0; i<$STD_NUM_RICS; i++))
170 do
171     sim_equal "a1-sim-osc-"$i num_instances 0
172 done
173
174 #Check the number of schemas
175 a1pms_equal json:policy-types 1
176
177 # Load the polictypes in STD 2
178 for ((i=0; i<$STD_NUM_RICS; i++))
179 do
180    sim_put_policy_type 201 "a1-sim-std2-"$i STD_QOS_0_2_0 testdata/STD2/sim_qos.json
181    sim_put_policy_type 201 "a1-sim-std2-"$i STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
182 done
183
184 # Load the polictypes in OSC
185 for ((i=0; i<$OSC_NUM_RICS; i++))
186 do
187     sim_put_policy_type 201 "a1-sim-osc-"$i 1 testdata/OSC/sim_1.json
188     sim_put_policy_type 201 "a1-sim-osc-"$i 2 testdata/OSC/sim_2.json
189 done
190
191 # Check that all rics are synced in
192 a1pms_equal json:rics 6 300
193
194 #Check the number of schemas and the individual schemas
195 a1pms_equal json:policy-types 5 300
196
197 for ((i=0; i<$STD_NUM_RICS; i++))
198 do
199     ricid=$((3+$i))
200     a1pms_equal json:policy-types?ric_id=ric$ricid 1 120
201 done
202
203 for ((i=0; i<$STD_NUM_RICS; i++))
204 do
205    ricid=$((5+$i))
206    a1pms_equal json:policy-types?ric_id=ric$ricid 2 120
207 done
208
209 for ((i=0; i<$OSC_NUM_RICS; i++))
210 do
211     ricid=$((1+$i))
212     a1pms_equal json:policy-types?ric_id=ric$ricid 2 120
213 done
214
215 #Check the schemas in STD 2
216 for ((i=0; i<$OSC_NUM_RICS; i++))
217 do
218    ricid=$((5+$i))
219    a1_a1pms_api_get_policy_type 200 STD_QOS_0_2_0 testdata/STD2/qos-a1pms-modified.json
220    a1_a1pms_api_get_policy_type 200 STD_QOS2_0.1.0 testdata/STD2/qos2-a1pms-modified.json
221 done
222
223 # Check the schemas in OSC
224 for ((i=0; i<$OSC_NUM_RICS; i++))
225 do
226     a1_a1pms_api_get_policy_type 200 1 testdata/OSC/1-a1pms-modified.json
227     a1_a1pms_api_get_policy_type 200 2 testdata/OSC/2-a1pms-modified.json
228 done
229
230 if [ "$A1PMS_VERSION" == "V2" ]; then
231
232     a1pms_equal json:policy-types 5 120
233
234     a1pms_equal json:policies 0
235
236     a1pms_equal json:policy-instances 0
237 else
238
239     a1pms_equal json:policy_schemas 5 120
240
241     a1pms_equal json:policy_types 5
242
243     a1pms_equal json:policies 0
244
245     a1pms_equal json:policy_ids 0
246 fi
247
248 a1pms_api_put_service 201 "Emergency-response-app" 0 "$CR_SERVICE_APP_PATH_0/ER-app"
249
250 # Create policies in STD
251 for ((i=0; i<$STD_NUM_RICS; i++))
252 do
253     ricid=$((3+$i))
254     generate_policy_uuid
255     a1pms_api_put_policy 201 "Emergency-response-app" ric$ricid NOTYPE $((1100+$i)) NOTRANSIENT $CR_SERVICE_APP_PATH_0/"std2" testdata/STD/pi1_template.json 1
256     generate_policy_uuid
257     a1pms_api_put_policy 201 "Emergency-response-app" ric$ricid NOTYPE $((1200+$i)) NOTRANSIENT $CR_SERVICE_APP_PATH_0/"std2" testdata/STD/pi1_template.json 1
258 done
259
260 #Create policies in STD 2
261 for ((i=0; i<$STD_NUM_RICS; i++))
262 do
263    ricid=$((5+$i))
264    generate_policy_uuid
265    a1pms_api_put_policy 201 "Emergency-response-app" ric$ricid STD_QOS_0_2_0 $((2100+$i)) NOTRANSIENT $CR_SERVICE_APP_PATH_0/"std2" testdata/STD2/pi_qos_template.json 1
266    generate_policy_uuid
267    a1pms_api_put_policy 201 "Emergency-response-app" ric$ricid STD_QOS2_0.1.0 $((2200+$i)) NOTRANSIENT $CR_SERVICE_APP_PATH_0/"std2" testdata/STD2/pi_qos2_template.json 1
268 done
269
270 # Create policies in OSC
271 for ((i=0; i<$OSC_NUM_RICS; i++))
272 do
273     ricid=$((1+$i))
274     generate_policy_uuid
275     a1pms_api_put_policy 201 "Emergency-response-app" ric$ricid 1 $((3100+$i)) NOTRANSIENT $CR_SERVICE_APP_PATH_0/"osc" testdata/OSC/pi1_template.json 1
276     generate_policy_uuid
277     a1pms_api_put_policy 201 "Emergency-response-app" ric$ricid 2 $((3200+$i)) NOTRANSIENT $CR_SERVICE_APP_PATH_0/"osc" testdata/OSC/pi2_template.json 1
278 done
279
280
281 # Check the number of policies in STD and STD2
282 for ((i=0; i<$STD_NUM_RICS; i++))
283 do
284     sim_equal "a1-sim-std-"$i num_instances 2
285     sim_equal "a1-sim-std2-"$i num_instances 2
286 done
287
288 # Check the number of policies in OSC
289 for ((i=0; i<$STD_NUM_RICS; i++))
290 do
291     sim_equal "a1-sim-osc-"$i num_instances 2
292 done
293
294 stop_a1pms
295
296 start_stopped_a1pms
297
298 # Check A1PMS state after restart
299
300 sleep_wait 200
301
302 if [ "$A1PMS_VERSION" == "V2" ]; then
303
304     a1pms_equal json:policy-types 5 120
305
306     a1pms_equal json:policies 12
307
308     a1pms_equal json:policy-instances 12
309 else
310
311     a1pms_equal json:policy_schemas 5 120
312
313     a1pms_equal json:policy_types 5
314
315     a1pms_equal json:policies 12
316
317     a1pms_equal json:policy_ids 12
318 fi
319
320 # Check the number of policies in STD and STD2
321 for ((i=0; i<$STD_NUM_RICS; i++))
322 do
323     sim_equal "a1-sim-std-"$i num_instances 2
324     sim_equal "a1-sim-std2-"$i num_instances 2
325 done
326
327 # Check the number of policies in OSC
328 for ((i=0; i<$STD_NUM_RICS; i++))
329 do
330     sim_equal "a1-sim-osc-"$i num_instances 2
331 done
332
333 cr_api_reset 0   # Reset CR to count new events
334
335 echo "ADD EVENT/STATUS CHECK"
336 echo "ADD MR CHECK"
337
338 FLAT_A1_EI="1"
339
340 ics_api_admin_reset
341
342 CB_JOB="$PROD_STUB_SERVICE_PATH$PROD_STUB_JOB_CALLBACK"
343 CB_SV="$PROD_STUB_SERVICE_PATH$PROD_STUB_SUPERVISION_CALLBACK"
344 TARGET1="$RIC_SIM_HTTPX://a1-sim-std2-0.a1-sim:$RIC_SIM_PORT/datadelivery"
345 TARGET2="$RIC_SIM_HTTPX://a1-sim-std2-1.a1-sim:$RIC_SIM_PORT/datadelivery"
346
347 STATUS1="$CR_SERVICE_APP_PATH_0/job1-status"
348 STATUS2="$CR_SERVICE_APP_PATH_0/job2-status"
349
350 prodstub_arm_producer 200 prod-a
351 prodstub_arm_type 200 prod-a type1
352 prodstub_arm_job_create 200 prod-a job1
353 prodstub_arm_job_create 200 prod-a job2
354
355
356 ### ics status
357 ics_api_service_status 200
358
359 ## Setup prod-a
360 if [ $ICS_VERSION == "V1-1" ]; then
361     ics_api_edp_put_producer 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ics/ei-type-1.json
362
363     ics_api_edp_get_producer 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ics/ei-type-1.json
364 else
365     ics_api_edp_put_type_2 201 type1 testdata/ics/ei-type-1.json
366     ics_api_edp_get_type_2 200 type1
367
368     ics_api_edp_get_type_ids 200 type1
369
370     ics_api_edp_put_producer_2 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1
371     ics_api_edp_put_producer_2 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1
372 fi
373
374 ics_api_edp_get_producer_status 200 prod-a ENABLED
375
376
377 ## Create a job for prod-a
378 ## job1 - prod-a
379 if [  -z "$FLAT_A1_EI" ]; then
380     ics_api_a1_put_job 201 type1 job1 $TARGET1 ricsim_g3_1 testdata/ics/job-template.json
381 else
382     ics_api_a1_put_job 201 job1 type1 $TARGET1 ricsim_g3_1 $STATUS1 testdata/ics/job-template.json
383 fi
384
385 # Check the job data in the producer
386 if [ $ICS_VERSION == "V1-1" ]; then
387     prodstub_check_jobdata 200 prod-a job1 type1 $TARGET1 ricsim_g3_1 testdata/ics/job-template.json
388 else
389     if [[ "$ICS_FEATURE3LEVEL" == *"INFO-TYPES"* ]]; then
390         prodstub_check_jobdata_3 200 prod-a job1 type1 $TARGET1 ricsim_g3_1 testdata/ics/job-template.json
391     else
392         prodstub_check_jobdata_2 200 prod-a job1 type1 $TARGET1 ricsim_g3_1 testdata/ics/job-template.json
393     fi
394 fi
395
396 ## Create a second job for prod-a
397 ## job2 - prod-a
398 if [  -z "$FLAT_A1_EI" ]; then
399     ics_api_a1_put_job 201 type1 job2 $TARGET2 ricsim_g3_2 testdata/ics/job-template.json
400 else
401     ics_api_a1_put_job 201 job2 type1 $TARGET2 ricsim_g3_2 $STATUS2 testdata/ics/job-template.json
402 fi
403
404 # Check the job data in the producer
405 if [ $ICS_VERSION == "V1-1" ]; then
406     prodstub_check_jobdata 200 prod-a job2 type1 $TARGET2 ricsim_g3_2 testdata/ics/job-template.json
407 else
408     if [[ "$ICS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
409         prodstub_check_jobdata_3 200 prod-a job2 type1 $TARGET2 ricsim_g3_2 testdata/ics/job-template.json
410     else
411         prodstub_check_jobdata_2 200 prod-a job2 type1 $TARGET2 ricsim_g3_2 testdata/ics/job-template.json
412     fi
413 fi
414
415 # Dmaap mediator and adapter
416 start_dmaapadp NOPROXY $SIM_GROUP/$DMAAP_ADP_COMPOSE_DIR/$DMAAP_ADP_CONFIG_FILE_TEMPLATE $SIM_GROUP/$DMAAP_ADP_COMPOSE_DIR/$DMAAP_ADP_DATA_FILE
417
418 start_dmaapmed NOPROXY $SIM_GROUP/$DMAAP_MED_COMPOSE_DIR/$DMAAP_MED_HOST_DATA_FILE
419
420 ics_equal json:data-producer/v1/info-producers 3 120
421
422 ics_equal json:data-producer/v1/info-types 4 30
423
424 ics_api_idc_get_type_ids 200 ExampleInformationType ExampleInformationTypeKafka STD_Fault_Messages type1
425
426 ics_api_edp_get_producer_ids_2 200 NOTYPE prod-a DmaapGenericInfoProducer DMaaP_Mediator_Producer
427
428 NUM_JOBS=1
429
430 for ((i=1; i<=$NUM_JOBS; i++))
431 do
432     ics_api_idc_put_job 201 jobx$i STD_Fault_Messages $CR_SERVICE_MR_PATH_0/jobx-data$i info-ownerx$i $CR_SERVICE_MR_PATH_0/job_status_info-ownerx$i testdata/dmaap-adapter/job-template1.json
433 done
434
435 for ((i=1; i<=$NUM_JOBS; i++))
436 do
437     ics_api_idc_put_job 201 joby$i ExampleInformationType $CR_SERVICE_MR_PATH_0/joby-data$i info-ownery$i $CR_SERVICE_MR_PATH_0/job_status_info-ownery$i testdata/dmaap-adapter/job-template1.json
438     ics_api_idc_put_job 201 jobz$i ExampleInformationTypeKafka $CR_SERVICE_MR_PATH_0/jobz-data$i info-ownerz$i $CR_SERVICE_MR_PATH_0/job_status_info-ownerz$i testdata/dmaap-adapter/job-template-1-kafka.json
439 done
440
441 for ((i=1; i<=$NUM_JOBS; i++))
442 do
443     ics_api_a1_get_job_status 200 jobx$i ENABLED 30
444     ics_api_a1_get_job_status 200 joby$i ENABLED 30
445     ics_api_a1_get_job_status 200 jobz$i ENABLED 30
446 done
447
448 sleep_wait 30 # Wait for mediator to listening to kafka
449
450 mr_api_send_json "/events/unauthenticated.dmaapmed.json" '{"msg":"msg-0"}'
451 mr_api_send_json "/events/unauthenticated.dmaapadp.json" '{"msg":"msg-1"}'
452 mr_api_send_json "/events/unauthenticated.dmaapmed.json" '{"msg":"msg-2"}'
453 mr_api_send_json "/events/unauthenticated.dmaapadp.json" '{"msg":"msg-3"}'
454 kafkapc_api_post_msg 200 "unauthenticated.dmaapadp_kafka.text" "text/plain" 'Message-------4'
455 kafkapc_api_post_msg 200 "unauthenticated.dmaapadp_kafka.text" "text/plain" 'Message-------6'
456
457
458 cr_equal 0 received_callbacks $(($NUM_JOBS*2*3)) 200
459 for ((i=1; i<=$NUM_JOBS; i++))
460 do
461     cr_equal 0 received_callbacks?id=jobx-data$i 2
462     cr_equal 0 received_callbacks?id=joby-data$i 2
463     cr_equal 0 received_callbacks?id=jobz-data$i 2
464 done
465
466 for ((i=1; i<=$NUM_JOBS; i++))
467 do
468     cr_api_check_single_genric_json_event 200 0 jobx-data$i '{"msg":"msg-0"}'
469     cr_api_check_single_genric_json_event 200 0 jobx-data$i '{"msg":"msg-2"}'
470     cr_api_check_single_genric_json_event 200 0 joby-data$i '{"msg":"msg-1"}'
471     cr_api_check_single_genric_json_event 200 0 joby-data$i '{"msg":"msg-3"}'
472     cr_api_check_single_genric_json_event 200 0 jobz-data$i 'Message-------4'
473     cr_api_check_single_genric_json_event 200 0 jobz-data$i 'Message-------6'
474 done
475
476
477 stop_ics
478
479 start_stopped_ics
480
481 # Check ICS status after restart
482
483 if [  -z "$FLAT_A1_EI" ]; then
484     ics_api_a1_get_job_status 200 type1 job1 DISABLED
485     ics_api_a1_get_job_status 200 type1 job2 DISABLED
486 else
487     ics_api_a1_get_job_status 200 job1 DISABLED
488     ics_api_a1_get_job_status 200 job2 DISABLED
489 fi
490
491 check_a1pms_logs
492 check_ics_logs
493 check_sdnc_logs
494
495 #### TEST COMPLETE ####
496
497 store_logs          END
498
499 print_result