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 . ../common/testcase_common.sh $@
27 . ../common/agent_api_functions.sh
28 . ../common/ricsimulator_api_functions.sh
35 # Tested variants of REST/DMAAP/SDNC config
36 TESTED_VARIANTS="REST DMAAP REST+SDNC DMAAP+SDNC"
37 #Test agent and simulator protocol versions (others are http only)
38 TESTED_PROTOCOLS="HTTP HTTPS"
39 for __httpx in $TESTED_PROTOCOLS ; do
40 for interface in $TESTED_VARIANTS ; do
42 echo "#####################################################################"
43 echo "#####################################################################"
44 echo "### Testing agent: $interface using $__httpx"
45 echo "#####################################################################"
46 echo "#####################################################################"
49 if [ $__httpx == "HTTPS" ]; then
50 CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks"
54 if [[ $interface = *"SDNC"* ]]; then
57 if [[ $interface = *"DMAAP"* ]]; then
63 CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
67 if [[ $interface = *"SDNC"* ]]; then
70 if [[ $interface = *"DMAAP"* ]]; then
77 # Clean container and start all needed containers #
80 start_ric_simulators ricsim_g1 1 OSC_2.1.0
81 start_ric_simulators ricsim_g2 1 STD_1.1.3
82 if [ "$PMS_VERSION" == "V2" ]; then
83 start_ric_simulators ricsim_g3 1 STD_2.0.0
92 if [[ $interface = *"SDNC"* ]]; then
94 prepare_consul_config SDNC ".consul_config.json"
96 prepare_consul_config NOSDNC ".consul_config.json"
99 consul_config_app ".consul_config.json"
108 cr_equal received_callbacks 0
109 mr_equal requests_submitted 0
111 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
113 if [ "$PMS_VERSION" == "V2" ]; then
114 api_equal json:rics 3 60
116 #api_equal json:policy_schemas 2 120
118 api_equal json:policy-types 2 120
120 api_equal json:policies 0
122 api_equal json:policy_instances 0
124 api_equal json:rics 2 60
126 api_equal json:policy_schemas 2 120
128 api_equal json:policy_types 2
130 api_equal json:policies 0
132 api_equal json:policy_ids 0
135 echo "############################################"
136 echo "############## Health check ################"
137 echo "############################################"
141 echo "############################################"
142 echo "##### Service registry and supervision #####"
143 echo "############################################"
145 api_put_service 201 "serv1" 1000 "$CR_PATH/1"
147 api_get_service_ids 200 "serv1"
149 api_put_services_keepalive 200 "serv1"
151 echo "############################################"
152 echo "############## RIC Repository ##############"
153 echo "############################################"
155 if [ "$PMS_VERSION" == "V2" ]; then
156 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"
158 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"
161 echo "############################################"
162 echo "########### A1 Policy Management ###########"
163 echo "############################################"
165 if [ "$PMS_VERSION" == "V2" ]; then
166 notificationurl="http://localhost:80"
170 api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
171 api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
173 api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
174 api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
176 api_delete_policy 204 5000
178 api_delete_policy 204 5100
180 if [ "$PMS_VERSION" == "V2" ]; then
181 api_equal json:policies 0
183 api_equal json:policy_instances 0
185 api_equal json:policies 0
187 api_equal json:policy_ids 0
190 cr_equal received_callbacks 0
192 if [[ $interface = *"DMAAP"* ]]; then
193 VAL=11 # Number of Agent API calls over DMAAP
194 mr_equal requests_fetched $VAL
195 mr_equal responses_submitted $VAL
196 mr_equal responses_fetched $VAL
197 mr_equal current_requests 0
198 mr_equal current_responses 0
200 mr_equal requests_submitted 0
203 if [[ $interface = *"SDNC"* ]]; then
204 sim_contains_str ricsim_g1_1 remote_hosts "a1-controller"
205 sim_contains_str ricsim_g2_1 remote_hosts "a1-controller"
206 if [ "$PMS_VERSION" == "V2" ]; then
207 sim_contains_str ricsim_g3_1 remote_hosts "a1-controller"
210 sim_contains_str ricsim_g1_1 remote_hosts "policy-agent"
211 sim_contains_str ricsim_g2_1 remote_hosts "policy-agent"
212 if [ "$PMS_VERSION" == "V2" ]; then
213 sim_contains_str ricsim_g3_1 remote_hosts "policy-agent"
217 check_policy_agent_logs
218 check_control_panel_logs
220 store_logs "${__httpx}__${interface}"
226 #### TEST COMPLETE ####
231 auto_clean_containers