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 with 100 jobs,types and topics"
22 #App names to include in the test when running docker, space separated list
23 DOCKER_INCLUDED_IMAGES="ICS DMAAPMED DMAAPADP KUBEPROXY MR DMAAPMR CR KAFKAPC HTTPPROXY"
25 #App names to include in the test when running kubernetes, space separated list
26 KUBE_INCLUDED_IMAGES=" ICS DMAAPMED DMAAPADP KUBEPROXY MR DMAAPMR CR KAFKAPC HTTPPROXY"
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 ORAN-F-RELEASE"
39 SUPPORTED_RUNMODES="DOCKER KUBE"
41 . ../common/testcase_common.sh $@
47 #Local vars in test script
48 ##########################
50 NUM_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
52 NUM_JOBS=100 # Mediator and adapter gets same number of jobs for every type
53 if [ $NUM_CR -gt 1 ]; then
54 __log_conf_fail_general "Max number of callback receivers is one in this test"
70 start_ics NOPROXY $SIM_GROUP/$ICS_COMPOSE_DIR/$ICS_CONFIG_FILE
78 for ((i=1; i<=$NUM_JOBS; i++))
80 kafkapc_api_create_topic 201 "unauthenticated.dmaapadp_kafka.text$i" "text/plain"
82 kafkapc_api_start_sending 200 "unauthenticated.dmaapadp_kafka.text$i"
86 adp_config_data='{"types": ['
87 for ((i=1; i<=$NUM_JOBS; i++))
90 adp_config_data=$adp_config_data','
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 "
95 adp_config_data=$adp_config_data']}'
96 echo $adp_config_data > tmp/adp_config_data.json
98 start_dmaapadp NOPROXY $SIM_GROUP/$DMAAP_ADP_COMPOSE_DIR/$DMAAP_ADP_CONFIG_FILE_TEMPLATE tmp/adp_config_data.json
102 if [[ "$DMAAP_MED_FEATURE_LEVEL" == *"KAFKATYPES"* ]]; then
103 for ((i=1; i<=$NUM_JOBS; i++))
105 kafkapc_api_create_topic 201 "unauthenticated.dmaapmed_kafka.text$i" "text/plain"
107 kafkapc_api_start_sending 200 "unauthenticated.dmaapmed_kafka.text$i"
111 med_config_data='{"types": ['
112 for ((i=1; i<=$NUM_JOBS; i++))
114 if [ $i -ne 1 ]; then
115 med_config_data=$med_config_data','
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 "
120 med_config_data=$med_config_data']}'
121 echo $med_config_data > tmp/med_config_data.json
123 start_dmaapmed NOPROXY tmp/med_config_data.json
125 ics_equal json:data-producer/v1/info-producers 2 60
128 ics_api_idc_get_job_ids 200 NOTYPE NOWNER EMPTY
129 ics_api_edp_get_producer_ids_2 200 NOTYPE DmaapGenericInfoProducer DMaaP_Mediator_Producer
130 ics_api_idc_get_type_ids 200 $adp_med_type_list
133 # Create jobs for adapter kafka - CR stores data as MD5 hash
134 start_timer "Create adapter (kafka) jobs: $NUM_JOBS"
135 for ((i=1; i<=$NUM_JOBS; i++))
137 # Max buffer timeout for is about 160 sec for Adator jobs"
138 adp_timeout=$(($i*1000))
139 adp_config_data='{"filter":"Message*","maxConcurrency": 1,"bufferTimeout": {"maxSize": 100,"maxTimeMiliseconds": '$adp_timeout'}}'
140 echo $adp_config_data > tmp/adp_config_data.json
142 cr_index=$(($i%$NUM_CR))
143 service_text="CR_SERVICE_TEXT_PATH_"$cr_index
144 service_app="CR_SERVICE_APP_PATH_"$cr_index
145 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
150 if [[ "$DMAAP_MED_FEATURE_LEVEL" == *"KAFKATYPES"* ]]; then
151 # Create jobs for mediator kafka - CR stores data as MD5 hash
152 start_timer "Create mediator (kafka) jobs: $NUM_JOBS"
153 for ((i=1; i<=$NUM_JOBS; i++))
155 med_timeout=$(($i*5000))
156 med_config_data='{"bufferTimeout": {"maxSize": 100,"maxTimeMiliseconds": '$med_timeout'}}'
157 echo $med_config_data > tmp/med_config_data.json
158 cr_index=$(($i%$NUM_CR))
159 service_text="CR_SERVICE_TEXT_PATH_"$cr_index
160 service_app="CR_SERVICE_APP_PATH_"$cr_index
161 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
167 for ((i=1; i<=$NUM_JOBS; i++))
169 ics_api_a1_get_job_status 200 job-adp-kafka-$i ENABLED 30
170 if [[ "$DMAAP_MED_FEATURE_LEVEL" == *"KAFKATYPES"* ]]; then
171 ics_api_a1_get_job_status 200 job-med-kafka-$i ENABLED 30
176 EXPECTED_DATA_DELIV=0 #Total delivered msg per CR
177 EXPECTED_BATCHES_DELIV=0 #Total delivered batches per CR
178 DATA_DELIV_JOBS=0 #Total delivered msg per job per CR
182 start_timer "Data delivery adapter kafka, 2 strings per job (short buffer timeouts)"
183 # Send small text via message-router to adapter
184 for ((i=1; i<=$NUM_JOBS; i++))
186 kafkapc_api_post_msg 200 "unauthenticated.dmaapadp_kafka.text"$i "text/plain" 'Message-------1'$i
187 kafkapc_api_post_msg 200 "unauthenticated.dmaapadp_kafka.text"$i "text/plain" 'Discard-------3'$i #Should be filtered out
188 kafkapc_api_post_msg 200 "unauthenticated.dmaapadp_kafka.text"$i "text/plain" 'Message-------3'$i
190 for ((i=1; i<=$NUM_JOBS; i++))
192 kafkapc_equal topics/unauthenticated.dmaapadp_kafka.text$i/counters/sent 3 30
195 # Wait for data recetption, adapter kafka
196 EXPECTED_DATA_DELIV=$(($NUM_JOBS*2/$NUM_CR+$EXPECTED_DATA_DELIV))
197 EXPECTED_BATCHES_DELIV=$(($NUM_JOBS/$NUM_CR+$EXPECTED_BATCHES_DELIV))
199 adp_timeout=$(($NUM_JOBS*1*2+60)) #NUM_JOBS*MIN_BUFFERTIMEOUT*2+60_SEC_DELAY
200 for ((i=0; i<$NUM_CR; i++))
202 cr_equal $i received_callbacks $EXPECTED_DATA_DELIV $adp_timeout
203 cr_greater_or_equal $i received_callback_batches $EXPECTED_BATCHES_DELIV
207 # Check received data callbacks from adapter
208 for ((i=1; i<=$NUM_JOBS; i++))
210 cr_index=$(($i%$NUM_CR))
211 cr_api_check_single_genric_event_md5 200 $cr_index job-adp-kafka-data$i 'Message-------1'$i
212 cr_api_check_single_genric_event_md5 200 $cr_index job-adp-kafka-data$i 'Message-------3'$i
215 if [[ "$DMAAP_MED_FEATURE_LEVEL" == *"KAFKATYPES"* ]]; then
217 PREV_DATA_DELIV=$(cr_read 0 received_callbacks)
218 PREV_BATCHES_DELIV=$(cr_read 0 received_callback_batches)
219 start_timer "Data delivery mediator kafka, 2 strings per job (long buffer timeouts)"
220 # Send small text via message-router to mediator
221 for ((i=1; i<=$NUM_JOBS; i++))
223 kafkapc_api_post_msg 200 "unauthenticated.dmaapmed_kafka.text$i" "text/plain" 'Message-------0'$i
224 kafkapc_api_post_msg 200 "unauthenticated.dmaapmed_kafka.text$i" "text/plain" 'Message-------2'$i
226 for ((i=1; i<=$NUM_JOBS; i++))
228 kafkapc_equal topics/unauthenticated.dmaapmed_kafka.text$i/counters/sent 2 30
231 # Wait for data recetption, adapter kafka
233 EXPECTED_DATA_DELIV=$(($NUM_JOBS*2/$NUM_CR+$PREV_DATA_DELIV))
234 EXPECTED_BATCHES_DELIV=$(($NUM_JOBS/$NUM_CR+$PREV_BATCHES_DELIV))
236 med_timeout=$(($NUM_JOBS*5*2+60)) #NUM_JOBS*MIN_BUFFERTIMEOUT*2+60_SEC_DELAY
237 for ((i=0; i<$NUM_CR; i++))
239 cr_equal $i received_callbacks $EXPECTED_DATA_DELIV $med_timeout
240 cr_greater_or_equal $i received_callback_batches $EXPECTED_BATCHES_DELIV
245 # Check received data callbacks from mediator
246 for ((i=1; i<=$NUM_JOBS; i++))
248 cr_index=$(($i%$NUM_CR))
249 cr_api_check_single_genric_event_md5 200 $cr_index job-med-kafka-data$i 'Message-------0'$i
250 cr_api_check_single_genric_event_md5 200 $cr_index job-med-kafka-data$i 'Message-------2'$i
254 #### TEST COMPLETE ####
260 auto_clean_environment