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="SDMC SDNC_ONAP"
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"
43 start_ric_simulators ricsim_g1 1 OSC_2.1.0
51 prepare_consul_config NOSDNC ".consul_config.json"
52 consul_config_app ".consul_config.json"
62 #Verify no callbacks or dmaap messages has been sent
63 cr_equal received_callbacks 0
64 mr_equal requests_submitted 0
69 #Print simulator interface version
70 sim_print ricsim_g1_1 interface
72 api_put_service 201 "service1" 15 "$CR_PATH/service1"
74 api_get_services 200 "service1" "service1" 15 "$CR_PATH/service1"
76 api_put_service 201 "service2" 120 "$CR_PATH/service2"
78 api_get_services 200 "service2" "service2" 120 "$CR_PATH/service2"
80 api_put_service 200 "service1" 50 "$CR_PATH/service1"
81 api_put_service 200 "service2" 180 "$CR_PATH/service2"
83 api_get_services 200 "service1" "service1" 50 "$CR_PATH/service1"
84 api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2"
86 api_get_service_ids 200 "service1" "service2"
88 sleep_wait 30 "Waiting for keep alive timeout"
90 api_get_services 200 "service1" "service1" 50 "$CR_PATH/service1"
91 api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2"
93 sleep_wait 100 "Waiting for keep alive timeout"
95 api_get_services 404 "service1"
96 api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2"
98 api_delete_services 204 "service2"
100 api_get_services 404 "service1"
101 api_get_services 404 "service2"
103 api_put_service 201 "service3" 60 "$CR_PATH/service3"
105 api_get_services 200 "service3" "service3" 60 "$CR_PATH/service3"
107 sleep_wait 30 "Waiting for keep alive timeout"
109 api_put_service 200 "service3" 60 "$CR_PATH/service3"
111 sleep_wait 100 "Waiting for keep alive timeout"
113 api_get_services 404 "service3"
115 api_put_service 201 "service4" 120 "$CR_PATH/service4"
117 sleep_wait 60 "Waiting for keep alive timeout"
119 api_get_services 200 "service4" "service4" 120 "$CR_PATH/service4"
121 api_put_services_keepalive 200 "service4"
123 sleep_wait 90 "Waiting for keep alive timeout"
125 api_get_services 200 "service4" "service4" 120 "$CR_PATH/service4"
127 api_delete_services 204 "service4"
129 api_get_services 404 "service4"
131 api_get_services 404 "service1"
132 api_get_services 404 "service2"
133 api_get_services 404 "service3"
135 api_get_service_ids 200
137 api_delete_services 404 "service1"
138 api_delete_services 404 "service2"
139 api_delete_services 404 "service3"
140 api_delete_services 404 "service4"
142 api_put_services_keepalive 404 "service1"
143 api_put_services_keepalive 404 "service2"
144 api_put_services_keepalive 404 "service3"
145 api_put_services_keepalive 404 "service4"
147 # Policy delete after timeout
148 api_put_service 201 "service10" 600 "$CR_PATH/service10"
150 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
152 api_equal json:rics 1 60
154 api_equal json:policy_schemas 1 120
156 api_equal json:policy_types 1
158 api_equal json:policies 0
160 api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json
162 api_equal json:policies 1
164 sim_equal ricsim_g1_1 num_instances 1
166 api_put_policy 201 "service10" ricsim_g1_1 1 5001 true testdata/OSC/pi1_template.json
168 api_equal json:policies 2
170 sim_equal ricsim_g1_1 num_instances 2
172 sim_post_delete_instances 200 ricsim_g1_1
174 #Wait for recreate of non transient policy
175 api_equal json:policies 1 180
177 sim_equal ricsim_g1_1 num_instances 1
179 api_put_service 200 "service10" 10 "$CR_PATH/service10"
181 #Wait for service expiry
182 api_equal json:policies 0 120
184 sim_equal ricsim_g1_1 num_instances 0
187 api_get_service_ids 200
189 deviation "TR18 Agents sends callback with empty body"
190 cr_equal received_callbacks 0
191 mr_equal requests_submitted 0
193 check_policy_agent_logs
194 check_control_panel_logs
196 #### TEST COMPLETE ####
202 auto_clean_containers