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"
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
123 api_equal json:rics 3 60
125 api_equal json:policy-types 2 120
127 api_equal json:policies 0
129 api_equal json:policy-instances 0
131 cr_equal received_callbacks 3 120
133 cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1
136 api_equal json:rics 2 60
138 api_equal json:policy_schemas 2 120
140 api_equal json:policy_types 2
142 api_equal json:policies 0
144 api_equal json:policy_ids 0
147 echo "############################################"
148 echo "############## Health check ################"
149 echo "############################################"
153 echo "############################################"
154 echo "##### Service registry and supervision #####"
155 echo "############################################"
157 api_put_service 201 "serv1" 1000 "$CR_PATH/1"
159 api_get_service_ids 200 "serv1" "ric-registration"
161 api_put_services_keepalive 200 "serv1"
163 echo "############################################"
164 echo "############## RIC Repository ##############"
165 echo "############################################"
167 if [ "$PMS_VERSION" == "V2" ]; then
168 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:NOTYPE:AVAILABLE"
170 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"
173 echo "############################################"
174 echo "########### A1 Policy Management ###########"
175 echo "############################################"
177 if [ "$PMS_VERSION" == "V2" ]; then
178 notificationurl=$CR_PATH"/test"
182 api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
183 api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
185 api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
186 api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
188 api_delete_policy 204 5000
190 api_delete_policy 204 5100
192 if [ "$PMS_VERSION" == "V2" ]; then
193 api_equal json:policies 0
195 api_equal json:policy-instances 0
197 api_equal json:policies 0
199 api_equal json:policy_ids 0
202 if [ "$PMS_VERSION" == "V2" ]; then
203 cr_equal received_callbacks 3
206 if [[ $interface = *"DMAAP"* ]]; then
207 VAL=11 # Number of Agent API calls over DMAAP
208 mr_equal requests_fetched $VAL
209 mr_equal responses_submitted $VAL
210 mr_equal responses_fetched $VAL
211 mr_equal current_requests 0
212 mr_equal current_responses 0
214 mr_equal requests_submitted 0
217 if [[ $interface = *"SDNC"* ]]; then
218 sim_contains_str ricsim_g1_1 remote_hosts "a1-controller"
219 sim_contains_str ricsim_g2_1 remote_hosts "a1-controller"
220 if [ "$PMS_VERSION" == "V2" ]; then
221 sim_contains_str ricsim_g3_1 remote_hosts "a1-controller"
224 sim_contains_str ricsim_g1_1 remote_hosts "policy-agent"
225 sim_contains_str ricsim_g2_1 remote_hosts "policy-agent"
226 if [ "$PMS_VERSION" == "V2" ]; then
227 sim_contains_str ricsim_g3_1 remote_hosts "policy-agent"
231 check_policy_agent_logs
232 check_control_panel_logs
234 if [[ $interface = *"SDNC"* ]]; then
238 store_logs "${__httpx}__${interface}"
244 #### TEST COMPLETE ####
249 auto_clean_containers