blob: 4c261b4c0f879086ece482f46ef4209a58f22a4d [file] [log] [blame]
BjornMagnussonXA663566c2021-11-08 10:25:07 +01001#!/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
20TC_ONELINE_DESCR="App test DMAAP Meditor and DMAAP Adapter"
21
22#App names to include in the test when running docker, space separated list
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +010023DOCKER_INCLUDED_IMAGES="ECS DMAAPMED DMAAPADP KUBEPROXY MR DMAAPMR CR"
BjornMagnussonXA663566c2021-11-08 10:25:07 +010024
25#App names to include in the test when running kubernetes, space separated list
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +010026KUBE_INCLUDED_IMAGES=" ECS DMAAPMED DMAAPADP KUBEPROXY MR DMAAPMR CR"
BjornMagnussonXA663566c2021-11-08 10:25:07 +010027
28#Prestarted app (not started by script) to include in the test when running kubernetes, space separated list
29KUBE_PRESTARTED_IMAGES=""
30
31#Ignore image in DOCKER_INCLUDED_IMAGES, KUBE_INCLUDED_IMAGES if
32#the image is not configured in the supplied env_file
33#Used for images not applicable to all supported profile
34CONDITIONALLY_IGNORED_IMAGES=""
35
36#Supported test environment profiles
37SUPPORTED_PROFILES="ORAN-E-RELEASE"
38#Supported run modes
39SUPPORTED_RUNMODES="DOCKER KUBE"
40
41. ../common/testcase_common.sh $@
42. ../common/agent_api_functions.sh
43. ../common/ricsimulator_api_functions.sh
44. ../common/ecs_api_functions.sh
45. ../common/prodstub_api_functions.sh
46. ../common/cr_api_functions.sh
47. ../common/rapp_catalogue_api_functions.sh
48. ../common/mr_api_functions.sh
49. ../common/control_panel_api_functions.sh
50. ../common/controller_api_functions.sh
51. ../common/consul_cbs_functions.sh
52. ../common/http_proxy_api_functions.sh
53. ../common/kube_proxy_api_functions.sh
54. ../common/gateway_api_functions.sh
55. ../common/dmaapmed_api_functions.sh
56. ../common/dmaapadp_api_functions.sh
57
58setup_testenvironment
59
60#### TEST BEGIN ####
61
62#Local vars in test script
63##########################
64FLAT_A1_EI="1"
65NUM_JOBS=100 # Mediator and adapter gets same number of jobs
66
67clean_environment
68
69#use_cr_https
70use_cr_http
71use_ecs_rest_https
72use_mr_https
73use_dmaapadp_https
74use_dmaapmed_https
75
76start_kube_proxy
77
78start_cr
79
80start_ecs NOPROXY $SIM_GROUP/$ECS_COMPOSE_DIR/$ECS_CONFIG_FILE
81
82set_ecs_trace
83
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +010084start_mr "unauthenticated.dmaapmed.json" "/events" "dmaapmediatorproducer/STD_Fault_Messages" \
85 "unauthenticated.dmaapadp.json" "/events" "dmaapadapterproducer/msgs" \
86 "unauthenticated.dmaapadp_kafka.text" "/events" "dmaapadapterproducer/msgs"
BjornMagnussonXA663566c2021-11-08 10:25:07 +010087
88start_dmaapadp NOPROXY $SIM_GROUP/$DMAAP_ADP_COMPOSE_DIR/$DMAAP_ADP_CONFIG_FILE $SIM_GROUP/$DMAAP_ADP_COMPOSE_DIR/$DMAAP_ADP_DATA_FILE
89
90set_dmaapadp_trace
91
92start_dmaapmed NOPROXY $SIM_GROUP/$DMAAP_MED_COMPOSE_DIR/$DMAAP_MED_DATA_FILE
93
94ecs_equal json:data-producer/v1/info-producers 2 60
95
96# Check producers
97ecs_api_idc_get_job_ids 200 NOTYPE NOWNER EMPTY
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +010098ecs_api_idc_get_type_ids 200 ExampleInformationType STD_Fault_Messages ExampleInformationTypeKafka
BjornMagnussonXA663566c2021-11-08 10:25:07 +010099ecs_api_edp_get_producer_ids_2 200 NOTYPE DmaapGenericInfoProducer DMaaP_Mediator_Producer
100
101
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +0100102# Create jobs for adapter - CR stores data as MD5 hash
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100103start_timer "Create adapter jobs: $NUM_JOBS"
104for ((i=1; i<=$NUM_JOBS; i++))
105do
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +0100106 ecs_api_idc_put_job 201 job-adp-$i ExampleInformationType $CR_SERVICE_MR_PATH/job-adp-data$i"?storeas=md5" info-owner-adp-$i $CR_SERVICE_APP_PATH/job_status_info-owner-adp-$i testdata/dmaap-adapter/job-template.json
107
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100108done
109print_timer "Create adapter jobs: $NUM_JOBS"
110
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +0100111# Create jobs for adapter kafka - CR stores data as MD5 hash
112start_timer "Create adapter (kafka) jobs: $NUM_JOBS"
113for ((i=1; i<=$NUM_JOBS; i++))
114do
115 ecs_api_idc_put_job 201 job-adp-kafka-$i ExampleInformationTypeKafka $CR_SERVICE_TEXT_PATH/job-adp-kafka-data$i"?storeas=md5" info-owner-adp-kafka-$i $CR_SERVICE_APP_PATH/job_status_info-owner-adp-kafka-$i testdata/dmaap-adapter/job-template-1-kafka.json
116
117done
118print_timer "Create adapter (kafka) jobs: $NUM_JOBS"
119
120# Create jobs for mediator - CR stores data as MD5 hash
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100121start_timer "Create mediator jobs: $NUM_JOBS"
122for ((i=1; i<=$NUM_JOBS; i++))
123do
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +0100124 ecs_api_idc_put_job 201 job-med-$i STD_Fault_Messages $CR_SERVICE_MR_PATH/job-med-data$i"?storeas=md5" info-owner-med-$i $CR_SERVICE_APP_PATH/job_status_info-owner-med-$i testdata/dmaap-adapter/job-template.json
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100125done
126print_timer "Create mediator jobs: $NUM_JOBS"
127
128# Check job status
129for ((i=1; i<=$NUM_JOBS; i++))
130do
131 ecs_api_a1_get_job_status 200 job-med-$i ENABLED 30
132 ecs_api_a1_get_job_status 200 job-adp-$i ENABLED 30
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +0100133 ecs_api_a1_get_job_status 200 job-adp-kafka-$i ENABLED 30
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100134done
135
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +0100136
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100137EXPECTED_DATA_DELIV=0
138
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +0100139mr_api_generate_json_payload_file 1 ./tmp/data_for_dmaap_test.json
140mr_api_generate_text_payload_file 1 ./tmp/data_for_dmaap_test.txt
141
142## Send json file via message-router to adapter
143
144EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
145
146mr_api_send_json_file "/events/unauthenticated.dmaapadp.json" ./tmp/data_for_dmaap_test.json
147cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
148
149EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
150mr_api_send_json_file "/events/unauthenticated.dmaapadp.json" ./tmp/data_for_dmaap_test.json
151cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
152
153EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
154mr_api_send_json_file "/events/unauthenticated.dmaapadp.json" ./tmp/data_for_dmaap_test.json
155cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
156
157EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
158mr_api_send_json_file "/events/unauthenticated.dmaapadp.json" ./tmp/data_for_dmaap_test.json
159cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
160
161EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
162mr_api_send_json_file "/events/unauthenticated.dmaapadp.json" ./tmp/data_for_dmaap_test.json
163cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
164
165# Check received data callbacks from adapter
166for ((i=1; i<=$NUM_JOBS; i++))
167do
168 cr_api_check_single_genric_event_md5_file 200 job-adp-data$i ./tmp/data_for_dmaap_test.json
169 cr_api_check_single_genric_event_md5_file 200 job-adp-data$i ./tmp/data_for_dmaap_test.json
170 cr_api_check_single_genric_event_md5_file 200 job-adp-data$i ./tmp/data_for_dmaap_test.json
171 cr_api_check_single_genric_event_md5_file 200 job-adp-data$i ./tmp/data_for_dmaap_test.json
172 cr_api_check_single_genric_event_md5_file 200 job-adp-data$i ./tmp/data_for_dmaap_test.json
173done
174
175
176## Send text file via message-router to adapter kafka
177
178EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
179
180mr_api_send_text_file "/events/unauthenticated.dmaapadp_kafka.text" ./tmp/data_for_dmaap_test.txt
181cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
182
183EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
184mr_api_send_text_file "/events/unauthenticated.dmaapadp_kafka.text" ./tmp/data_for_dmaap_test.txt
185cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
186
187EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
188mr_api_send_text_file "/events/unauthenticated.dmaapadp_kafka.text" ./tmp/data_for_dmaap_test.txt
189cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
190
191EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
192mr_api_send_text_file "/events/unauthenticated.dmaapadp_kafka.text" ./tmp/data_for_dmaap_test.txt
193cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
194
195EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
196mr_api_send_text_file "/events/unauthenticated.dmaapadp_kafka.text" ./tmp/data_for_dmaap_test.txt
197cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
198
199# Check received data callbacks from adapter kafka
200for ((i=1; i<=$NUM_JOBS; i++))
201do
202 cr_api_check_single_genric_event_md5_file 200 job-adp-kafka-data$i ./tmp/data_for_dmaap_test.txt
203 cr_api_check_single_genric_event_md5_file 200 job-adp-kafka-data$i ./tmp/data_for_dmaap_test.txt
204 cr_api_check_single_genric_event_md5_file 200 job-adp-kafka-data$i ./tmp/data_for_dmaap_test.txt
205 cr_api_check_single_genric_event_md5_file 200 job-adp-kafka-data$i ./tmp/data_for_dmaap_test.txt
206 cr_api_check_single_genric_event_md5_file 200 job-adp-kafka-data$i ./tmp/data_for_dmaap_test.txt
207done
208
209## Send json file via message-router to mediator
210
211EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
212
213mr_api_send_json_file "/events/unauthenticated.dmaapmed.json" ./tmp/data_for_dmaap_test.json
214cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
215
216EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
217mr_api_send_json_file "/events/unauthenticated.dmaapmed.json" ./tmp/data_for_dmaap_test.json
218cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
219
220EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
221mr_api_send_json_file "/events/unauthenticated.dmaapmed.json" ./tmp/data_for_dmaap_test.json
222cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
223
224EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
225mr_api_send_json_file "/events/unauthenticated.dmaapmed.json" ./tmp/data_for_dmaap_test.json
226cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
227
228EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
229mr_api_send_json_file "/events/unauthenticated.dmaapmed.json" ./tmp/data_for_dmaap_test.json
230cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
231
232# Check received data callbacks from mediator
233for ((i=1; i<=$NUM_JOBS; i++))
234do
235 cr_api_check_single_genric_event_md5_file 200 job-med-data$i ./tmp/data_for_dmaap_test.json
236 cr_api_check_single_genric_event_md5_file 200 job-med-data$i ./tmp/data_for_dmaap_test.json
237 cr_api_check_single_genric_event_md5_file 200 job-med-data$i ./tmp/data_for_dmaap_test.json
238 cr_api_check_single_genric_event_md5_file 200 job-med-data$i ./tmp/data_for_dmaap_test.json
239 cr_api_check_single_genric_event_md5_file 200 job-med-data$i ./tmp/data_for_dmaap_test.json
240done
241
242
243# Send small json via message-router to adapter
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100244mr_api_send_json "/events/unauthenticated.dmaapadp.json" '{"msg":"msg-1"}'
245mr_api_send_json "/events/unauthenticated.dmaapadp.json" '{"msg":"msg-3"}'
246
247# Wait for data recetption, adapter
248EXPECTED_DATA_DELIV=$(($NUM_JOBS*2+$EXPECTED_DATA_DELIV))
249start_timer "Data delivery adapter, 2 json per job"
250cr_equal received_callbacks $EXPECTED_DATA_DELIV 100
251print_timer "Data delivery adapter, 2 json per job"
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100252
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +0100253# Send small text via message-routere to adapter
254mr_api_send_text "/events/unauthenticated.dmaapadp_kafka.text" 'Message-------1'
255mr_api_send_text "/events/unauthenticated.dmaapadp_kafka.text" 'Message-------3'
256
257# Wait for data recetption, adapter kafka
258EXPECTED_DATA_DELIV=$(($NUM_JOBS*2+$EXPECTED_DATA_DELIV))
259start_timer "Data delivery adapte kafkar, 2 strings per job"
260cr_equal received_callbacks $EXPECTED_DATA_DELIV 100
261print_timer "Data delivery adapte kafkar, 2 strings per job"
262
263# Send small json via message-router to mediator
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100264mr_api_send_json "/events/unauthenticated.dmaapmed.json" '{"msg":"msg-0"}'
265mr_api_send_json "/events/unauthenticated.dmaapmed.json" '{"msg":"msg-2"}'
266
267# Wait for data reception, mediator
268EXPECTED_DATA_DELIV=$(($NUM_JOBS*2+$EXPECTED_DATA_DELIV))
269start_timer "Data delivery mediator, 2 json per job"
270cr_equal received_callbacks $EXPECTED_DATA_DELIV 100
271print_timer "Data delivery mediator, 2 json per job"
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100272
273# Check received number of messages for mediator and adapter callbacks
274for ((i=1; i<=$NUM_JOBS; i++))
275do
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +0100276 cr_equal received_callbacks?id=job-med-data$i 7
277 cr_equal received_callbacks?id=job-adp-data$i 7
278 cr_equal received_callbacks?id=job-adp-kafka-data$i 7
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100279done
280
281# Check received data and order for mediator and adapter callbacks
282for ((i=1; i<=$NUM_JOBS; i++))
283do
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +0100284 cr_api_check_single_genric_event_md5 200 job-med-data$i '{"msg":"msg-0"}'
285 cr_api_check_single_genric_event_md5 200 job-med-data$i '{"msg":"msg-2"}'
286 cr_api_check_single_genric_event_md5 200 job-adp-data$i '{"msg":"msg-1"}'
287 cr_api_check_single_genric_event_md5 200 job-adp-data$i '{"msg":"msg-3"}'
288 cr_api_check_single_genric_event_md5 200 job-adp-kafka-data$i 'Message-------1'
289 cr_api_check_single_genric_event_md5 200 job-adp-kafka-data$i 'Message-------3'
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100290done
291
292# Set delay in the callback receiver to slow down callbacks
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +0100293SEC_DELAY=2
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100294cr_delay_callback 200 $SEC_DELAY
295
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +0100296# Send small json via message-router to adapter
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100297mr_api_send_json "/events/unauthenticated.dmaapadp.json" '{"msg":"msg-5"}'
298mr_api_send_json "/events/unauthenticated.dmaapadp.json" '{"msg":"msg-7"}'
299
300# Wait for data recetption, adapter
301EXPECTED_DATA_DELIV=$(($NUM_JOBS*2+$EXPECTED_DATA_DELIV))
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +0100302start_timer "Data delivery adapter with $SEC_DELAY seconds delay in consumer, 2 json per job"
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100303cr_equal received_callbacks $EXPECTED_DATA_DELIV $(($NUM_JOBS+300))
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +0100304print_timer "Data delivery adapter with $SEC_DELAY seconds delay in consumer, 2 json per job"
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100305
306
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +0100307# Send small text via message-router to adapter kafka
308mr_api_send_text "/events/unauthenticated.dmaapadp_kafka.text" 'Message-------5'
309mr_api_send_text "/events/unauthenticated.dmaapadp_kafka.text" 'Message-------7'
310
311# Wait for data recetption, adapter kafka
312EXPECTED_DATA_DELIV=$(($NUM_JOBS*2+$EXPECTED_DATA_DELIV))
313start_timer "Data delivery adapter kafka with $SEC_DELAY seconds delay in consumer, 2 strings per job"
314cr_equal received_callbacks $EXPECTED_DATA_DELIV $(($NUM_JOBS+300))
315print_timer "Data delivery adapter with kafka $SEC_DELAY seconds delay in consumer, 2 strings per job"
316
317
318# Send small json via message-router to mediator
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100319mr_api_send_json "/events/unauthenticated.dmaapmed.json" '{"msg":"msg-4"}'
320mr_api_send_json "/events/unauthenticated.dmaapmed.json" '{"msg":"msg-6"}'
321
322# Wait for data reception, mediator
323EXPECTED_DATA_DELIV=$(($NUM_JOBS*2+$EXPECTED_DATA_DELIV))
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +0100324start_timer "Data delivery mediator with $SEC_DELAY seconds delay in consumer, 2 json per job"
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100325cr_equal received_callbacks $EXPECTED_DATA_DELIV 1000
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +0100326print_timer "Data delivery mediator with $SEC_DELAY seconds delay in consumer, 2 json per job"
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100327
328# Check received number of messages for mediator and adapter callbacks
329for ((i=1; i<=$NUM_JOBS; i++))
330do
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +0100331 cr_equal received_callbacks?id=job-med-data$i 9
332 cr_equal received_callbacks?id=job-adp-data$i 9
333 cr_equal received_callbacks?id=job-adp-kafka-data$i 9
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100334done
335
336# Check received data and order for mediator and adapter callbacks
337for ((i=1; i<=$NUM_JOBS; i++))
338do
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +0100339 cr_api_check_single_genric_event_md5 200 job-med-data$i '{"msg":"msg-4"}'
340 cr_api_check_single_genric_event_md5 200 job-med-data$i '{"msg":"msg-6"}'
341 cr_api_check_single_genric_event_md5 200 job-adp-data$i '{"msg":"msg-5"}'
342 cr_api_check_single_genric_event_md5 200 job-adp-data$i '{"msg":"msg-7"}'
343 cr_api_check_single_genric_event_md5 200 job-adp-kafka-data$i 'Message-------5'
344 cr_api_check_single_genric_event_md5 200 job-adp-kafka-data$i 'Message-------7'
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100345done
346
BjornMagnussonXA663566c2021-11-08 10:25:07 +0100347#### TEST COMPLETE ####
348
349store_logs END
350
351print_result
352
BjornMagnussonXA6fc58fd2021-11-18 08:19:45 +0100353auto_clean_environment