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