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 exclude checking pulling images for, space separated list
24 EXCLUDED_IMAGES="SDNC ECS"
26 . ../common/testcase_common.sh $@
27 . ../common/agent_api_functions.sh
28 . ../common/ricsimulator_api_functions.sh
32 #Local vars in test script
33 ##########################
34 # Path to callback receiver
35 CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
47 start_ric_simulators ricsim_g1 1 OSC_2.1.0
55 prepare_consul_config NOSDNC ".consul_config.json"
56 consul_config_app ".consul_config.json"
64 #Verify no callbacks or dmaap messages has been sent
65 cr_equal received_callbacks 0
66 mr_equal requests_submitted 0
71 #Print simulator interface version
72 sim_print ricsim_g1_1 interface
74 api_put_service 201 "service1" 15 "$CR_PATH/service1"
76 api_get_services 200 "service1" "service1" 15 "$CR_PATH/service1"
78 api_put_service 201 "service2" 120 "$CR_PATH/service2"
80 api_get_services 200 "service2" "service2" 120 "$CR_PATH/service2"
82 api_put_service 200 "service1" 50 "$CR_PATH/service1"
83 api_put_service 200 "service2" 180 "$CR_PATH/service2"
85 api_get_services 200 "service1" "service1" 50 "$CR_PATH/service1"
86 api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2"
88 api_get_service_ids 200 "service1" "service2"
90 sleep_wait 30 "Waiting for keep alive timeout"
92 api_get_services 200 "service1" "service1" 50 "$CR_PATH/service1"
93 api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2"
95 sleep_wait 100 "Waiting for keep alive timeout"
97 api_get_services 404 "service1"
98 api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2"
100 api_delete_services 204 "service2"
102 api_get_services 404 "service1"
103 api_get_services 404 "service2"
105 api_put_service 201 "service3" 60 "$CR_PATH/service3"
107 api_get_services 200 "service3" "service3" 60 "$CR_PATH/service3"
109 sleep_wait 30 "Waiting for keep alive timeout"
111 api_put_service 200 "service3" 60 "$CR_PATH/service3"
113 sleep_wait 100 "Waiting for keep alive timeout"
115 api_get_services 404 "service3"
117 api_put_service 201 "service4" 120 "$CR_PATH/service4"
119 sleep_wait 60 "Waiting for keep alive timeout"
121 api_get_services 200 "service4" "service4" 120 "$CR_PATH/service4"
123 api_put_services_keepalive 200 "service4"
125 sleep_wait 90 "Waiting for keep alive timeout"
127 api_get_services 200 "service4" "service4" 120 "$CR_PATH/service4"
129 api_delete_services 204 "service4"
131 api_get_services 404 "service4"
133 api_get_services 404 "service1"
134 api_get_services 404 "service2"
135 api_get_services 404 "service3"
137 api_get_service_ids 200
139 api_delete_services 404 "service1"
140 api_delete_services 404 "service2"
141 api_delete_services 404 "service3"
142 api_delete_services 404 "service4"
144 api_put_services_keepalive 404 "service1"
145 api_put_services_keepalive 404 "service2"
146 api_put_services_keepalive 404 "service3"
147 api_put_services_keepalive 404 "service4"
149 # Policy delete after timeout
150 api_put_service 201 "service10" 600 "$CR_PATH/service10"
152 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
154 api_equal json:rics 1 60
156 api_equal json:policy_schemas 1 120
158 api_equal json:policy_types 1
160 api_equal json:policies 0
162 api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json
164 api_equal json:policies 1
166 sim_equal ricsim_g1_1 num_instances 1
168 api_put_policy 201 "service10" ricsim_g1_1 1 5001 true testdata/OSC/pi1_template.json
170 api_equal json:policies 2
172 sim_equal ricsim_g1_1 num_instances 2
174 sim_post_delete_instances 200 ricsim_g1_1
176 #Wait for recreate of non transient policy
177 api_equal json:policies 1 180
179 sim_equal ricsim_g1_1 num_instances 1
181 api_put_service 200 "service10" 10 "$CR_PATH/service10"
183 #Wait for service expiry
184 api_equal json:policies 0 120
186 sim_equal ricsim_g1_1 num_instances 0
189 api_get_service_ids 200
191 deviation "TR18 Agents sends callback with empty body"
192 cr_equal received_callbacks 4
193 mr_equal requests_submitted 0
195 check_policy_agent_logs
196 check_control_panel_logs
198 #### TEST COMPLETE ####
204 auto_clean_containers