blob: 3f50abe6eca30be1ad2cc9cd12da66d1bc61b0b1 [file] [log] [blame]
BjornMagnussonXA8fbb2262022-01-24 15:20:15 +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 with 100 jobs,types and topics"
21
22#App names to include in the test when running docker, space separated list
23DOCKER_INCLUDED_IMAGES="ICS DMAAPMED DMAAPADP KUBEPROXY MR DMAAPMR CR KAFKAPC HTTPPROXY"
24
25#App names to include in the test when running kubernetes, space separated list
26KUBE_INCLUDED_IMAGES=" ICS DMAAPMED DMAAPADP KUBEPROXY MR DMAAPMR CR KAFKAPC HTTPPROXY"
27
BjornMagnussonXAd54225b2023-04-19 14:03:49 +020028#Pre-started app (not started by script) to include in the test when running kubernetes, space separated list
BjornMagnussonXA8fbb2262022-01-24 15:20:15 +010029KUBE_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
BjornMagnussonXAf83c3622023-02-28 10:05:51 +010037SUPPORTED_PROFILES="ORAN-F-RELEASE ORAN-G-RELEASE ORAN-H-RELEASE"
BjornMagnussonXA8fbb2262022-01-24 15:20:15 +010038#Supported run modes
39SUPPORTED_RUNMODES="DOCKER KUBE"
40
41. ../common/testcase_common.sh $@
42
43setup_testenvironment
44
45#### TEST BEGIN ####
46
47#Local vars in test script
48##########################
BjornMagnussonXA7d7cb5f2023-04-11 10:32:56 +020049
BjornMagnussonXA8fbb2262022-01-24 15:20:15 +010050NUM_CR=1 # Number of callback receivers, max 1
51## Note: The number jobs must be a multiple of the number of CRs in order to calculate the number of expected event in each CR
52NUM_JOBS=100 # Mediator and adapter gets same number of jobs for every type
53if [ $NUM_CR -gt 1 ]; then
54 __log_conf_fail_general "Max number of callback receivers is one in this test"
55fi
56
57clean_environment
58
59#use_cr_https
60use_cr_http
61use_ics_rest_https
62use_mr_https
63use_dmaapadp_https
64use_dmaapmed_https
65
66start_kube_proxy
67
68start_cr $NUM_CR
69
70start_ics NOPROXY $SIM_GROUP/$ICS_COMPOSE_DIR/$ICS_CONFIG_FILE
71
72set_ics_trace
73
74start_mr
75
76start_kafkapc
77
78for ((i=1; i<=$NUM_JOBS; i++))
79do
80 kafkapc_api_create_topic 201 "unauthenticated.dmaapadp_kafka.text$i" "text/plain"
81
82 kafkapc_api_start_sending 200 "unauthenticated.dmaapadp_kafka.text$i"
83done
84
85adp_med_type_list=""
86adp_config_data='{"types": ['
87for ((i=1; i<=$NUM_JOBS; i++))
88do
89 if [ $i -ne 1 ]; then
90 adp_config_data=$adp_config_data','
91 fi
92 adp_config_data=$adp_config_data'{"id": "ADPKafkaType'$i'","kafkaInputTopic": "unauthenticated.dmaapadp_kafka.text'$i'","useHttpProxy": false}'
93 adp_med_type_list="$adp_med_type_list ADPKafkaType$i "
94done
95adp_config_data=$adp_config_data']}'
96echo $adp_config_data > tmp/adp_config_data.json
97
BjornMagnussonXA8fbc6362022-04-19 09:39:22 +020098start_dmaapadp NOPROXY $SIM_GROUP/$DMAAP_ADP_COMPOSE_DIR/$DMAAP_ADP_CONFIG_FILE_TEMPLATE tmp/adp_config_data.json
BjornMagnussonXA8fbb2262022-01-24 15:20:15 +010099
100set_dmaapadp_trace
101
102if [[ "$DMAAP_MED_FEATURE_LEVEL" == *"KAFKATYPES"* ]]; then
103 for ((i=1; i<=$NUM_JOBS; i++))
104 do
105 kafkapc_api_create_topic 201 "unauthenticated.dmaapmed_kafka.text$i" "text/plain"
106
107 kafkapc_api_start_sending 200 "unauthenticated.dmaapmed_kafka.text$i"
108 done
109fi
110
111med_config_data='{"types": ['
112for ((i=1; i<=$NUM_JOBS; i++))
113do
114 if [ $i -ne 1 ]; then
115 med_config_data=$med_config_data','
116 fi
117 med_config_data=$med_config_data'{"id": "MEDKafkaType'$i'","kafkaInputTopic": "unauthenticated.dmaapmed_kafka.text'$i'"}'
118 adp_med_type_list="$adp_med_type_list MEDKafkaType$i "
119done
120med_config_data=$med_config_data']}'
121echo $med_config_data > tmp/med_config_data.json
122
123start_dmaapmed NOPROXY tmp/med_config_data.json
124
125ics_equal json:data-producer/v1/info-producers 2 60
126
127# Check producers
128ics_api_idc_get_job_ids 200 NOTYPE NOWNER EMPTY
BjornMagnussonXAf81090f2022-08-24 09:17:44 +0200129if [[ "$DMAAP_ADP_FEATURE_LEVEL" == *"GENERATED_PROD_NAME"* ]]; then
130 if [ $RUNMODE == "KUBE" ]; then
131 __NAME="https:__$DMAAP_ADP_APP_NAME.$KUBE_NONRTRIC_NAMESPACE:$DMAAP_ADP_EXTERNAL_SECURE_PORT"
132 else
133 __NAME="https:__$DMAAP_ADP_APP_NAME:$DMAAP_ADP_INTERNAL_SECURE_PORT"
134 fi
135 ics_api_edp_get_producer_ids_2 200 NOTYPE $__NAME DMaaP_Mediator_Producer
136else
137 ics_api_edp_get_producer_ids_2 200 NOTYPE DmaapGenericInfoProducer DMaaP_Mediator_Producer
138fi
139
BjornMagnussonXA8fbb2262022-01-24 15:20:15 +0100140ics_api_idc_get_type_ids 200 $adp_med_type_list
141
142
143# Create jobs for adapter kafka - CR stores data as MD5 hash
144start_timer "Create adapter (kafka) jobs: $NUM_JOBS"
145for ((i=1; i<=$NUM_JOBS; i++))
146do
BjornMagnussonXAd54225b2023-04-19 14:03:49 +0200147 # Max buffer timeout for is about 160 sec for Adapter jobs"
BjornMagnussonXA8fbb2262022-01-24 15:20:15 +0100148 adp_timeout=$(($i*1000))
BjornMagnussonXA23d69b42023-02-03 15:13:53 +0100149 if [[ "$DMAAP_ADP_FEATURE_LEVEL" == *"FILTERSPEC"* ]]; then
150 deviation "It is possible to give filter without filtertype without error indication"
151 if [[ "$DMAAP_ADP_FEATURE_LEVEL" == *"FILTERSCHEMA"* ]]; then
152 adp_config_data='{"filterType": "regexp", "filter":"Message*","maxConcurrency": 1,"bufferTimeout": {"maxSize": 100,"maxTimeMilliseconds": '$adp_timeout'}}'
153 else
154 adp_config_data='{"filterType": "regexp", "filter":"Message*","maxConcurrency": 1,"bufferTimeout": {"maxSize": 100,"maxTimeMiliseconds": '$adp_timeout'}}'
155 fi
156 else
157 if [[ "$DMAAP_ADP_FEATURE_LEVEL" == *"FILTERSCHEMA"* ]]; then
158 adp_config_data='{"filter":"Message*","maxConcurrency": 1,"bufferTimeout": {"maxSize": 100,"maxTimeMilliseconds": '$adp_timeout'}}'
159 else
160 adp_config_data='{"filter":"Message*","maxConcurrency": 1,"bufferTimeout": {"maxSize": 100,"maxTimeMiliseconds": '$adp_timeout'}}'
161 fi
162 fi
BjornMagnussonXA8fbb2262022-01-24 15:20:15 +0100163 echo $adp_config_data > tmp/adp_config_data.json
164
165 cr_index=$(($i%$NUM_CR))
166 service_text="CR_SERVICE_TEXT_PATH_"$cr_index
167 service_app="CR_SERVICE_APP_PATH_"$cr_index
168 ics_api_idc_put_job 201 job-adp-kafka-$i "ADPKafkaType$i" ${!service_text}/job-adp-kafka-data$i"?storeas=md5" info-owner-adp-kafka-$i ${!service_app}/callbacks-null tmp/adp_config_data.json
169
170done
171print_timer
172
173if [[ "$DMAAP_MED_FEATURE_LEVEL" == *"KAFKATYPES"* ]]; then
174 # Create jobs for mediator kafka - CR stores data as MD5 hash
175 start_timer "Create mediator (kafka) jobs: $NUM_JOBS"
176 for ((i=1; i<=$NUM_JOBS; i++))
177 do
178 med_timeout=$(($i*5000))
BjornMagnussonXA23d69b42023-02-03 15:13:53 +0100179 if [[ "$DMAAP_MED_FEATURE_LEVEL" == *"FILTERSCHEMA"* ]]; then
180 med_config_data='{"bufferTimeout": {"maxSize": 100,"maxTimeMilliseconds": '$med_timeout'}}'
181 else
182 med_config_data='{"bufferTimeout": {"maxSize": 100,"maxTimeMiliseconds": '$med_timeout'}}'
183 fi
BjornMagnussonXA8fbb2262022-01-24 15:20:15 +0100184 echo $med_config_data > tmp/med_config_data.json
185 cr_index=$(($i%$NUM_CR))
186 service_text="CR_SERVICE_TEXT_PATH_"$cr_index
187 service_app="CR_SERVICE_APP_PATH_"$cr_index
188 ics_api_idc_put_job 201 job-med-kafka-$i "MEDKafkaType$i" ${!service_text}/job-med-kafka-data$i"?storeas=md5" info-owner-med-kafka-$i ${!service_app}/callbacks-null tmp/med_config_data.json
189 done
190 print_timer
191fi
192
193# Check job status
194for ((i=1; i<=$NUM_JOBS; i++))
195do
196 ics_api_a1_get_job_status 200 job-adp-kafka-$i ENABLED 30
197 if [[ "$DMAAP_MED_FEATURE_LEVEL" == *"KAFKATYPES"* ]]; then
198 ics_api_a1_get_job_status 200 job-med-kafka-$i ENABLED 30
199 fi
200done
201
202
203EXPECTED_DATA_DELIV=0 #Total delivered msg per CR
204EXPECTED_BATCHES_DELIV=0 #Total delivered batches per CR
205DATA_DELIV_JOBS=0 #Total delivered msg per job per CR
206
207sleep_wait 60
208
209start_timer "Data delivery adapter kafka, 2 strings per job (short buffer timeouts)"
210# Send small text via message-router to adapter
211for ((i=1; i<=$NUM_JOBS; i++))
212do
213 kafkapc_api_post_msg 200 "unauthenticated.dmaapadp_kafka.text"$i "text/plain" 'Message-------1'$i
214 kafkapc_api_post_msg 200 "unauthenticated.dmaapadp_kafka.text"$i "text/plain" 'Discard-------3'$i #Should be filtered out
215 kafkapc_api_post_msg 200 "unauthenticated.dmaapadp_kafka.text"$i "text/plain" 'Message-------3'$i
216done
217for ((i=1; i<=$NUM_JOBS; i++))
218do
219 kafkapc_equal topics/unauthenticated.dmaapadp_kafka.text$i/counters/sent 3 30
220done
221
BjornMagnussonXAd54225b2023-04-19 14:03:49 +0200222# Wait for data reception, adapter kafka
BjornMagnussonXA8fbb2262022-01-24 15:20:15 +0100223EXPECTED_DATA_DELIV=$(($NUM_JOBS*2/$NUM_CR+$EXPECTED_DATA_DELIV))
224EXPECTED_BATCHES_DELIV=$(($NUM_JOBS/$NUM_CR+$EXPECTED_BATCHES_DELIV))
225
226adp_timeout=$(($NUM_JOBS*1*2+60)) #NUM_JOBS*MIN_BUFFERTIMEOUT*2+60_SEC_DELAY
227for ((i=0; i<$NUM_CR; i++))
228do
BjornMagnussonXA8fbb2262022-01-24 15:20:15 +0100229 cr_equal $i received_callbacks $EXPECTED_DATA_DELIV $adp_timeout
230 cr_greater_or_equal $i received_callback_batches $EXPECTED_BATCHES_DELIV
231done
232print_timer
233
234# Check received data callbacks from adapter
235for ((i=1; i<=$NUM_JOBS; i++))
236do
237 cr_index=$(($i%$NUM_CR))
BjornMagnussonXAd54225b2023-04-19 14:03:49 +0200238 cr_api_check_single_generic_event_md5 200 $cr_index job-adp-kafka-data$i 'Message-------1'$i
239 cr_api_check_single_generic_event_md5 200 $cr_index job-adp-kafka-data$i 'Message-------3'$i
BjornMagnussonXA8fbb2262022-01-24 15:20:15 +0100240done
241
242if [[ "$DMAAP_MED_FEATURE_LEVEL" == *"KAFKATYPES"* ]]; then
243
244 PREV_DATA_DELIV=$(cr_read 0 received_callbacks)
245 PREV_BATCHES_DELIV=$(cr_read 0 received_callback_batches)
246 start_timer "Data delivery mediator kafka, 2 strings per job (long buffer timeouts)"
247 # Send small text via message-router to mediator
248 for ((i=1; i<=$NUM_JOBS; i++))
249 do
250 kafkapc_api_post_msg 200 "unauthenticated.dmaapmed_kafka.text$i" "text/plain" 'Message-------0'$i
251 kafkapc_api_post_msg 200 "unauthenticated.dmaapmed_kafka.text$i" "text/plain" 'Message-------2'$i
252 done
253 for ((i=1; i<=$NUM_JOBS; i++))
254 do
255 kafkapc_equal topics/unauthenticated.dmaapmed_kafka.text$i/counters/sent 2 30
256 done
257
BjornMagnussonXAd54225b2023-04-19 14:03:49 +0200258 # Wait for data reception, adapter kafka
BjornMagnussonXA8fbb2262022-01-24 15:20:15 +0100259
260 EXPECTED_DATA_DELIV=$(($NUM_JOBS*2/$NUM_CR+$PREV_DATA_DELIV))
261 EXPECTED_BATCHES_DELIV=$(($NUM_JOBS/$NUM_CR+$PREV_BATCHES_DELIV))
262
263 med_timeout=$(($NUM_JOBS*5*2+60)) #NUM_JOBS*MIN_BUFFERTIMEOUT*2+60_SEC_DELAY
264 for ((i=0; i<$NUM_CR; i++))
265 do
266 cr_equal $i received_callbacks $EXPECTED_DATA_DELIV $med_timeout
267 cr_greater_or_equal $i received_callback_batches $EXPECTED_BATCHES_DELIV
268 done
269
270 print_timer
271
272 # Check received data callbacks from mediator
273 for ((i=1; i<=$NUM_JOBS; i++))
274 do
275 cr_index=$(($i%$NUM_CR))
BjornMagnussonXAd54225b2023-04-19 14:03:49 +0200276 cr_api_check_single_generic_event_md5 200 $cr_index job-med-kafka-data$i 'Message-------0'$i
277 cr_api_check_single_generic_event_md5 200 $cr_index job-med-kafka-data$i 'Message-------2'$i
BjornMagnussonXA8fbb2262022-01-24 15:20:15 +0100278 done
279fi
280
281#### TEST COMPLETE ####
282
283store_logs END
284
285print_result
286
287auto_clean_environment