BjornMagnussonXA | 663566c | 2021-11-08 10:25:07 +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" |
| 21 | |
| 22 | #App names to include in the test when running docker, space separated list |
| 23 | DOCKER_INCLUDED_IMAGES="ECS DMAAPMED DMAAPADP KUBEPROXY MR CR" |
| 24 | |
| 25 | #App names to include in the test when running kubernetes, space separated list |
| 26 | KUBE_INCLUDED_IMAGES=" ECS DMAAPMED DMAAPADP KUBEPROXY MR CR" |
| 27 | |
| 28 | #Prestarted app (not started by script) to include in the test when running kubernetes, space separated list |
| 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 |
| 37 | SUPPORTED_PROFILES="ORAN-E-RELEASE" |
| 38 | #Supported run modes |
| 39 | SUPPORTED_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 | |
| 58 | setup_testenvironment |
| 59 | |
| 60 | #### TEST BEGIN #### |
| 61 | |
| 62 | #Local vars in test script |
| 63 | ########################## |
| 64 | FLAT_A1_EI="1" |
| 65 | NUM_JOBS=100 # Mediator and adapter gets same number of jobs |
| 66 | |
| 67 | clean_environment |
| 68 | |
| 69 | #use_cr_https |
| 70 | use_cr_http |
| 71 | use_ecs_rest_https |
| 72 | use_mr_https |
| 73 | use_dmaapadp_https |
| 74 | use_dmaapmed_https |
| 75 | |
| 76 | start_kube_proxy |
| 77 | |
| 78 | start_cr |
| 79 | |
| 80 | start_ecs NOPROXY $SIM_GROUP/$ECS_COMPOSE_DIR/$ECS_CONFIG_FILE |
| 81 | |
| 82 | set_ecs_trace |
| 83 | |
| 84 | start_mr |
| 85 | |
| 86 | start_dmaapadp NOPROXY $SIM_GROUP/$DMAAP_ADP_COMPOSE_DIR/$DMAAP_ADP_CONFIG_FILE $SIM_GROUP/$DMAAP_ADP_COMPOSE_DIR/$DMAAP_ADP_DATA_FILE |
| 87 | |
| 88 | set_dmaapadp_trace |
| 89 | |
| 90 | start_dmaapmed NOPROXY $SIM_GROUP/$DMAAP_MED_COMPOSE_DIR/$DMAAP_MED_DATA_FILE |
| 91 | |
| 92 | ecs_equal json:data-producer/v1/info-producers 2 60 |
| 93 | |
| 94 | # Check producers |
| 95 | ecs_api_idc_get_job_ids 200 NOTYPE NOWNER EMPTY |
| 96 | ecs_api_idc_get_type_ids 200 ExampleInformationType STD_Fault_Messages |
| 97 | ecs_api_edp_get_producer_ids_2 200 NOTYPE DmaapGenericInfoProducer DMaaP_Mediator_Producer |
| 98 | |
| 99 | |
| 100 | # Create jobs for adapter |
| 101 | start_timer "Create adapter jobs: $NUM_JOBS" |
| 102 | for ((i=1; i<=$NUM_JOBS; i++)) |
| 103 | do |
| 104 | ecs_api_idc_put_job 201 job-adp-$i ExampleInformationType $CR_SERVICE_MR_PATH/job-adp-data$i info-owner-adp-$i $CR_SERVICE_MR_PATH/job_status_info-owner-adp-$i testdata/dmaap-adapter/job-template.json |
| 105 | done |
| 106 | print_timer "Create adapter jobs: $NUM_JOBS" |
| 107 | |
| 108 | # Create jobs for mediator |
| 109 | start_timer "Create mediator jobs: $NUM_JOBS" |
| 110 | for ((i=1; i<=$NUM_JOBS; i++)) |
| 111 | do |
| 112 | ecs_api_idc_put_job 201 job-med-$i STD_Fault_Messages $CR_SERVICE_MR_PATH/job-med-data$i info-owner-med-$i $CR_SERVICE_MR_PATH/job_status_info-owner-med-$i testdata/dmaap-adapter/job-template.json |
| 113 | done |
| 114 | print_timer "Create mediator jobs: $NUM_JOBS" |
| 115 | |
| 116 | # Check job status |
| 117 | for ((i=1; i<=$NUM_JOBS; i++)) |
| 118 | do |
| 119 | ecs_api_a1_get_job_status 200 job-med-$i ENABLED 30 |
| 120 | ecs_api_a1_get_job_status 200 job-adp-$i ENABLED 30 |
| 121 | done |
| 122 | |
| 123 | EXPECTED_DATA_DELIV=0 |
| 124 | |
| 125 | # Send data to adapter via mr |
| 126 | mr_api_send_json "/events/unauthenticated.dmaapadp.json" '{"msg":"msg-1"}' |
| 127 | mr_api_send_json "/events/unauthenticated.dmaapadp.json" '{"msg":"msg-3"}' |
| 128 | |
| 129 | # Wait for data recetption, adapter |
| 130 | EXPECTED_DATA_DELIV=$(($NUM_JOBS*2+$EXPECTED_DATA_DELIV)) |
| 131 | start_timer "Data delivery adapter, 2 json per job" |
| 132 | cr_equal received_callbacks $EXPECTED_DATA_DELIV 100 |
| 133 | print_timer "Data delivery adapter, 2 json per job" |
| 134 | EXPECTED_DATA_DELIV=$(cr_read received_callbacks) |
| 135 | |
| 136 | # Send data to mediator |
| 137 | mr_api_send_json "/events/unauthenticated.dmaapmed.json" '{"msg":"msg-0"}' |
| 138 | mr_api_send_json "/events/unauthenticated.dmaapmed.json" '{"msg":"msg-2"}' |
| 139 | |
| 140 | # Wait for data reception, mediator |
| 141 | EXPECTED_DATA_DELIV=$(($NUM_JOBS*2+$EXPECTED_DATA_DELIV)) |
| 142 | start_timer "Data delivery mediator, 2 json per job" |
| 143 | cr_equal received_callbacks $EXPECTED_DATA_DELIV 100 |
| 144 | print_timer "Data delivery mediator, 2 json per job" |
| 145 | EXPECTED_DATA_DELIV=$(cr_read received_callbacks) |
| 146 | |
| 147 | # Check received number of messages for mediator and adapter callbacks |
| 148 | for ((i=1; i<=$NUM_JOBS; i++)) |
| 149 | do |
| 150 | cr_equal received_callbacks?id=job-med-data$i 2 |
| 151 | cr_equal received_callbacks?id=job-adp-data$i 2 |
| 152 | done |
| 153 | |
| 154 | # Check received data and order for mediator and adapter callbacks |
| 155 | for ((i=1; i<=$NUM_JOBS; i++)) |
| 156 | do |
| 157 | cr_api_check_single_genric_json_event 200 job-med-data$i '{"msg":"msg-0"}' |
| 158 | cr_api_check_single_genric_json_event 200 job-med-data$i '{"msg":"msg-2"}' |
| 159 | cr_api_check_single_genric_json_event 200 job-adp-data$i '{"msg":"msg-1"}' |
| 160 | cr_api_check_single_genric_json_event 200 job-adp-data$i '{"msg":"msg-3"}' |
| 161 | done |
| 162 | |
| 163 | # Set delay in the callback receiver to slow down callbacks |
| 164 | SEC_DELAY=5 |
| 165 | cr_delay_callback 200 $SEC_DELAY |
| 166 | |
| 167 | # Send data to adapter via mr |
| 168 | mr_api_send_json "/events/unauthenticated.dmaapadp.json" '{"msg":"msg-5"}' |
| 169 | mr_api_send_json "/events/unauthenticated.dmaapadp.json" '{"msg":"msg-7"}' |
| 170 | |
| 171 | # Wait for data recetption, adapter |
| 172 | EXPECTED_DATA_DELIV=$(($NUM_JOBS*2+$EXPECTED_DATA_DELIV)) |
| 173 | start_timer "Data delivery adapter with $SEC_DELAY seconds delay, 2 json per job" |
| 174 | cr_equal received_callbacks $EXPECTED_DATA_DELIV $(($NUM_JOBS+300)) |
| 175 | print_timer "Data delivery adapter with $SEC_DELAY seconds delay, 2 json per job" |
| 176 | EXPECTED_DATA_DELIV=$(cr_read received_callbacks) |
| 177 | |
| 178 | |
| 179 | # Send data to mediator |
| 180 | mr_api_send_json "/events/unauthenticated.dmaapmed.json" '{"msg":"msg-4"}' |
| 181 | mr_api_send_json "/events/unauthenticated.dmaapmed.json" '{"msg":"msg-6"}' |
| 182 | |
| 183 | # Wait for data reception, mediator |
| 184 | EXPECTED_DATA_DELIV=$(($NUM_JOBS*2+$EXPECTED_DATA_DELIV)) |
| 185 | start_timer "Data delivery mediator with $SEC_DELAY seconds delay, 2 json per job" |
| 186 | cr_equal received_callbacks $EXPECTED_DATA_DELIV 1000 |
| 187 | print_timer "Data delivery mediator with $SEC_DELAY seconds delay, 2 json per job" |
| 188 | EXPECTED_DATA_DELIV=$(cr_read received_callbacks) |
| 189 | |
| 190 | # Check received number of messages for mediator and adapter callbacks |
| 191 | for ((i=1; i<=$NUM_JOBS; i++)) |
| 192 | do |
| 193 | cr_equal received_callbacks?id=job-med-data$i 4 |
| 194 | cr_equal received_callbacks?id=job-adp-data$i 4 |
| 195 | done |
| 196 | |
| 197 | # Check received data and order for mediator and adapter callbacks |
| 198 | for ((i=1; i<=$NUM_JOBS; i++)) |
| 199 | do |
| 200 | cr_api_check_single_genric_json_event 200 job-med-data$i '{"msg":"msg-4"}' |
| 201 | cr_api_check_single_genric_json_event 200 job-med-data$i '{"msg":"msg-6"}' |
| 202 | cr_api_check_single_genric_json_event 200 job-adp-data$i '{"msg":"msg-5"}' |
| 203 | cr_api_check_single_genric_json_event 200 job-adp-data$i '{"msg":"msg-7"}' |
| 204 | done |
| 205 | |
| 206 | |
| 207 | |
| 208 | #### TEST COMPLETE #### |
| 209 | |
| 210 | store_logs END |
| 211 | |
| 212 | print_result |
| 213 | |
| 214 | auto_clean_environment |