Corrected rApp Catalogue image tag for d release test
[nonrtric.git] / test / auto-test / FTC_HELM_RECIPE_D_RELEASE.sh
1 #!/usr/bin/env 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="Sanity test of Non-RT RIC Helm recepie - all components - D-RELEASE"
21
22 #App names to include in the test when running docker, space separated list
23 DOCKER_INCLUDED_IMAGES="" # Not used -  KUBE only test script
24
25 #App names to include in the test when running kubernetes, space separated list
26 KUBE_INCLUDED_IMAGES=" MR CR  PRODSTUB KUBEPROXY"
27 #Prestarted app (not started by script) to include in the test when running kubernetes, space separated list
28 KUBE_PRESTARTED_IMAGES=" PA RICSIM CP ECS RC SDNC"
29
30 #Supported test environment profiles
31 SUPPORTED_PROFILES="ORAN-D-RELEASE"
32 #Supported run modes
33 SUPPORTED_RUNMODES="KUBE"
34
35 . ../common/testcase_common.sh $@
36 . ../common/agent_api_functions.sh
37 . ../common/ricsimulator_api_functions.sh
38 . ../common/ecs_api_functions.sh
39 . ../common/prodstub_api_functions.sh
40 . ../common/cr_api_functions.sh
41 . ../common/rapp_catalogue_api_functions.sh
42 . ../common/mr_api_functions.sh
43 . ../common/control_panel_api_functions.sh
44 . ../common/controller_api_functions.sh
45 . ../common/kube_proxy_api_functions.sh
46
47 setup_testenvironment
48
49 #### TEST BEGIN ####
50
51 use_mr_http       #MR only supports http?
52 use_cr_https
53 use_agent_rest_https
54 use_sdnc_https
55 use_simulator_https
56 use_ecs_rest_https
57 use_prod_stub_https
58 if [ $ECS_VERSION == "V1-1" ]; then
59     use_rapp_catalogue_http # https not yet supported
60 else
61     ########################################use_rapp_catalogue_https
62     use_rapp_catalogue_http
63 fi
64
65 echo -e "$RED CHECK WHY RC HTTPS DOES NOT WORK $ERED"
66
67 ###############################use_control_panel_https
68 use_control_panel_http
69
70 if [ "$PMS_VERSION" == "V1" ]; then
71    echo "PMS VERSION 2 (V2) is required"
72    exit 1
73 fi
74
75 clean_environment
76
77 pms_kube_pvc_reset
78
79 ecs_kube_pvc_reset
80
81 start_kube_proxy
82
83 STD_NUM_RICS=2
84 OSC_NUM_RICS=2
85
86 start_ric_simulators a1-sim-osc $STD_NUM_RICS OSC_2.1.0
87 echo " RIC MAPPING a1-sim-osc-0 : ric1"
88 echo " RIC MAPPING a1-sim-osc-1 : ric2"
89
90 start_ric_simulators a1-sim-std $STD_NUM_RICS STD_1.1.3
91 echo " RIC MAPPING a1-sim-std-0 : ric3"
92 echo " RIC MAPPING a1-sim-std-1 : ric4"
93
94 start_ric_simulators a1-sim-std2 $STD_NUM_RICS STD_2.0.0
95 echo " RIC MAPPING a1-sim-std2-0 : ric5"
96 echo " RIC MAPPING a1-sim-std2-1 : ric6"
97
98 start_mr
99
100 start_control_panel
101
102 start_sdnc
103
104 start_policy_agent
105
106 start_cr
107
108 start_prod_stub
109
110 start_ecs NOPROXY
111
112 set_ecs_trace
113
114 start_rapp_catalogue
115
116 set_agent_trace
117
118 #### Test RAPP Catalogue ####
119
120 rapp_cat_api_get_services 200 EMPTY
121
122 rapp_cat_api_put_service 201 "Emergency-response-app" v1 "Emergency-response-app" "Emergency-response-app"
123
124 rapp_cat_api_get_services 200 "Emergency-response-app" v1 "Emergency-response-app" "Emergency-response-app"
125
126 #Check the number of services
127 rc_equal json:services 1
128
129 api_get_status 200
130
131 #### Test Policy Management Service ####
132
133 # Print the A1 version for STD 1.1.X
134 for ((i=0; i<$STD_NUM_RICS; i++))
135 do
136     sim_print "a1-sim-std-"$i interface
137 done
138
139 # Print the A1 version for STD 2.0.X
140 for ((i=0; i<$STD_NUM_RICS; i++))
141 do
142    sim_print "a1-sim-std2-"$i interface
143 done
144
145 # Print the A1 version for OSC 2.1.X
146 for ((i=0; i<$OSC_NUM_RICS; i++))
147 do
148     sim_print "a1-sim-osc-"$i interface
149 done
150
151 # Load the polictypes in STD 2
152 for ((i=0; i<$STD_NUM_RICS; i++))
153 do
154    sim_put_policy_type 201 "a1-sim-std2-"$i STD_QOS_0_2_0 testdata/STD2/sim_qos.json
155    sim_put_policy_type 201 "a1-sim-std2-"$i STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
156 done
157
158 # Load the polictypes in OSC
159 for ((i=0; i<$OSC_NUM_RICS; i++))
160 do
161     sim_put_policy_type 201 "a1-sim-osc-"$i 1 testdata/OSC/sim_1.json
162     sim_put_policy_type 201 "a1-sim-osc-"$i 2 testdata/OSC/sim_2.json
163 done
164
165 # Check that all rics are synced in
166 api_equal json:rics 6 300
167
168 #Check the number of schemas and the individual schemas
169 api_equal json:policy-types 5 300
170
171 for ((i=0; i<$STD_NUM_RICS; i++))
172 do
173     ricid=$((3+$i))
174     api_equal json:policy-types?ric_id=ric$ricid 1 120
175 done
176
177 for ((i=0; i<$STD_NUM_RICS; i++))
178 do
179    ricid=$((5+$i))
180    api_equal json:policy-types?ric_id=ric$ricid 2 120
181 done
182
183 for ((i=0; i<$OSC_NUM_RICS; i++))
184 do
185     ricid=$((1+$i))
186     api_equal json:policy-types?ric_id=ric$ricid 2 120
187 done
188
189 #Check the schemas in STD 2
190 for ((i=0; i<$OSC_NUM_RICS; i++))
191 do
192    ricid=$((5+$i))
193    api_get_policy_type 200 STD_QOS_0_2_0 testdata/STD2/qos-agent-modified.json
194    api_get_policy_type 200 STD_QOS2_0.1.0 testdata/STD2/qos2-agent-modified.json
195 done
196
197 # Check the schemas in OSC
198 for ((i=0; i<$OSC_NUM_RICS; i++))
199 do
200     api_get_policy_type 200 1 testdata/OSC/1-agent-modified.json
201     api_get_policy_type 200 2 testdata/OSC/2-agent-modified.json
202 done
203
204 if [ "$PMS_VERSION" == "V2" ]; then
205
206     api_equal json:policy-types 5 120
207
208     api_equal json:policies 0
209
210     api_equal json:policy-instances 0
211 else
212
213     api_equal json:policy_schemas 5 120
214
215     api_equal json:policy_types 5
216
217     api_equal json:policies 0
218
219     api_equal json:policy_ids 0
220 fi
221
222 api_put_service 201 "Emergency-response-app" 0 "$CR_SERVICE_PATH/ER-app"
223
224 # Create policies in STD
225 for ((i=0; i<$STD_NUM_RICS; i++))
226 do
227     ricid=$((3+$i))
228     generate_policy_uuid
229     api_put_policy 201 "Emergency-response-app" ric$ricid NOTYPE $((1100+$i)) NOTRANSIENT $CR_SERVICE_PATH/"std2" testdata/STD/pi1_template.json 1
230     generate_policy_uuid
231     api_put_policy 201 "Emergency-response-app" ric$ricid NOTYPE $((1200+$i)) NOTRANSIENT $CR_SERVICE_PATH/"std2" testdata/STD/pi1_template.json 1
232 done
233
234 #Create policies in STD 2
235 for ((i=0; i<$STD_NUM_RICS; i++))
236 do
237    ricid=$((5+$i))
238    generate_policy_uuid
239    api_put_policy 201 "Emergency-response-app" ric$ricid STD_QOS_0_2_0 $((2100+$i)) NOTRANSIENT $CR_SERVICE_PATH/"std2" testdata/STD2/pi_qos_template.json 1
240    generate_policy_uuid
241    api_put_policy 201 "Emergency-response-app" ric$ricid STD_QOS2_0.1.0 $((2200+$i)) NOTRANSIENT $CR_SERVICE_PATH/"std2" testdata/STD2/pi_qos2_template.json 1
242 done
243
244 # Create policies in OSC
245 for ((i=0; i<$OSC_NUM_RICS; i++))
246 do
247     ricid=$((1+$i))
248     generate_policy_uuid
249     api_put_policy 201 "Emergency-response-app" ric$ricid 1 $((3100+$i)) NOTRANSIENT $CR_SERVICE_PATH/"osc" testdata/OSC/pi1_template.json 1
250     generate_policy_uuid
251     api_put_policy 201 "Emergency-response-app" ric$ricid 2 $((3200+$i)) NOTRANSIENT $CR_SERVICE_PATH/"osc" testdata/OSC/pi2_template.json 1
252 done
253
254
255 # Check the number of policies in STD and STD2
256 for ((i=0; i<$STD_NUM_RICS; i++))
257 do
258     sim_equal "a1-sim-std-"$i num_instances 2
259     sim_equal "a1-sim-std2-"$i num_instances 2
260 done
261
262 # Check the number of policies in OSC
263 for ((i=0; i<$STD_NUM_RICS; i++))
264 do
265     sim_equal "a1-sim-osc-"$i num_instances 2
266 done
267
268 stop_policy_agent
269
270 start_stopped_policy_agent
271
272 # Check PMS state after restart
273
274 sleep_wait 200
275
276 if [ "$PMS_VERSION" == "V2" ]; then
277
278     api_equal json:policy-types 5 120
279
280     api_equal json:policies 12
281
282     api_equal json:policy-instances 12
283 else
284
285     api_equal json:policy_schemas 5 120
286
287     api_equal json:policy_types 5
288
289     api_equal json:policies 12
290
291     api_equal json:policy_ids 12
292 fi
293
294 # Check the number of policies in STD and STD2
295 for ((i=0; i<$STD_NUM_RICS; i++))
296 do
297     sim_equal "a1-sim-std-"$i num_instances 2
298     sim_equal "a1-sim-std2-"$i num_instances 2
299 done
300
301 # Check the number of policies in OSC
302 for ((i=0; i<$STD_NUM_RICS; i++))
303 do
304     sim_equal "a1-sim-osc-"$i num_instances 2
305 done
306
307
308 echo "ADD EVENT/STATUS CHECK"
309 echo "ADD MR CHECK"
310
311 FLAT_A1_EI="1"
312
313 ecs_api_admin_reset
314
315 CB_JOB="$PROD_STUB_SERVICE_PATH$PROD_STUB_JOB_CALLBACK"
316 CB_SV="$PROD_STUB_SERVICE_PATH$PROD_STUB_SUPERVISION_CALLBACK"
317 TARGET1="$RIC_SIM_HTTPX://a1-sim-std2-0.a1-sim:$RIC_SIM_PORT/datadelivery"
318 TARGET2="$RIC_SIM_HTTPX://a1-sim-std2-1.a1-sim:$RIC_SIM_PORT/datadelivery"
319
320 STATUS1="$CR_SERVICE_PATH/job1-status"
321 STATUS2="$CR_SERVICE_PATH/job2-status"
322
323 prodstub_arm_producer 200 prod-a
324 prodstub_arm_type 200 prod-a type1
325 prodstub_arm_job_create 200 prod-a job1
326 prodstub_arm_job_create 200 prod-a job2
327
328
329 ### ecs status
330 ecs_api_service_status 200
331
332 ## Setup prod-a
333 if [ $ECS_VERSION == "V1-1" ]; then
334     ecs_api_edp_put_producer 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json
335
336     ecs_api_edp_get_producer 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1 testdata/ecs/ei-type-1.json
337 else
338     ecs_api_edp_put_type_2 201 type1 testdata/ecs/ei-type-1.json
339     ecs_api_edp_get_type_2 200 type1
340     ecs_api_edp_get_type_ids 200 type1
341
342     ecs_api_edp_put_producer_2 201 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1
343     ecs_api_edp_put_producer_2 200 prod-a $CB_JOB/prod-a $CB_SV/prod-a type1
344 fi
345
346 ecs_api_edp_get_producer_status 200 prod-a ENABLED
347
348
349 ## Create a job for prod-a
350 ## job1 - prod-a
351 if [  -z "$FLAT_A1_EI" ]; then
352     ecs_api_a1_put_job 201 type1 job1 $TARGET1 ricsim_g3_1 testdata/ecs/job-template.json
353 else
354     ecs_api_a1_put_job 201 job1 type1 $TARGET1 ricsim_g3_1 $STATUS1 testdata/ecs/job-template.json
355 fi
356
357 # Check the job data in the producer
358 if [ $ECS_VERSION == "V1-1" ]; then
359     prodstub_check_jobdata 200 prod-a job1 type1 $TARGET1 ricsim_g3_1 testdata/ecs/job-template.json
360 else
361     if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
362         prodstub_check_jobdata_3 200 prod-a job1 type1 $TARGET1 ricsim_g3_1 testdata/ecs/job-template.json
363     else
364         prodstub_check_jobdata_2 200 prod-a job1 type1 $TARGET1 ricsim_g3_1 testdata/ecs/job-template.json
365     fi
366 fi
367
368 ## Create a second job for prod-a
369 ## job2 - prod-a
370 if [  -z "$FLAT_A1_EI" ]; then
371     ecs_api_a1_put_job 201 type1 job2 $TARGET2 ricsim_g3_2 testdata/ecs/job-template.json
372 else
373     ecs_api_a1_put_job 201 job2 type1 $TARGET2 ricsim_g3_2 $STATUS2 testdata/ecs/job-template.json
374 fi
375
376 # Check the job data in the producer
377 if [ $ECS_VERSION == "V1-1" ]; then
378     prodstub_check_jobdata 200 prod-a job2 type1 $TARGET2 ricsim_g3_2 testdata/ecs/job-template.json
379 else
380     if [[ "$ECS_FEATURE_LEVEL" == *"INFO-TYPES"* ]]; then
381         prodstub_check_jobdata_3 200 prod-a job2 type1 $TARGET2 ricsim_g3_2 testdata/ecs/job-template.json
382     else
383         prodstub_check_jobdata_2 200 prod-a job2 type1 $TARGET2 ricsim_g3_2 testdata/ecs/job-template.json
384     fi
385 fi
386
387 stop_ecs
388
389 start_stopped_ecs
390
391 # Check ECS status after restart
392
393 if [  -z "$FLAT_A1_EI" ]; then
394     ecs_api_a1_get_job_status 200 type1 job1 DISABLED
395     ecs_api_a1_get_job_status 200 type1 job2 DISABLED
396 else
397     ecs_api_a1_get_job_status 200 job1 DISABLED
398     ecs_api_a1_get_job_status 200 job2 DISABLED
399 fi
400
401 check_policy_agent_logs
402 check_ecs_logs
403 check_sdnc_logs
404
405 #### TEST COMPLETE ####
406
407 store_logs          END
408
409 print_result