BjornMagnussonXA | 8fbb226 | 2022-01-24 15:20:15 +0100 | [diff] [blame] | 1 | #!/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 | |
| 20 | TC_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 |
| 23 | DOCKER_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 |
| 26 | KUBE_INCLUDED_IMAGES=" ICS DMAAPMED DMAAPADP KUBEPROXY MR DMAAPMR CR KAFKAPC HTTPPROXY" |
| 27 | |
BjornMagnussonXA | d54225b | 2023-04-19 14:03:49 +0200 | [diff] [blame] | 28 | #Pre-started app (not started by script) to include in the test when running kubernetes, space separated list |
BjornMagnussonXA | 8fbb226 | 2022-01-24 15:20:15 +0100 | [diff] [blame] | 29 | KUBE_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 |
| 34 | CONDITIONALLY_IGNORED_IMAGES="" |
| 35 | |
| 36 | #Supported test environment profiles |
BjornMagnussonXA | f83c362 | 2023-02-28 10:05:51 +0100 | [diff] [blame] | 37 | SUPPORTED_PROFILES="ORAN-F-RELEASE ORAN-G-RELEASE ORAN-H-RELEASE" |
BjornMagnussonXA | 8fbb226 | 2022-01-24 15:20:15 +0100 | [diff] [blame] | 38 | #Supported run modes |
| 39 | SUPPORTED_RUNMODES="DOCKER KUBE" |
| 40 | |
| 41 | . ../common/testcase_common.sh $@ |
| 42 | |
| 43 | setup_testenvironment |
| 44 | |
| 45 | #### TEST BEGIN #### |
| 46 | |
| 47 | #Local vars in test script |
| 48 | ########################## |
BjornMagnussonXA | 7d7cb5f | 2023-04-11 10:32:56 +0200 | [diff] [blame] | 49 | |
BjornMagnussonXA | 8fbb226 | 2022-01-24 15:20:15 +0100 | [diff] [blame] | 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" |
| 55 | fi |
| 56 | |
| 57 | clean_environment |
| 58 | |
| 59 | #use_cr_https |
| 60 | use_cr_http |
| 61 | use_ics_rest_https |
| 62 | use_mr_https |
| 63 | use_dmaapadp_https |
| 64 | use_dmaapmed_https |
| 65 | |
| 66 | start_kube_proxy |
| 67 | |
| 68 | start_cr $NUM_CR |
| 69 | |
| 70 | start_ics NOPROXY $SIM_GROUP/$ICS_COMPOSE_DIR/$ICS_CONFIG_FILE |
| 71 | |
| 72 | set_ics_trace |
| 73 | |
| 74 | start_mr |
| 75 | |
| 76 | start_kafkapc |
| 77 | |
| 78 | for ((i=1; i<=$NUM_JOBS; i++)) |
| 79 | do |
| 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" |
| 83 | done |
| 84 | |
| 85 | adp_med_type_list="" |
| 86 | adp_config_data='{"types": [' |
| 87 | for ((i=1; i<=$NUM_JOBS; i++)) |
| 88 | do |
| 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 " |
| 94 | done |
| 95 | adp_config_data=$adp_config_data']}' |
| 96 | echo $adp_config_data > tmp/adp_config_data.json |
| 97 | |
BjornMagnussonXA | 8fbc636 | 2022-04-19 09:39:22 +0200 | [diff] [blame] | 98 | start_dmaapadp NOPROXY $SIM_GROUP/$DMAAP_ADP_COMPOSE_DIR/$DMAAP_ADP_CONFIG_FILE_TEMPLATE tmp/adp_config_data.json |
BjornMagnussonXA | 8fbb226 | 2022-01-24 15:20:15 +0100 | [diff] [blame] | 99 | |
| 100 | set_dmaapadp_trace |
| 101 | |
| 102 | if [[ "$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 |
| 109 | fi |
| 110 | |
| 111 | med_config_data='{"types": [' |
| 112 | for ((i=1; i<=$NUM_JOBS; i++)) |
| 113 | do |
| 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 " |
| 119 | done |
| 120 | med_config_data=$med_config_data']}' |
| 121 | echo $med_config_data > tmp/med_config_data.json |
| 122 | |
| 123 | start_dmaapmed NOPROXY tmp/med_config_data.json |
| 124 | |
| 125 | ics_equal json:data-producer/v1/info-producers 2 60 |
| 126 | |
| 127 | # Check producers |
| 128 | ics_api_idc_get_job_ids 200 NOTYPE NOWNER EMPTY |
BjornMagnussonXA | f81090f | 2022-08-24 09:17:44 +0200 | [diff] [blame] | 129 | if [[ "$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 |
| 136 | else |
| 137 | ics_api_edp_get_producer_ids_2 200 NOTYPE DmaapGenericInfoProducer DMaaP_Mediator_Producer |
| 138 | fi |
| 139 | |
BjornMagnussonXA | 8fbb226 | 2022-01-24 15:20:15 +0100 | [diff] [blame] | 140 | ics_api_idc_get_type_ids 200 $adp_med_type_list |
| 141 | |
| 142 | |
| 143 | # Create jobs for adapter kafka - CR stores data as MD5 hash |
| 144 | start_timer "Create adapter (kafka) jobs: $NUM_JOBS" |
| 145 | for ((i=1; i<=$NUM_JOBS; i++)) |
| 146 | do |
BjornMagnussonXA | d54225b | 2023-04-19 14:03:49 +0200 | [diff] [blame] | 147 | # Max buffer timeout for is about 160 sec for Adapter jobs" |
BjornMagnussonXA | 8fbb226 | 2022-01-24 15:20:15 +0100 | [diff] [blame] | 148 | adp_timeout=$(($i*1000)) |
BjornMagnussonXA | 23d69b4 | 2023-02-03 15:13:53 +0100 | [diff] [blame] | 149 | 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 |
BjornMagnussonXA | 8fbb226 | 2022-01-24 15:20:15 +0100 | [diff] [blame] | 163 | 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 | |
| 170 | done |
| 171 | print_timer |
| 172 | |
| 173 | if [[ "$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)) |
BjornMagnussonXA | 23d69b4 | 2023-02-03 15:13:53 +0100 | [diff] [blame] | 179 | 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 |
BjornMagnussonXA | 8fbb226 | 2022-01-24 15:20:15 +0100 | [diff] [blame] | 184 | 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 |
| 191 | fi |
| 192 | |
| 193 | # Check job status |
| 194 | for ((i=1; i<=$NUM_JOBS; i++)) |
| 195 | do |
| 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 |
| 200 | done |
| 201 | |
| 202 | |
| 203 | EXPECTED_DATA_DELIV=0 #Total delivered msg per CR |
| 204 | EXPECTED_BATCHES_DELIV=0 #Total delivered batches per CR |
| 205 | DATA_DELIV_JOBS=0 #Total delivered msg per job per CR |
| 206 | |
| 207 | sleep_wait 60 |
| 208 | |
| 209 | start_timer "Data delivery adapter kafka, 2 strings per job (short buffer timeouts)" |
| 210 | # Send small text via message-router to adapter |
| 211 | for ((i=1; i<=$NUM_JOBS; i++)) |
| 212 | do |
| 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 |
| 216 | done |
| 217 | for ((i=1; i<=$NUM_JOBS; i++)) |
| 218 | do |
| 219 | kafkapc_equal topics/unauthenticated.dmaapadp_kafka.text$i/counters/sent 3 30 |
| 220 | done |
| 221 | |
BjornMagnussonXA | d54225b | 2023-04-19 14:03:49 +0200 | [diff] [blame] | 222 | # Wait for data reception, adapter kafka |
BjornMagnussonXA | 8fbb226 | 2022-01-24 15:20:15 +0100 | [diff] [blame] | 223 | EXPECTED_DATA_DELIV=$(($NUM_JOBS*2/$NUM_CR+$EXPECTED_DATA_DELIV)) |
| 224 | EXPECTED_BATCHES_DELIV=$(($NUM_JOBS/$NUM_CR+$EXPECTED_BATCHES_DELIV)) |
| 225 | |
| 226 | adp_timeout=$(($NUM_JOBS*1*2+60)) #NUM_JOBS*MIN_BUFFERTIMEOUT*2+60_SEC_DELAY |
| 227 | for ((i=0; i<$NUM_CR; i++)) |
| 228 | do |
BjornMagnussonXA | 8fbb226 | 2022-01-24 15:20:15 +0100 | [diff] [blame] | 229 | cr_equal $i received_callbacks $EXPECTED_DATA_DELIV $adp_timeout |
| 230 | cr_greater_or_equal $i received_callback_batches $EXPECTED_BATCHES_DELIV |
| 231 | done |
| 232 | print_timer |
| 233 | |
| 234 | # Check received data callbacks from adapter |
| 235 | for ((i=1; i<=$NUM_JOBS; i++)) |
| 236 | do |
| 237 | cr_index=$(($i%$NUM_CR)) |
BjornMagnussonXA | d54225b | 2023-04-19 14:03:49 +0200 | [diff] [blame] | 238 | 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 |
BjornMagnussonXA | 8fbb226 | 2022-01-24 15:20:15 +0100 | [diff] [blame] | 240 | done |
| 241 | |
| 242 | if [[ "$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 | |
BjornMagnussonXA | d54225b | 2023-04-19 14:03:49 +0200 | [diff] [blame] | 258 | # Wait for data reception, adapter kafka |
BjornMagnussonXA | 8fbb226 | 2022-01-24 15:20:15 +0100 | [diff] [blame] | 259 | |
| 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)) |
BjornMagnussonXA | d54225b | 2023-04-19 14:03:49 +0200 | [diff] [blame] | 276 | 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 |
BjornMagnussonXA | 8fbb226 | 2022-01-24 15:20:15 +0100 | [diff] [blame] | 278 | done |
| 279 | fi |
| 280 | |
| 281 | #### TEST COMPLETE #### |
| 282 | |
| 283 | store_logs END |
| 284 | |
| 285 | print_result |
| 286 | |
| 287 | auto_clean_environment |