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
10 # http://www.apache.org/licenses/LICENSE-2.0
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=================================================
20 TC_ONELINE_DESCR="App test DMAAP Meditor and DMAAP Adapter"
22 #App names to include in the test when running docker, space separated list
23 DOCKER_INCLUDED_IMAGES="ECS DMAAPMED DMAAPADP KUBEPROXY MR DMAAPMR CR"
25 #App names to include in the test when running kubernetes, space separated list
26 KUBE_INCLUDED_IMAGES=" ECS DMAAPMED DMAAPADP KUBEPROXY MR DMAAPMR CR"
28 #Prestarted app (not started by script) to include in the test when running kubernetes, space separated list
29 KUBE_PRESTARTED_IMAGES=""
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
34 CONDITIONALLY_IGNORED_IMAGES=""
36 #Supported test environment profiles
37 SUPPORTED_PROFILES="ORAN-E-RELEASE"
39 SUPPORTED_RUNMODES="DOCKER KUBE"
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
62 #Local vars in test script
63 ##########################
65 NUM_JOBS=100 # Mediator and adapter gets same number of jobs
80 start_ecs NOPROXY $SIM_GROUP/$ECS_COMPOSE_DIR/$ECS_CONFIG_FILE
84 start_mr "unauthenticated.dmaapmed.json" "/events" "dmaapmediatorproducer/STD_Fault_Messages" \
85 "unauthenticated.dmaapadp.json" "/events" "dmaapadapterproducer/msgs" \
86 "unauthenticated.dmaapadp_kafka.text" "/events" "dmaapadapterproducer/msgs"
88 start_dmaapadp NOPROXY $SIM_GROUP/$DMAAP_ADP_COMPOSE_DIR/$DMAAP_ADP_CONFIG_FILE $SIM_GROUP/$DMAAP_ADP_COMPOSE_DIR/$DMAAP_ADP_DATA_FILE
92 start_dmaapmed NOPROXY $SIM_GROUP/$DMAAP_MED_COMPOSE_DIR/$DMAAP_MED_DATA_FILE
94 ecs_equal json:data-producer/v1/info-producers 2 60
97 ecs_api_idc_get_job_ids 200 NOTYPE NOWNER EMPTY
98 ecs_api_idc_get_type_ids 200 ExampleInformationType STD_Fault_Messages ExampleInformationTypeKafka
99 ecs_api_edp_get_producer_ids_2 200 NOTYPE DmaapGenericInfoProducer DMaaP_Mediator_Producer
102 # Create jobs for adapter - CR stores data as MD5 hash
103 start_timer "Create adapter jobs: $NUM_JOBS"
104 for ((i=1; i<=$NUM_JOBS; i++))
106 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
109 print_timer "Create adapter jobs: $NUM_JOBS"
111 # Create jobs for adapter kafka - CR stores data as MD5 hash
112 start_timer "Create adapter (kafka) jobs: $NUM_JOBS"
113 for ((i=1; i<=$NUM_JOBS; i++))
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
118 print_timer "Create adapter (kafka) jobs: $NUM_JOBS"
120 # Create jobs for mediator - CR stores data as MD5 hash
121 start_timer "Create mediator jobs: $NUM_JOBS"
122 for ((i=1; i<=$NUM_JOBS; i++))
124 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
126 print_timer "Create mediator jobs: $NUM_JOBS"
129 for ((i=1; i<=$NUM_JOBS; i++))
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
133 ecs_api_a1_get_job_status 200 job-adp-kafka-$i ENABLED 30
137 EXPECTED_DATA_DELIV=0
139 mr_api_generate_json_payload_file 1 ./tmp/data_for_dmaap_test.json
140 mr_api_generate_text_payload_file 1 ./tmp/data_for_dmaap_test.txt
142 ## Send json file via message-router to adapter
144 EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
146 mr_api_send_json_file "/events/unauthenticated.dmaapadp.json" ./tmp/data_for_dmaap_test.json
147 cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
149 EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
150 mr_api_send_json_file "/events/unauthenticated.dmaapadp.json" ./tmp/data_for_dmaap_test.json
151 cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
153 EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
154 mr_api_send_json_file "/events/unauthenticated.dmaapadp.json" ./tmp/data_for_dmaap_test.json
155 cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
157 EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
158 mr_api_send_json_file "/events/unauthenticated.dmaapadp.json" ./tmp/data_for_dmaap_test.json
159 cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
161 EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
162 mr_api_send_json_file "/events/unauthenticated.dmaapadp.json" ./tmp/data_for_dmaap_test.json
163 cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
165 # Check received data callbacks from adapter
166 for ((i=1; i<=$NUM_JOBS; i++))
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
176 ## Send text file via message-router to adapter kafka
178 EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
180 mr_api_send_text_file "/events/unauthenticated.dmaapadp_kafka.text" ./tmp/data_for_dmaap_test.txt
181 cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
183 EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
184 mr_api_send_text_file "/events/unauthenticated.dmaapadp_kafka.text" ./tmp/data_for_dmaap_test.txt
185 cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
187 EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
188 mr_api_send_text_file "/events/unauthenticated.dmaapadp_kafka.text" ./tmp/data_for_dmaap_test.txt
189 cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
191 EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
192 mr_api_send_text_file "/events/unauthenticated.dmaapadp_kafka.text" ./tmp/data_for_dmaap_test.txt
193 cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
195 EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
196 mr_api_send_text_file "/events/unauthenticated.dmaapadp_kafka.text" ./tmp/data_for_dmaap_test.txt
197 cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
199 # Check received data callbacks from adapter kafka
200 for ((i=1; i<=$NUM_JOBS; i++))
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
209 ## Send json file via message-router to mediator
211 EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
213 mr_api_send_json_file "/events/unauthenticated.dmaapmed.json" ./tmp/data_for_dmaap_test.json
214 cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
216 EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
217 mr_api_send_json_file "/events/unauthenticated.dmaapmed.json" ./tmp/data_for_dmaap_test.json
218 cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
220 EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
221 mr_api_send_json_file "/events/unauthenticated.dmaapmed.json" ./tmp/data_for_dmaap_test.json
222 cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
224 EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
225 mr_api_send_json_file "/events/unauthenticated.dmaapmed.json" ./tmp/data_for_dmaap_test.json
226 cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
228 EXPECTED_DATA_DELIV=$(($NUM_JOBS+$EXPECTED_DATA_DELIV))
229 mr_api_send_json_file "/events/unauthenticated.dmaapmed.json" ./tmp/data_for_dmaap_test.json
230 cr_equal received_callbacks $EXPECTED_DATA_DELIV 200
232 # Check received data callbacks from mediator
233 for ((i=1; i<=$NUM_JOBS; i++))
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
243 # Send small json via message-router to adapter
244 mr_api_send_json "/events/unauthenticated.dmaapadp.json" '{"msg":"msg-1"}'
245 mr_api_send_json "/events/unauthenticated.dmaapadp.json" '{"msg":"msg-3"}'
247 # Wait for data recetption, adapter
248 EXPECTED_DATA_DELIV=$(($NUM_JOBS*2+$EXPECTED_DATA_DELIV))
249 start_timer "Data delivery adapter, 2 json per job"
250 cr_equal received_callbacks $EXPECTED_DATA_DELIV 100
251 print_timer "Data delivery adapter, 2 json per job"
253 # Send small text via message-routere to adapter
254 mr_api_send_text "/events/unauthenticated.dmaapadp_kafka.text" 'Message-------1'
255 mr_api_send_text "/events/unauthenticated.dmaapadp_kafka.text" 'Message-------3'
257 # Wait for data recetption, adapter kafka
258 EXPECTED_DATA_DELIV=$(($NUM_JOBS*2+$EXPECTED_DATA_DELIV))
259 start_timer "Data delivery adapte kafkar, 2 strings per job"
260 cr_equal received_callbacks $EXPECTED_DATA_DELIV 100
261 print_timer "Data delivery adapte kafkar, 2 strings per job"
263 # Send small json via message-router to mediator
264 mr_api_send_json "/events/unauthenticated.dmaapmed.json" '{"msg":"msg-0"}'
265 mr_api_send_json "/events/unauthenticated.dmaapmed.json" '{"msg":"msg-2"}'
267 # Wait for data reception, mediator
268 EXPECTED_DATA_DELIV=$(($NUM_JOBS*2+$EXPECTED_DATA_DELIV))
269 start_timer "Data delivery mediator, 2 json per job"
270 cr_equal received_callbacks $EXPECTED_DATA_DELIV 100
271 print_timer "Data delivery mediator, 2 json per job"
273 # Check received number of messages for mediator and adapter callbacks
274 for ((i=1; i<=$NUM_JOBS; i++))
276 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
281 # Check received data and order for mediator and adapter callbacks
282 for ((i=1; i<=$NUM_JOBS; i++))
284 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'
292 # Set delay in the callback receiver to slow down callbacks
294 cr_delay_callback 200 $SEC_DELAY
296 # Send small json via message-router to adapter
297 mr_api_send_json "/events/unauthenticated.dmaapadp.json" '{"msg":"msg-5"}'
298 mr_api_send_json "/events/unauthenticated.dmaapadp.json" '{"msg":"msg-7"}'
300 # Wait for data recetption, adapter
301 EXPECTED_DATA_DELIV=$(($NUM_JOBS*2+$EXPECTED_DATA_DELIV))
302 start_timer "Data delivery adapter with $SEC_DELAY seconds delay in consumer, 2 json per job"
303 cr_equal received_callbacks $EXPECTED_DATA_DELIV $(($NUM_JOBS+300))
304 print_timer "Data delivery adapter with $SEC_DELAY seconds delay in consumer, 2 json per job"
307 # Send small text via message-router to adapter kafka
308 mr_api_send_text "/events/unauthenticated.dmaapadp_kafka.text" 'Message-------5'
309 mr_api_send_text "/events/unauthenticated.dmaapadp_kafka.text" 'Message-------7'
311 # Wait for data recetption, adapter kafka
312 EXPECTED_DATA_DELIV=$(($NUM_JOBS*2+$EXPECTED_DATA_DELIV))
313 start_timer "Data delivery adapter kafka with $SEC_DELAY seconds delay in consumer, 2 strings per job"
314 cr_equal received_callbacks $EXPECTED_DATA_DELIV $(($NUM_JOBS+300))
315 print_timer "Data delivery adapter with kafka $SEC_DELAY seconds delay in consumer, 2 strings per job"
318 # Send small json via message-router to mediator
319 mr_api_send_json "/events/unauthenticated.dmaapmed.json" '{"msg":"msg-4"}'
320 mr_api_send_json "/events/unauthenticated.dmaapmed.json" '{"msg":"msg-6"}'
322 # Wait for data reception, mediator
323 EXPECTED_DATA_DELIV=$(($NUM_JOBS*2+$EXPECTED_DATA_DELIV))
324 start_timer "Data delivery mediator with $SEC_DELAY seconds delay in consumer, 2 json per job"
325 cr_equal received_callbacks $EXPECTED_DATA_DELIV 1000
326 print_timer "Data delivery mediator with $SEC_DELAY seconds delay in consumer, 2 json per job"
328 # Check received number of messages for mediator and adapter callbacks
329 for ((i=1; i<=$NUM_JOBS; i++))
331 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
336 # Check received data and order for mediator and adapter callbacks
337 for ((i=1; i<=$NUM_JOBS; i++))
339 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'
347 #### TEST COMPLETE ####
353 auto_clean_environment