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, space separated list
24 INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
26 #SUPPORTED TEST ENV FILE
27 SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-CHERRY"
29 . ../common/testcase_common.sh $@
30 . ../common/agent_api_functions.sh
31 . ../common/ricsimulator_api_functions.sh
32 . ../common/cr_api_functions.sh
39 # Tested variants of REST/DMAAP/SDNC config
40 TESTED_VARIANTS="REST DMAAP REST+SDNC DMAAP+SDNC"
41 #Test agent and simulator protocol versions (others are http only)
42 TESTED_PROTOCOLS="HTTP HTTPS"
43 for __httpx in $TESTED_PROTOCOLS ; do
44 for interface in $TESTED_VARIANTS ; do
46 echo "#####################################################################"
47 echo "#####################################################################"
48 echo "### Testing agent: $interface using $__httpx"
49 echo "#####################################################################"
50 echo "#####################################################################"
52 # Clean container and start all needed containers #
55 if [ $__httpx == "HTTPS" ]; then
65 # Create service to be able to receive events when rics becomes available
66 # Must use rest towards the agent since dmaap is not configured yet
67 api_put_service 201 "ric-registration" 0 "$CR_PATH/ric-registration"
69 if [ $__httpx == "HTTPS" ]; then
73 if [[ $interface = *"SDNC"* ]]; then
76 if [[ $interface = *"DMAAP"* ]]; then
85 if [[ $interface = *"SDNC"* ]]; then
88 if [[ $interface = *"DMAAP"* ]]; then
95 start_ric_simulators ricsim_g1 1 OSC_2.1.0
96 start_ric_simulators ricsim_g2 1 STD_1.1.3
97 if [ "$PMS_VERSION" == "V2" ]; then
98 start_ric_simulators ricsim_g3 1 STD_2.0.0
109 if [[ $interface = *"SDNC"* ]]; then
111 prepare_consul_config SDNC ".consul_config.json"
113 prepare_consul_config NOSDNC ".consul_config.json"
116 consul_config_app ".consul_config.json"
118 mr_equal requests_submitted 0
120 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
122 if [ "$PMS_VERSION" == "V2" ]; then
124 sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
126 api_equal json:rics 3 60
128 api_equal json:policy-types 3 120
130 api_equal json:policies 0
132 api_equal json:policy-instances 0
134 cr_equal received_callbacks 3 120
136 cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1
139 api_equal json:rics 2 60
141 api_equal json:policy_schemas 2 120
143 api_equal json:policy_types 2
145 api_equal json:policies 0
147 api_equal json:policy_ids 0
150 echo "############################################"
151 echo "############## Health check ################"
152 echo "############################################"
156 echo "############################################"
157 echo "##### Service registry and supervision #####"
158 echo "############################################"
160 api_put_service 201 "serv1" 1000 "$CR_PATH/1"
162 api_get_service_ids 200 "serv1" "ric-registration"
164 api_put_services_keepalive 200 "serv1"
166 echo "############################################"
167 echo "############## RIC Repository ##############"
168 echo "############################################"
170 if [ "$PMS_VERSION" == "V2" ]; then
171 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"
173 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"
176 echo "############################################"
177 echo "########### A1 Policy Management ###########"
178 echo "############################################"
180 if [ "$PMS_VERSION" == "V2" ]; then
181 notificationurl=$CR_PATH"/test"
185 api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
186 api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
187 if [ "$PMS_VERSION" == "V2" ]; then
188 api_put_policy 201 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json
189 api_put_policy 200 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json
192 api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
193 api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
195 if [ "$PMS_VERSION" == "V2" ]; then
196 api_equal json:policies 3
198 api_equal json:policies 2
201 api_delete_policy 204 5000
203 api_delete_policy 204 5100
205 if [ "$PMS_VERSION" == "V2" ]; then
206 api_delete_policy 204 5200
209 if [ "$PMS_VERSION" == "V2" ]; then
210 api_equal json:policies 0
212 api_equal json:policy-instances 0
214 api_equal json:policies 0
216 api_equal json:policy_ids 0
219 if [ "$PMS_VERSION" == "V2" ]; then
220 cr_equal received_callbacks 3
223 if [[ $interface = *"DMAAP"* ]]; then
225 if [ "$PMS_VERSION" == "V2" ]; then
226 VAL=14 # Number of Agent API calls over DMAAP
228 VAL=11 # Number of Agent API calls over DMAAP
230 mr_equal requests_fetched $VAL
231 mr_equal responses_submitted $VAL
232 mr_equal responses_fetched $VAL
233 mr_equal current_requests 0
234 mr_equal current_responses 0
236 mr_equal requests_submitted 0
239 if [[ $interface = *"SDNC"* ]]; then
240 sim_contains_str ricsim_g1_1 remote_hosts "a1-controller"
241 sim_contains_str ricsim_g2_1 remote_hosts "a1-controller"
242 if [ "$PMS_VERSION" == "V2" ]; then
243 sim_contains_str ricsim_g3_1 remote_hosts "a1-controller"
246 sim_contains_str ricsim_g1_1 remote_hosts "policy-agent"
247 sim_contains_str ricsim_g2_1 remote_hosts "policy-agent"
248 if [ "$PMS_VERSION" == "V2" ]; then
249 sim_contains_str ricsim_g3_1 remote_hosts "policy-agent"
253 check_policy_agent_logs
254 check_control_panel_logs
256 if [[ $interface = *"SDNC"* ]]; then
260 store_logs "${__httpx}__${interface}"
266 #### TEST COMPLETE ####
271 auto_clean_containers