1b63f615d85883f939344751a420e4670197ec0e
[nonrtric.git] / test / auto-test / FTC_HELM_E_RELEASE.sh
1 #!/usr/bin/env bash
2
3 #  ============LICENSE_START===============================================
4 #  Copyright (C) 2020-2023 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 #Pre-started 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 use_rapp_catalogue_http
58
59 echo -e "$RED CHECK WHY RC HTTPS DOES NOT WORK $ERED"
60
61 ###############################use_control_panel_https
62 use_control_panel_http
63
64 clean_environment
65
66 ics_kube_pvc_reset
67
68 a1pms_kube_pvc_reset
69
70 start_kube_proxy
71
72 STD_NUM_RICS=2
73 OSC_NUM_RICS=2
74
75 start_ric_simulators a1-sim-osc $STD_NUM_RICS OSC_2.1.0
76 echo " RIC MAPPING a1-sim-osc-0 : ric1"
77 echo " RIC MAPPING a1-sim-osc-1 : ric2"
78
79 start_ric_simulators a1-sim-std $STD_NUM_RICS STD_1.1.3
80 echo " RIC MAPPING a1-sim-std-0 : ric3"
81 echo " RIC MAPPING a1-sim-std-1 : ric4"
82
83 start_ric_simulators a1-sim-std2 $STD_NUM_RICS STD_2.0.0
84 echo " RIC MAPPING a1-sim-std2-0 : ric5"
85 echo " RIC MAPPING a1-sim-std2-1 : ric6"
86
87 start_mr    "$MR_READ_TOPIC"  "/events" "users/policy-agent" \
88             "$MR_WRITE_TOPIC" "/events" "users/mr-stub" \
89             "unauthenticated.dmaapmed.json" "/events" "dmaapmediatorproducer/STD_Fault_Messages" \
90             "unauthenticated.dmaapadp.json" "/events" "dmaapadapterproducer/msgs"
91
92 start_kafkapc
93
94 kafkapc_api_create_topic 201 "unauthenticated.dmaapadp_kafka.text" "text/plain"
95
96 kafkapc_api_start_sending 200 "unauthenticated.dmaapadp_kafka.text"
97
98 start_control_panel
99
100 start_sdnc
101 controller_api_wait_for_status_ok 200 a1-sim-std-1
102
103 start_a1pms
104
105 start_cr 1
106
107 start_prod_stub
108
109 start_ics NOPROXY
110
111 set_ics_trace
112
113 start_rapp_catalogue
114
115 set_a1pms_trace
116
117 #### Test RAPP Catalogue ####
118
119 rapp_cat_api_get_services 200 EMPTY
120
121 rapp_cat_api_put_service 201 "Emergency-response-app" v1 "Emergency-response-app" "Emergency-response-app"
122
123 rapp_cat_api_get_services 200 "Emergency-response-app" v1 "Emergency-response-app" "Emergency-response-app"
124
125 #Check the number of services
126 rc_equal json:services 1
127
128 sleep_wait 120 "Let A1PMS configuration take effect"
129
130 a1_a1pms_api_get_status 200
131
132 #### Test Policy Management Service ####
133
134 # Print the A1 version for STD 1.1.X
135 for ((i=0; i<$STD_NUM_RICS; i++))
136 do
137     sim_print "a1-sim-std-"$i interface
138 done
139
140 # Print the A1 version for STD 2.0.X
141 for ((i=0; i<$STD_NUM_RICS; i++))
142 do
143    sim_print "a1-sim-std2-"$i interface
144 done
145
146 # Print the A1 version for OSC 2.1.X
147 for ((i=0; i<$OSC_NUM_RICS; i++))
148 do
149     sim_print "a1-sim-osc-"$i interface
150 done
151
152 # Check the number of policies in STD and STD2
153 for ((i=0; i<$STD_NUM_RICS; i++))
154 do
155     sim_equal "a1-sim-std-"$i num_instances 0
156     sim_equal "a1-sim-std2-"$i num_instances 0
157 done
158
159 # Check the number of policies in OSC
160 for ((i=0; i<$STD_NUM_RICS; i++))
161 do
162     sim_equal "a1-sim-osc-"$i num_instances 0
163 done
164
165 #Check the number of schemas
166 a1pms_equal json:policy-types 1
167
168 # Load the policytypes in STD 2
169 for ((i=0; i<$STD_NUM_RICS; i++))
170 do
171    sim_put_policy_type 201 "a1-sim-std2-"$i STD_QOS_0_2_0 testdata/STD2/sim_qos.json
172    sim_put_policy_type 201 "a1-sim-std2-"$i STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
173 done
174
175 # Load the policytypes in OSC
176 for ((i=0; i<$OSC_NUM_RICS; i++))
177 do
178     sim_put_policy_type 201 "a1-sim-osc-"$i 1 testdata/OSC/sim_1.json
179     sim_put_policy_type 201 "a1-sim-osc-"$i 2 testdata/OSC/sim_2.json
180 done
181
182 # Check that all rics are synced in
183 a1pms_equal json:rics 6 300
184
185 #Check the number of schemas and the individual schemas
186 a1pms_equal json:policy-types 5 300
187
188 for ((i=0; i<$STD_NUM_RICS; i++))
189 do
190     ricid=$((3+$i))
191     a1pms_equal json:policy-types?ric_id=ric$ricid 1 120
192 done
193
194 for ((i=0; i<$STD_NUM_RICS; i++))
195 do
196    ricid=$((5+$i))
197    a1pms_equal json:policy-types?ric_id=ric$ricid 2 120
198 done
199
200 for ((i=0; i<$OSC_NUM_RICS; i++))
201 do
202     ricid=$((1+$i))
203     a1pms_equal json:policy-types?ric_id=ric$ricid 2 120
204 done
205
206 #Check the schemas in STD 2
207 for ((i=0; i<$OSC_NUM_RICS; i++))
208 do
209    ricid=$((5+$i))
210    a1_a1pms_api_get_policy_type 200 STD_QOS_0_2_0 testdata/STD2/qos-a1pms-modified.json
211    a1_a1pms_api_get_policy_type 200 STD_QOS2_0.1.0 testdata/STD2/qos2-a1pms-modified.json
212 done
213
214 # Check the schemas in OSC
215 for ((i=0; i<$OSC_NUM_RICS; i++))
216 do
217     a1_a1pms_api_get_policy_type 200 1 testdata/OSC/1-a1pms-modified.json
218     a1_a1pms_api_get_policy_type 200 2 testdata/OSC/2-a1pms-modified.json
219 done
220
221 a1pms_equal json:policy-types 5 120
222
223 a1pms_equal json:policies 0
224
225 a1pms_equal json:policy-instances 0
226
227 a1pms_api_put_service 201 "Emergency-response-app" 0 "$CR_SERVICE_APP_PATH_0/ER-app"
228
229 # Create policies in STD
230 for ((i=0; i<$STD_NUM_RICS; i++))
231 do
232     ricid=$((3+$i))
233     sim_generate_policy_uuid
234     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
235     sim_generate_policy_uuid
236     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
237 done
238
239 #Create policies in STD 2
240 for ((i=0; i<$STD_NUM_RICS; i++))
241 do
242    ricid=$((5+$i))
243    sim_generate_policy_uuid
244    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
245    sim_generate_policy_uuid
246    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
247 done
248
249 # Create policies in OSC
250 for ((i=0; i<$OSC_NUM_RICS; i++))
251 do
252     ricid=$((1+$i))
253     sim_generate_policy_uuid
254     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
255     sim_generate_policy_uuid
256     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
257 done
258
259
260 # Check the number of policies in STD and STD2
261 for ((i=0; i<$STD_NUM_RICS; i++))
262 do
263     sim_equal "a1-sim-std-"$i num_instances 2
264     sim_equal "a1-sim-std2-"$i num_instances 2
265 done
266
267 # Check the number of policies in OSC
268 for ((i=0; i<$STD_NUM_RICS; i++))
269 do
270     sim_equal "a1-sim-osc-"$i num_instances 2
271 done
272
273 stop_a1pms
274
275 start_stopped_a1pms
276
277 # Check A1PMS state after restart
278
279 sleep_wait 200
280
281 a1pms_equal json:policy-types 5 120
282
283 a1pms_equal json:policies 12
284
285 a1pms_equal json:policy-instances 12
286
287 # Check the number of policies in STD and STD2
288 for ((i=0; i<$STD_NUM_RICS; i++))
289 do
290     sim_equal "a1-sim-std-"$i num_instances 2
291     sim_equal "a1-sim-std2-"$i num_instances 2
292 done
293
294 # Check the number of policies in OSC
295 for ((i=0; i<$STD_NUM_RICS; i++))
296 do
297     sim_equal "a1-sim-osc-"$i num_instances 2
298 done
299
300 cr_api_reset 0   # Reset CR to count new events
301
302 echo "ADD EVENT/STATUS CHECK"
303 echo "ADD MR CHECK"
304
305 ics_api_admin_reset
306
307 CB_JOB="$PROD_STUB_SERVICE_PATH$PROD_STUB_JOB_CALLBACK"
308 CB_SV="$PROD_STUB_SERVICE_PATH$PROD_STUB_SUPERVISION_CALLBACK"
309 TARGET1="$RIC_SIM_HTTPX://a1-sim-std2-0.a1-sim:$RIC_SIM_PORT/datadelivery"
310 TARGET2="$RIC_SIM_HTTPX://a1-sim-std2-1.a1-sim:$RIC_SIM_PORT/datadelivery"
311
312 STATUS1="$CR_SERVICE_APP_PATH_0/job1-status"
313 STATUS2="$CR_SERVICE_APP_PATH_0/job2-status"
314
315 prodstub_arm_producer 200 prod-a
316 prodstub_arm_type 200 prod-a type1
317 prodstub_arm_job_create 200 prod-a job1
318 prodstub_arm_job_create 200 prod-a job2
319
320
321 ### ics status
322 ics_api_service_status 200
323
324 ## Setup prod-a
325 ics_api_edp_put_type_2 201 type1 testdata/ics/ei-type-1.json
326 ics_api_edp_get_type_2 200 type1
327
328 ics_api_edp_get_type_ids 200 type1
329
330 ics_api_edp_put_producer_2 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1
331 ics_api_edp_put_producer_2 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1
332
333 ics_api_edp_get_producer_status 200 prod-a ENABLED
334
335
336 ## Create a job for prod-a
337 ## job1 - prod-a
338 ics_api_a1_put_job 201 job1 type1 $TARGET1 ricsim_g3_1 $STATUS1 testdata/ics/job-template.json
339
340 # Check the job data in the producer
341 prodstub_check_jobdata_3 200 prod-a job1 type1 $TARGET1 ricsim_g3_1 testdata/ics/job-template.json
342
343 ## Create a second job for prod-a
344 ## job2 - prod-a
345 ics_api_a1_put_job 201 job2 type1 $TARGET2 ricsim_g3_2 $STATUS2 testdata/ics/job-template.json
346
347 # Check the job data in the producer
348 prodstub_check_jobdata_3 200 prod-a job2 type1 $TARGET2 ricsim_g3_2 testdata/ics/job-template.json
349
350 # Dmaap mediator and adapter
351 start_dmaapadp NOPROXY $SIM_GROUP/$DMAAP_ADP_COMPOSE_DIR/$DMAAP_ADP_CONFIG_FILE_TEMPLATE $SIM_GROUP/$DMAAP_ADP_COMPOSE_DIR/$DMAAP_ADP_DATA_FILE
352
353 start_dmaapmed NOPROXY $SIM_GROUP/$DMAAP_MED_COMPOSE_DIR/$DMAAP_MED_HOST_DATA_FILE
354
355 ics_equal json:data-producer/v1/info-producers 3 120
356
357 ics_equal json:data-producer/v1/info-types 4 30
358
359 ics_api_idc_get_type_ids 200 ExampleInformationType ExampleInformationTypeKafka STD_Fault_Messages type1
360
361 ics_api_edp_get_producer_ids_2 200 NOTYPE prod-a DmaapGenericInfoProducer DMaaP_Mediator_Producer
362
363 NUM_JOBS=1
364
365 for ((i=1; i<=$NUM_JOBS; i++))
366 do
367     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
368 done
369
370 for ((i=1; i<=$NUM_JOBS; i++))
371 do
372     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
373     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
374 done
375
376 for ((i=1; i<=$NUM_JOBS; i++))
377 do
378     ics_api_a1_get_job_status 200 jobx$i ENABLED 30
379     ics_api_a1_get_job_status 200 joby$i ENABLED 30
380     ics_api_a1_get_job_status 200 jobz$i ENABLED 30
381 done
382
383 sleep_wait 30 # Wait for mediator to listening to kafka
384
385 mr_api_send_json "/events/unauthenticated.dmaapmed.json" '{"msg":"msg-0"}'
386 mr_api_send_json "/events/unauthenticated.dmaapadp.json" '{"msg":"msg-1"}'
387 mr_api_send_json "/events/unauthenticated.dmaapmed.json" '{"msg":"msg-2"}'
388 mr_api_send_json "/events/unauthenticated.dmaapadp.json" '{"msg":"msg-3"}'
389 kafkapc_api_post_msg 200 "unauthenticated.dmaapadp_kafka.text" "text/plain" 'Message-------4'
390 kafkapc_api_post_msg 200 "unauthenticated.dmaapadp_kafka.text" "text/plain" 'Message-------6'
391
392
393 cr_equal 0 received_callbacks $(($NUM_JOBS*2*3)) 200
394 for ((i=1; i<=$NUM_JOBS; i++))
395 do
396     cr_equal 0 received_callbacks?id=jobx-data$i 2
397     cr_equal 0 received_callbacks?id=joby-data$i 2
398     cr_equal 0 received_callbacks?id=jobz-data$i 2
399 done
400
401 for ((i=1; i<=$NUM_JOBS; i++))
402 do
403     cr_api_check_single_generic_json_event 200 0 jobx-data$i '{"msg":"msg-0"}'
404     cr_api_check_single_generic_json_event 200 0 jobx-data$i '{"msg":"msg-2"}'
405     cr_api_check_single_generic_json_event 200 0 joby-data$i '{"msg":"msg-1"}'
406     cr_api_check_single_generic_json_event 200 0 joby-data$i '{"msg":"msg-3"}'
407     cr_api_check_single_generic_json_event 200 0 jobz-data$i 'Message-------4'
408     cr_api_check_single_generic_json_event 200 0 jobz-data$i 'Message-------6'
409 done
410
411
412 stop_ics
413
414 start_stopped_ics
415
416 # Check ICS status after restart
417
418 ics_api_a1_get_job_status 200 job1 DISABLED
419 ics_api_a1_get_job_status 200 job2 DISABLED
420
421 check_a1pms_logs
422 check_ics_logs
423 check_sdnc_logs
424
425 #### TEST COMPLETE ####
426
427 store_logs          END
428
429 print_result