Merge "Update of EI Data Producer API"
[nonrtric.git] / test / auto-test / FTC10.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 TC_ONELINE_DESCR="Basic use case, register service, create/update policy, delete policy, de-register service using both STD and OSC interface while mixing REST and Dmaap"
21
22 #App names to include in the test when running docker, space separated list
23 DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM"
24
25 #App names to include in the test when running kubernetes, space separated list
26 KUBE_INCLUDED_IMAGES=" MR CR PA RICSIM CP"
27 #Prestarted app (not started by script) to include in the test when running kubernetes, space separated list
28 KUBE_PRESTARTED_IMAGES=""
29
30 #Supported test environment profiles
31 SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU  ORAN-CHERRY ORAN-DAWN"
32 #Supported run modes
33 SUPPORTED_RUNMODES="DOCKER KUBE"
34
35 . ../common/testcase_common.sh $@
36 . ../common/agent_api_functions.sh
37 . ../common/consul_cbs_functions.sh
38 . ../common/control_panel_api_functions.sh
39 . ../common/controller_api_functions.sh
40 . ../common/cr_api_functions.sh
41 . ../common/mr_api_functions.sh
42 . ../common/ricsimulator_api_functions.sh
43
44 #### TEST BEGIN ####
45
46 generate_uuid
47
48 use_simulator_http
49 use_mr_http
50 use_agent_rest_http
51
52
53 clean_environment
54
55 start_ric_simulators  ricsim_g1 3 OSC_2.1.0
56
57 start_ric_simulators  ricsim_g2 5 STD_1.1.3
58
59 if [ "$PMS_VERSION" == "V2" ]; then
60     start_ric_simulators ricsim_g3 1  STD_2.0.0
61 fi
62
63 start_mr
64
65 start_cr
66
67 if [ $RUNMODE == "DOCKER" ]; then
68     start_consul_cbs
69 fi
70
71 start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/application.properties
72
73 start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/application.yaml
74
75 set_agent_debug
76
77 use_agent_rest_http
78
79 prepare_consul_config      NOSDNC  ".consul_config.json"
80
81 if [ $RUNMODE == "KUBE" ]; then
82     agent_load_config                       ".consul_config.json"
83 else
84     consul_config_app                      ".consul_config.json"
85 fi
86
87 api_get_status 200
88
89 sim_print ricsim_g1_1 interface
90
91 sim_print ricsim_g2_1 interface
92
93 if [ "$PMS_VERSION" == "V2" ]; then
94     sim_print ricsim_g3_1 interface
95 fi
96
97 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
98
99 if [ "$PMS_VERSION" == "V2" ]; then
100     sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
101     api_equal json:policy-types 3 300
102 else
103     api_equal json:policy_types 2 300
104 fi
105
106 # Create policies
107
108 if [ "$PMS_VERSION" == "V2" ]; then
109     notificationurl=$CR_SERVICE_PATH"/test"
110 else
111     notificationurl=""
112 fi
113
114 use_agent_rest_http
115
116 api_put_service 201 "service1" 3600 "$CR_SERVICE_PATH/1"
117
118 api_put_policy 201 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
119
120 sim_equal ricsim_g1_1 num_instances 1
121
122
123 use_agent_dmaap_http
124
125 api_put_policy 201 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
126
127 sim_equal ricsim_g1_1 num_instances 2
128
129
130 use_agent_rest_http
131
132 api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
133
134 sim_equal ricsim_g2_1 num_instances 1
135
136
137 use_agent_dmaap_http
138
139 api_put_policy 201 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
140
141 sim_equal ricsim_g2_1 num_instances 2
142
143 if [ "$PMS_VERSION" == "V2" ]; then
144     use_agent_rest_http
145
146     api_put_policy 201 "service1" ricsim_g3_1 STD_QOS_0_2_0 2200 true $notificationurl testdata/STD2/pi_qos_template.json 1
147
148     sim_equal ricsim_g3_1 num_instances 1
149
150     use_agent_dmaap_http
151
152     api_put_policy 201 "service1" ricsim_g3_1 STD_QOS_0_2_0 3200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos_template.json 1
153
154     sim_equal ricsim_g3_1 num_instances 2
155
156 fi
157
158 #Update policies
159 use_agent_rest_http
160
161 api_put_service 200 "service1" 3600 "$CR_SERVICE_PATH/1"
162
163 api_put_policy 200 "service1" ricsim_g1_1 1 2000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
164
165 sim_equal ricsim_g1_1 num_instances 2
166
167
168 use_agent_dmaap_http
169
170 api_put_policy 200 "service1" ricsim_g1_1 1 3000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json 1
171
172 sim_equal ricsim_g1_1 num_instances 2
173
174
175 use_agent_rest_http
176
177
178 api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 2100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
179
180 sim_equal ricsim_g2_1 num_instances 2
181
182
183 use_agent_dmaap_http
184
185 api_put_policy 200 "service1" ricsim_g2_1 NOTYPE 3100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json 1
186
187 sim_equal ricsim_g2_1 num_instances 2
188
189 if [ "$PMS_VERSION" == "V2" ]; then
190     use_agent_rest_http
191
192     api_put_policy 200 "service1" ricsim_g3_1 STD_QOS_0_2_0 2200 true $notificationurl testdata/STD2/pi_qos_template.json 1
193
194     sim_equal ricsim_g3_1 num_instances 2
195
196
197     use_agent_dmaap_http
198
199     api_put_policy 200 "service1" ricsim_g3_1 STD_QOS_0_2_0 3200 true $notificationurl testdata/STD2/pi_qos_template.json 1
200
201     sim_equal ricsim_g3_1 num_instances 2
202 fi
203
204 # Check policies
205 if [ "$PMS_VERSION" == "V2" ]; then
206     api_get_policy 200 2000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
207     api_get_policy 200 3000 testdata/OSC/pi1_template.json "service1" ricsim_g1_1 1 false $notificationurl
208     api_get_policy 200 2100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
209     api_get_policy 200 3100 testdata/STD/pi1_template.json "service1" ricsim_g2_1 NOTYPE false $notificationurl
210     api_get_policy 200 2200 testdata/STD2/pi_qos_template.json "service1" ricsim_g3_1 STD_QOS_0_2_0 true $notificationurl
211     api_get_policy 200 3200 testdata/STD2/pi_qos_template.json "service1" ricsim_g3_1 STD_QOS_0_2_0 true $notificationurl
212 else
213     api_get_policy 200 2000 testdata/OSC/pi1_template.json
214     api_get_policy 200 3000 testdata/OSC/pi1_template.json
215     api_get_policy 200 2100 testdata/STD/pi1_template.json
216     api_get_policy 200 3100 testdata/STD/pi1_template.json
217 fi
218
219 sim_equal ricsim_g1_1 num_instances 2
220 sim_equal ricsim_g2_1 num_instances 2
221
222 if [ "$PMS_VERSION" == "V2" ]; then
223     sim_equal ricsim_g3_1 num_instances 2
224 fi
225
226 # Remove policies
227
228 use_agent_dmaap_http
229 api_delete_policy 204 2000
230 use_agent_rest_http
231 api_delete_policy 204 3000
232 use_agent_dmaap_http
233 api_delete_policy 204 2100
234 use_agent_rest_http
235 api_delete_policy 204 3100
236 if [ "$PMS_VERSION" == "V2" ]; then
237     use_agent_dmaap_http
238     api_delete_policy 204 2200
239     use_agent_rest_http
240     api_delete_policy 204 3200
241 fi
242
243 sim_equal ricsim_g1_1 num_instances 0
244 sim_equal ricsim_g2_1 num_instances 0
245
246 if [ "$PMS_VERSION" == "V2" ]; then
247     sim_equal ricsim_g3_1 num_instances 0
248 fi
249
250 # Check remote host access to simulator
251
252 sim_contains_str ricsim_g1_1 remote_hosts $POLICY_AGENT_APP_NAME
253 sim_contains_str ricsim_g2_1 remote_hosts $POLICY_AGENT_APP_NAME
254 if [ "$PMS_VERSION" == "V2" ]; then
255     sim_contains_str ricsim_g3_1 remote_hosts $POLICY_AGENT_APP_NAME
256 fi
257
258 # Check policy removal
259 use_agent_rest_http
260 api_get_policy 404 2000
261 api_get_policy 404 3000
262 api_get_policy 404 2100
263 api_get_policy 404 3100
264
265 if [ "$PMS_VERSION" == "V2" ]; then
266     api_get_policy 404 2200
267     api_get_policy 404 3200
268 fi
269
270 # Remove the service
271 use_agent_dmaap_http
272 api_delete_services 204 "service1"
273
274 api_get_services 404 "service1"
275
276 check_policy_agent_logs
277
278 #### TEST COMPLETE ####
279
280 store_logs          END
281
282 print_result
283
284 auto_clean_environment