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 CR"
25 #App names to include in the test when running kubernetes, space separated list
26 KUBE_INCLUDED_IMAGES=" ECS DMAAPMED DMAAPADP KUBEPROXY MR 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
86 start_dmaapadp NOPROXY $SIM_GROUP/$DMAAP_ADP_COMPOSE_DIR/$DMAAP_ADP_CONFIG_FILE $SIM_GROUP/$DMAAP_ADP_COMPOSE_DIR/$DMAAP_ADP_DATA_FILE
90 start_dmaapmed NOPROXY $SIM_GROUP/$DMAAP_MED_COMPOSE_DIR/$DMAAP_MED_DATA_FILE
92 ecs_equal json:data-producer/v1/info-producers 2 60
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
100 # Create jobs for adapter
101 start_timer "Create adapter jobs: $NUM_JOBS"
102 for ((i=1; i<=$NUM_JOBS; i++))
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
106 print_timer "Create adapter jobs: $NUM_JOBS"
108 # Create jobs for mediator
109 start_timer "Create mediator jobs: $NUM_JOBS"
110 for ((i=1; i<=$NUM_JOBS; i++))
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
114 print_timer "Create mediator jobs: $NUM_JOBS"
117 for ((i=1; i<=$NUM_JOBS; i++))
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
123 EXPECTED_DATA_DELIV=0
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"}'
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)
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"}'
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)
147 # Check received number of messages for mediator and adapter callbacks
148 for ((i=1; i<=$NUM_JOBS; i++))
150 cr_equal received_callbacks?id=job-med-data$i 2
151 cr_equal received_callbacks?id=job-adp-data$i 2
154 # Check received data and order for mediator and adapter callbacks
155 for ((i=1; i<=$NUM_JOBS; i++))
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"}'
163 # Set delay in the callback receiver to slow down callbacks
165 cr_delay_callback 200 $SEC_DELAY
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"}'
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)
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"}'
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)
190 # Check received number of messages for mediator and adapter callbacks
191 for ((i=1; i<=$NUM_JOBS; i++))
193 cr_equal received_callbacks?id=job-med-data$i 4
194 cr_equal received_callbacks?id=job-adp-data$i 4
197 # Check received data and order for mediator and adapter callbacks
198 for ((i=1; i<=$NUM_JOBS; i++))
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"}'
208 #### TEST COMPLETE ####
214 auto_clean_environment