Adapted test scripts to changes in PMS 2.0
[nonrtric.git] / test / auto-test / FTC110.sh
1 #!/bin/bash
2
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
9 #
10 #       http://www.apache.org/licenses/LICENSE-2.0
11 #
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=================================================
18 #
19
20
21 TC_ONELINE_DESCR="Testing of service registration timeouts and keepalive"
22
23 #App names to include in the test, space separated list
24 INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM"
25
26 #SUPPORTED TEST ENV FILE
27 SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN"
28
29 . ../common/testcase_common.sh  $@
30 . ../common/agent_api_functions.sh
31 . ../common/ricsimulator_api_functions.sh
32 . ../common/cr_api_functions.sh
33
34 generate_uuid
35
36 use_cr_http
37 use_simulator_http
38 use_mr_http
39 use_agent_rest_http
40
41
42 #### TEST BEGIN ####
43
44 clean_containers
45
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
50 fi
51
52 start_mr
53
54 start_cr
55
56 start_consul_cbs
57
58 prepare_consul_config      NOSDNC  ".consul_config.json"
59 consul_config_app                  ".consul_config.json"
60
61 start_control_panel
62
63 start_policy_agent
64
65 set_agent_debug
66
67 mr_equal requests_submitted 0
68
69 #Check agent alive
70 api_get_status 200
71
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
77 fi
78
79 api_put_service 201 "service1" 15 "$CR_PATH/service1"
80
81 api_get_services 200 "service1" "service1" 15 "$CR_PATH/service1"
82
83 api_put_service 201 "service2" 120 "$CR_PATH/service2"
84
85 api_get_services 200 "service2" "service2" 120 "$CR_PATH/service2"
86
87 api_put_service 200 "service1" 50 "$CR_PATH/service1"
88 api_put_service 200 "service2" 180 "$CR_PATH/service2"
89
90 api_get_services 200 "service1" "service1" 50 "$CR_PATH/service1"
91 api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2"
92
93 api_get_service_ids 200 "service1" "service2"
94
95 sleep_wait 30 "Waiting for keep alive timeout"
96
97 api_get_services 200 "service1" "service1" 50 "$CR_PATH/service1"
98 api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2"
99
100 sleep_wait 100 "Waiting for keep alive timeout"
101
102 api_get_services 404 "service1"
103 api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2"
104
105 api_delete_services 204 "service2"
106
107 api_get_services 404 "service1"
108 api_get_services 404 "service2"
109
110 api_put_service 201 "service3" 60 "$CR_PATH/service3"
111
112 api_get_services 200 "service3" "service3" 60 "$CR_PATH/service3"
113
114 sleep_wait 30 "Waiting for keep alive timeout"
115
116 api_put_service 200 "service3" 60 "$CR_PATH/service3"
117
118 sleep_wait 100 "Waiting for keep alive timeout"
119
120 api_get_services 404 "service3"
121
122 api_put_service 201 "service4" 120 "$CR_PATH/service4"
123
124 sleep_wait 60 "Waiting for keep alive timeout"
125
126 api_get_services 200 "service4" "service4" 120 "$CR_PATH/service4"
127
128 api_put_services_keepalive 200 "service4"
129
130 sleep_wait 90 "Waiting for keep alive timeout"
131
132 api_get_services 200 "service4" "service4" 120 "$CR_PATH/service4"
133
134 api_delete_services 204 "service4"
135
136 api_get_services 404 "service4"
137
138 api_get_services 404 "service1"
139 api_get_services 404 "service2"
140 api_get_services 404 "service3"
141
142 api_get_service_ids 200
143
144 api_delete_services 404 "service1"
145 api_delete_services 404 "service2"
146 api_delete_services 404 "service3"
147 api_delete_services 404 "service4"
148
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"
153
154 # Policy delete after timeout
155 api_put_service 201 "service10" 600 "$CR_PATH/service10"
156
157 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
158
159 if [ "$PMS_VERSION" == "V2" ]; then
160     api_equal json:rics 3 60
161
162     #api_equal json:policy_schemas 2 120
163
164     api_equal json:policy-types 2 120
165
166     api_equal json:policies 0
167 else
168     api_equal json:rics 2 60
169
170     api_equal json:policy_schemas 2 120
171
172     api_equal json:policy_types 2
173
174     api_equal json:policies 0
175 fi
176
177 if [ "$PMS_VERSION" == "V2" ]; then
178     notificationurl=$CR_PATH"/test"
179 else
180     notificationurl=""
181 fi
182
183 api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
184 api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
185
186 api_equal json:policies 2
187
188 sim_equal ricsim_g1_1 num_instances 1
189 sim_equal ricsim_g2_1 num_instances 1
190
191 api_put_policy 201 "service10" ricsim_g1_1 1 5001 true $notificationurl testdata/OSC/pi1_template.json
192 api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5101 true $notificationurl testdata/STD/pi1_template.json
193
194 api_equal json:policies 4
195
196 sim_equal ricsim_g1_1 num_instances 2
197 sim_equal ricsim_g2_1 num_instances 2
198
199 sim_post_delete_instances 200 ricsim_g1_1
200 sim_post_delete_instances 200 ricsim_g2_1
201
202 #Wait for recreate of non transient policy
203 api_equal json:policies 2 180
204
205 sim_equal ricsim_g1_1 num_instances 1
206 sim_equal ricsim_g2_1 num_instances 1
207
208 api_put_service 200 "service10" 10 "$CR_PATH/service10"
209
210 #Wait for service expiry
211 api_equal json:policies 0 120
212
213 sim_equal ricsim_g1_1 num_instances 0
214 sim_equal ricsim_g2_1 num_instances 0
215
216 api_get_service_ids 200
217
218 mr_equal requests_submitted 0
219
220 check_policy_agent_logs
221 check_control_panel_logs
222
223 #### TEST COMPLETE ####
224
225 store_logs          END
226
227 print_result
228
229 auto_clean_containers