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=================================================
21 TC_ONELINE_DESCR="Sanity test, create service and then create,update and delete a policy using http/https and Agent REST/DMAAP with/without SDNC controller"
23 #App names to include in the test when running docker, space separated list
24 DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR DMAAPMR PA RICSIM SDNC NGW KUBEPROXY"
26 #App names to include in the test when running kubernetes, space separated list
27 KUBE_INCLUDED_IMAGES="CP CR MR DMAAPMR PA RICSIM SDNC NGW KUBEPROXY "
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="NGW"
36 #Supported test environment profiles
37 SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ONAP-ISTANBUL ORAN-CHERRY ORAN-D-RELEASE ORAN-E-RELEASE"
39 SUPPORTED_RUNMODES="DOCKER KUBE"
41 . ../common/testcase_common.sh $@
42 . ../common/agent_api_functions.sh
43 . ../common/consul_cbs_functions.sh
44 . ../common/control_panel_api_functions.sh
45 . ../common/controller_api_functions.sh
46 . ../common/cr_api_functions.sh
47 . ../common/mr_api_functions.sh
48 . ../common/ricsimulator_api_functions.sh
49 . ../common/http_proxy_api_functions.sh
50 . ../common/kube_proxy_api_functions.sh
51 . ../common/gateway_api_functions.sh
59 # Tested variants of REST/DMAAP/SDNC config
60 TESTED_VARIANTS="REST DMAAP REST+SDNC DMAAP+SDNC"
61 #Test agent and simulator protocol versions (others are http only)
62 TESTED_PROTOCOLS="HTTP HTTPS"
63 for __httpx in $TESTED_PROTOCOLS ; do
64 for interface in $TESTED_VARIANTS ; do
66 echo "#####################################################################"
67 echo "#####################################################################"
68 echo "### Testing agent: $interface using $__httpx"
69 echo "#####################################################################"
70 echo "#####################################################################"
76 if [ $__httpx == "HTTPS" ]; then
82 start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/$POLICY_AGENT_CONFIG_FILE
86 # Create service to be able to receive events when rics becomes available
87 # Must use rest towards the agent since dmaap is not configured yet
88 api_put_service 201 "ric-registration" 0 "$CR_SERVICE_APP_PATH/ric-registration"
90 if [ $__httpx == "HTTPS" ]; then
94 if [[ $interface = *"SDNC"* ]]; then
97 if [[ $interface = *"DMAAP"* ]]; then
106 if [[ $interface = *"SDNC"* ]]; then
109 if [[ $interface = *"DMAAP"* ]]; then
116 start_ric_simulators ricsim_g1 1 OSC_2.1.0
117 start_ric_simulators ricsim_g2 1 STD_1.1.3
118 if [ "$PMS_VERSION" == "V2" ]; then
119 start_ric_simulators ricsim_g3 1 STD_2.0.0
122 start_mr "$MR_READ_TOPIC" "/events" "users/policy-agent" \
123 "$MR_WRITE_TOPIC" "/events" "users/mr-stub"
127 start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
129 if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
130 start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
133 if [ $RUNMODE == "DOCKER" ]; then
137 if [[ $interface = *"SDNC"* ]]; then
139 prepare_consul_config SDNC ".consul_config.json"
141 prepare_consul_config NOSDNC ".consul_config.json"
144 if [ $RUNMODE == "KUBE" ]; then
145 agent_load_config ".consul_config.json"
147 consul_config_app ".consul_config.json"
150 mr_equal requests_submitted 0
152 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
154 if [ "$PMS_VERSION" == "V2" ]; then
156 sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
158 api_equal json:rics 3 300
160 api_equal json:policy-types 3 120
162 api_equal json:policies 0
164 api_equal json:policy-instances 0
166 cr_equal received_callbacks 3 120
168 cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1
171 api_equal json:rics 2 300
173 api_equal json:policy_schemas 2 120
175 api_equal json:policy_types 2
177 api_equal json:policies 0
179 api_equal json:policy_ids 0
182 echo "############################################"
183 echo "############## Health check ################"
184 echo "############################################"
188 echo "############################################"
189 echo "##### Service registry and supervision #####"
190 echo "############################################"
192 api_put_service 201 "serv1" 1000 "$CR_SERVICE_APP_PATH/1"
194 api_get_service_ids 200 "serv1" "ric-registration"
196 api_put_services_keepalive 200 "serv1"
198 echo "############################################"
199 echo "############## RIC Repository ##############"
200 echo "############################################"
202 if [ "$PMS_VERSION" == "V2" ]; then
203 api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:AVAILABLE ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE ricsim_g3_1:me1_ricsim_g3_1,me2_ricsim_g3_1:STD_QOS_0_2_0:AVAILABLE"
205 api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:AVAILABLE ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
208 echo "############################################"
209 echo "########### A1 Policy Management ###########"
210 echo "############################################"
212 if [ "$PMS_VERSION" == "V2" ]; then
213 notificationurl=$CR_SERVICE_APP_PATH"/test"
217 api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
218 api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
219 if [ "$PMS_VERSION" == "V2" ]; then
220 api_put_policy 201 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json
221 api_put_policy 200 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json
224 api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
225 api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
227 if [ "$PMS_VERSION" == "V2" ]; then
228 api_equal json:policies 3
230 api_equal json:policies 2
233 api_delete_policy 204 5000
235 api_delete_policy 204 5100
237 if [ "$PMS_VERSION" == "V2" ]; then
238 api_delete_policy 204 5200
241 if [ "$PMS_VERSION" == "V2" ]; then
242 api_equal json:policies 0
244 api_equal json:policy-instances 0
246 api_equal json:policies 0
248 api_equal json:policy_ids 0
251 if [ "$PMS_VERSION" == "V2" ]; then
252 cr_equal received_callbacks 3
255 if [[ $interface = *"DMAAP"* ]]; then
257 if [ "$PMS_VERSION" == "V2" ]; then
258 VAL=14 # Number of Agent API calls over DMAAP
260 VAL=11 # Number of Agent API calls over DMAAP
262 mr_equal requests_fetched $VAL
263 mr_equal responses_submitted $VAL
264 mr_equal responses_fetched $VAL
265 mr_equal current_requests 0
266 mr_equal current_responses 0
268 mr_equal requests_submitted 0
271 if [[ $interface = *"SDNC"* ]]; then
272 sim_contains_str ricsim_g1_1 remote_hosts $SDNC_APP_NAME
273 sim_contains_str ricsim_g2_1 remote_hosts $SDNC_APP_NAME
274 if [ "$PMS_VERSION" == "V2" ]; then
275 sim_contains_str ricsim_g3_1 remote_hosts $SDNC_APP_NAME
278 sim_contains_str ricsim_g1_1 remote_hosts $POLICY_AGENT_APP_NAME
279 sim_contains_str ricsim_g2_1 remote_hosts $POLICY_AGENT_APP_NAME
280 if [ "$PMS_VERSION" == "V2" ]; then
281 sim_contains_str ricsim_g3_1 remote_hosts $POLICY_AGENT_APP_NAME
285 check_policy_agent_logs
288 if [[ $interface = *"SDNC"* ]]; then
292 store_logs "${__httpx}__${interface}"
298 #### TEST COMPLETE ####
303 auto_clean_environment