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="Testing of service registration timeouts and keepalive"
23 #App names to include in the test, space separated list
24 INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM"
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
46 start_ric_simulators ricsim_g1 1 OSC_2.1.0
47 start_ric_simulators ricsim_g2 1 STD_1.1.3
48 if [ "$PMS_VERSION" == "V2" ]; then
49 start_ric_simulators ricsim_g3 1 STD_2.0.0
58 prepare_consul_config NOSDNC ".consul_config.json"
59 consul_config_app ".consul_config.json"
67 mr_equal requests_submitted 0
72 #Print simulator interface version
73 sim_print ricsim_g1_1 interface
74 sim_print ricsim_g2_1 interface
75 if [ "$PMS_VERSION" == "V2" ]; then
76 sim_print ricsim_g3_1 interface
79 api_put_service 201 "service1" 15 "$CR_PATH/service1"
81 api_get_services 200 "service1" "service1" 15 "$CR_PATH/service1"
83 api_put_service 201 "service2" 120 "$CR_PATH/service2"
85 api_get_services 200 "service2" "service2" 120 "$CR_PATH/service2"
87 api_put_service 200 "service1" 50 "$CR_PATH/service1"
88 api_put_service 200 "service2" 180 "$CR_PATH/service2"
90 api_get_services 200 "service1" "service1" 50 "$CR_PATH/service1"
91 api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2"
93 api_get_service_ids 200 "service1" "service2"
95 sleep_wait 30 "Waiting for keep alive timeout"
97 api_get_services 200 "service1" "service1" 50 "$CR_PATH/service1"
98 api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2"
100 sleep_wait 100 "Waiting for keep alive timeout"
102 api_get_services 404 "service1"
103 api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2"
105 api_delete_services 204 "service2"
107 api_get_services 404 "service1"
108 api_get_services 404 "service2"
110 api_put_service 201 "service3" 60 "$CR_PATH/service3"
112 api_get_services 200 "service3" "service3" 60 "$CR_PATH/service3"
114 sleep_wait 30 "Waiting for keep alive timeout"
116 api_put_service 200 "service3" 60 "$CR_PATH/service3"
118 sleep_wait 100 "Waiting for keep alive timeout"
120 api_get_services 404 "service3"
122 api_put_service 201 "service4" 120 "$CR_PATH/service4"
124 sleep_wait 60 "Waiting for keep alive timeout"
126 api_get_services 200 "service4" "service4" 120 "$CR_PATH/service4"
128 api_put_services_keepalive 200 "service4"
130 sleep_wait 90 "Waiting for keep alive timeout"
132 api_get_services 200 "service4" "service4" 120 "$CR_PATH/service4"
134 api_delete_services 204 "service4"
136 api_get_services 404 "service4"
138 api_get_services 404 "service1"
139 api_get_services 404 "service2"
140 api_get_services 404 "service3"
142 api_get_service_ids 200
144 api_delete_services 404 "service1"
145 api_delete_services 404 "service2"
146 api_delete_services 404 "service3"
147 api_delete_services 404 "service4"
149 api_put_services_keepalive 404 "service1"
150 api_put_services_keepalive 404 "service2"
151 api_put_services_keepalive 404 "service3"
152 api_put_services_keepalive 404 "service4"
154 # Policy delete after timeout
155 api_put_service 201 "service10" 600 "$CR_PATH/service10"
157 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
159 if [ "$PMS_VERSION" == "V2" ]; then
161 sim_put_policy_type 201 ricsim_g3_1 STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
163 api_equal json:rics 3 60
165 #api_equal json:policy_schemas 2 120
167 api_equal json:policy-types 3 120
169 api_equal json:policies 0
171 api_equal json:rics 2 60
173 api_equal json:policy_schemas 2 120
175 api_equal json:policy_types 2
177 api_equal json:policies 0
180 if [ "$PMS_VERSION" == "V2" ]; then
181 notificationurl=$CR_PATH"/test"
186 api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
187 api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
189 if [ "$PMS_VERSION" == "V2" ]; then
190 api_put_policy 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json
191 api_equal json:policies 3
193 api_equal json:policies 2
196 sim_equal ricsim_g1_1 num_instances 1
197 sim_equal ricsim_g2_1 num_instances 1
199 api_put_policy 201 "service10" ricsim_g1_1 1 5001 true $notificationurl testdata/OSC/pi1_template.json
200 api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5101 true $notificationurl testdata/STD/pi1_template.json
202 if [ "$PMS_VERSION" == "V2" ]; then
203 api_put_policy 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5201 true $notificationurl testdata/STD2/pi_qos2_template.json
204 api_equal json:policies 6
206 api_equal json:policies 4
209 sim_equal ricsim_g1_1 num_instances 2
210 sim_equal ricsim_g2_1 num_instances 2
211 if [ "$PMS_VERSION" == "V2" ]; then
212 sim_equal ricsim_g3_1 num_instances 2
215 sim_post_delete_instances 200 ricsim_g1_1
216 sim_post_delete_instances 200 ricsim_g2_1
218 if [ "$PMS_VERSION" == "V2" ]; then
219 sim_post_delete_instances 200 ricsim_g3_1
222 #Wait for recreate of non transient policy
223 if [ "$PMS_VERSION" == "V2" ]; then
224 api_equal json:policies 3 180
226 api_equal json:policies 2 180
229 sim_equal ricsim_g1_1 num_instances 1
230 sim_equal ricsim_g2_1 num_instances 1
231 if [ "$PMS_VERSION" == "V2" ]; then
232 sim_equal ricsim_g3_1 num_instances 1
235 api_put_service 200 "service10" 10 "$CR_PATH/service10"
237 #Wait for service expiry
238 api_equal json:policies 0 120
240 sim_equal ricsim_g1_1 num_instances 0
241 sim_equal ricsim_g2_1 num_instances 0
242 if [ "$PMS_VERSION" == "V2" ]; then
243 sim_equal ricsim_g3_1 num_instances 0
246 api_get_service_ids 200
248 mr_equal requests_submitted 0
250 check_policy_agent_logs
251 check_control_panel_logs
253 #### TEST COMPLETE ####
259 auto_clean_containers