Functional Test Updates for I Release
[nonrtric.git] / test / auto-test / ONAP_UC.sh
1 #!/usr/bin/env bash
2
3 #  ============LICENSE_START===============================================
4 #  Copyright (C) 2020-2023 Nordix Foundation. All rights reserved.
5 #  Copyright (C) 2023 OpenInfra Foundation Europe. All rights reserved.
6 #  ========================================================================
7 #  Licensed under the Apache License, Version 2.0 (the "License");
8 #  you may not use this file except in compliance with the License.
9 #  You may obtain a copy of the License at
10 #
11 #       http://www.apache.org/licenses/LICENSE-2.0
12 #
13 #  Unless required by applicable law or agreed to in writing, software
14 #  distributed under the License is distributed on an "AS IS" BASIS,
15 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 #  See the License for the specific language governing permissions and
17 #  limitations under the License.
18 #  ============LICENSE_END=================================================
19 #
20
21
22 TC_ONELINE_DESCR="ONAP Use case REQ-626"
23 #App names to include in the test when running docker, space separated list
24 DOCKER_INCLUDED_IMAGES="CP CR MR DMAAPMR A1PMS RICSIM SDNC NGW KUBEPROXY"
25
26 #App names to include in the test when running kubernetes, space separated list
27 KUBE_INCLUDED_IMAGES="CP CR MR DMAAPMR A1PMS RICSIM SDNC KUBEPROXY NGW"
28 #Pre-started app (not started by script) to include in the test when running kubernetes, space separated list
29 KUBE_PRESTARTED_IMAGES=""
30
31 #Ignore image in DOCKER_INCLUDED_IMAGES, KUBE_INCLUDED_IMAGES if
32 #the image is not configured in the supplied env_file
33 #Used for images not applicable to all supported profile
34 CONDITIONALLY_IGNORED_IMAGES="NGW"
35
36 #Supported test environment profiles
37 SUPPORTED_PROFILES="ONAP-KOHN ONAP-LONDON ONAP-MONTREAL"
38 #Supported run modes
39 SUPPORTED_RUNMODES="DOCKER KUBE"
40
41 . ../common/testcase_common.sh $@
42
43 setup_testenvironment
44
45 #### TEST BEGIN ####
46
47 #Local vars in test script
48 ##########################
49
50 use_cr_https
51 use_a1pms_rest_https
52 if [[ "$SDNC_FEATURE_LEVEL" == *"NO_NB_HTTPS"* ]]; then
53     deviation "SDNC does not support NB https"
54     use_sdnc_http
55 else
56     use_sdnc_https
57 fi
58 use_simulator_https
59 if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
60     :
61 else
62     use_mr_https
63 fi
64 __httpx="HTTPS"
65 notificationurl=$CR_SERVICE_APP_PATH_0"/test"
66
67 sim_generate_policy_uuid
68
69 # Tested variants of REST/DMAAP/SDNC config
70
71
72 if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
73     TESTED_VARIANTS="REST   REST+SDNC"
74 else
75     TESTED_VARIANTS="REST   DMAAP   REST+SDNC   DMAAP+SDNC"
76 fi
77
78 for interface in $TESTED_VARIANTS ; do
79
80     echo "#####################################################################"
81     echo "#####################################################################"
82     echo "### Testing a1pms: $interface using https"
83     echo "#####################################################################"
84     echo "#####################################################################"
85
86     clean_environment
87
88     start_kube_proxy
89
90     if [[ $interface = *"DMAAP"* ]]; then
91         use_a1pms_dmaap_https
92     else
93         use_a1pms_rest_https
94     fi
95
96     OSC_NUM_RICS=1
97     STD_NUM_RICS=1
98
99     start_ric_simulators  $RIC_SIM_PREFIX"_g1" $OSC_NUM_RICS OSC_2.1.0
100
101     start_ric_simulators  $RIC_SIM_PREFIX"_g2" $STD_NUM_RICS STD_1.1.3
102
103     start_ric_simulators $RIC_SIM_PREFIX"_g3" $STD_NUM_RICS STD_2.0.0
104
105     if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
106         :
107     else
108         start_mr    "$MR_READ_TOPIC"  "/events" "users/policy-agent" \
109                     "$MR_WRITE_TOPIC" "/events" "users/mr-stub"
110     fi
111
112     start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
113
114     if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
115         start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
116     fi
117
118
119
120     if [[ $interface = *"SDNC"* ]]; then
121         start_sdnc
122         controller_api_wait_for_status_ok 200 ricsim_g1_1
123         prepare_a1pms_config      SDNC    ".a1pms_config.json"
124     else
125         prepare_a1pms_config      NOSDNC  ".a1pms_config.json"
126     fi
127
128     start_a1pms NORPOXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
129
130     set_a1pms_trace
131
132     if [ $RUNMODE == "KUBE" ]; then
133         a1pms_load_config                       ".a1pms_config.json"
134     else
135         #Temporary switch to http/https if dmaap use. Otherwise it is not possible to push config
136         if [ $__httpx == "HTTPS" ]; then
137             use_a1pms_rest_https
138         else
139             use_a1pms_rest_http
140         fi
141         a1pms_api_put_configuration 200 ".a1pms_config.json"
142         if [ $__httpx == "HTTPS" ]; then
143             if [[ $interface = *"DMAAP"* ]]; then
144                 use_a1pms_dmaap_https
145             else
146                 use_a1pms_rest_https
147             fi
148         else
149             if [[ $interface = *"DMAAP"* ]]; then
150                 use_a1pms_dmaap_http
151             else
152                 use_a1pms_rest_http
153             fi
154         fi
155     fi
156
157     # Check that all rics are synced in
158     a1pms_equal json:rics 3 300
159
160     a1pms_api_get_status 200
161
162     # Print the A1 version for OSC
163     for ((i=1; i<=$OSC_NUM_RICS; i++))
164     do
165         sim_print $RIC_SIM_PREFIX"_g1_"$i interface
166     done
167
168
169     # Print the A1 version for STD 1.X
170     for ((i=1; i<=$STD_NUM_RICS; i++))
171     do
172         sim_print $RIC_SIM_PREFIX"_g2_"$i interface
173     done
174
175     # Print the A1 version for STD 2.X
176     for ((i=1; i<=$STD_NUM_RICS; i++))
177     do
178         sim_print $RIC_SIM_PREFIX"_g3_"$i interface
179     done
180
181     #################################################################
182     ## REQ: Synchronize A1 Policy Information in RAN
183     #################################################################
184
185     # Load the policytypes in osc
186     for ((i=1; i<=$OSC_NUM_RICS; i++))
187     do
188         sim_put_policy_type 201 $RIC_SIM_PREFIX"_g1_"$i 100 demo-testdata/OSC/sim_qos.json
189         sim_put_policy_type 201 $RIC_SIM_PREFIX"_g1_"$i 20008 demo-testdata/OSC/sim_tsa.json
190     done
191
192     #Check the number of schemas and the individual schemas in OSC
193     a1pms_equal json:policy-types 3 300
194
195     for ((i=1; i<=$OSC_NUM_RICS; i++))
196     do
197         a1pms_equal json:policy-types?ric_id=$RIC_SIM_PREFIX"_g1_"$i 2 120
198     done
199
200     # Check the schemas in OSC
201     for ((i=1; i<=$OSC_NUM_RICS; i++))
202     do
203         a1pms_api_get_policy_type 200 100 demo-testdata/OSC/qos-a1pms-modified.json
204         a1pms_api_get_policy_type 200 20008 demo-testdata/OSC/tsa-a1pms-modified.json
205     done
206
207
208     # Load the policytypes in std
209     for ((i=1; i<=$STD_NUM_RICS; i++))
210     do
211         sim_put_policy_type 201 $RIC_SIM_PREFIX"_g3_"$i STD_QOS_0_2_0 demo-testdata/STD2/sim_qos.json
212         sim_put_policy_type 201 $RIC_SIM_PREFIX"_g3_"$i STD_QOS2_0.1.0 demo-testdata/STD2/sim_qos2.json
213     done
214
215     #Check the number of schemas and the individual schemas in STD
216     a1pms_equal json:policy-types 5 120
217
218     for ((i=1; i<=$STD_NUM_RICS; i++))
219     do
220         a1pms_equal json:policy-types?ric_id=$RIC_SIM_PREFIX"_g3_"$i 2 120
221     done
222
223     # Check the schemas in STD
224     for ((i=1; i<=$STD_NUM_RICS; i++))
225     do
226         a1pms_api_get_policy_type 200 STD_QOS_0_2_0 demo-testdata/STD2/qos-a1pms-modified.json
227         a1pms_api_get_policy_type 200 'STD_QOS2_0.1.0' demo-testdata/STD2/qos2-a1pms-modified.json
228     done
229
230     #Check the number of types
231     a1pms_equal json:policy-types 5 120
232
233     #################################################################
234     ##  REQ: A1 Policy Type / Instance Operations
235     #################################################################
236
237     # Create policies
238     use_a1pms_rest_http
239
240     a1pms_api_put_service 201 "Emergency-response-app" 0 "$CR_SERVICE_APP_PATH_0/1"
241
242     # Create policies in OSC
243     for ((i=1; i<=$OSC_NUM_RICS; i++))
244     do
245         a1pms_api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 100 $((3000+$i)) NOTRANSIENT $notificationurl demo-testdata/OSC/piqos_template.json 1
246         a1pms_api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g1_"$i 20008 $((4000+$i)) NOTRANSIENT $notificationurl demo-testdata/OSC/pitsa_template.json 1
247     done
248
249
250     # Check the number of policies in OSC
251     for ((i=1; i<=$OSC_NUM_RICS; i++))
252     do
253         sim_equal $RIC_SIM_PREFIX"_g1_"$i num_instances 2
254     done
255
256
257     # Create policies in STD
258     for ((i=1; i<=$STD_NUM_RICS; i++))
259     do
260         a1pms_api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g2_"$i NOTYPE $((2100+$i)) NOTRANSIENT $notificationurl demo-testdata/STD/pi1_template.json 1
261         a1pms_api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g3_"$i STD_QOS_0_2_0 $((2300+$i)) NOTRANSIENT $notificationurl demo-testdata/STD2/pi1_template.json 1
262         a1pms_api_put_policy 201 "Emergency-response-app" $RIC_SIM_PREFIX"_g3_"$i 'STD_QOS2_0.1.0' $((2400+$i)) NOTRANSIENT $notificationurl demo-testdata/STD2/pi1_template.json 1
263     done
264
265
266     # Check the number of policies in STD
267     for ((i=1; i<=$STD_NUM_RICS; i++))
268     do
269         sim_equal $RIC_SIM_PREFIX"_g2_"$i num_instances 1
270         sim_equal $RIC_SIM_PREFIX"_g3_"$i num_instances 2
271     done
272
273     #################################################################
274     ##  REQ: A1 Policy Instance Status Operations
275     #################################################################
276
277     # Check status STD
278     for ((i=1; i<=$STD_NUM_RICS; i++))
279     do
280         a1pms_api_get_policy_status 200 $((2100+$i)) STD "UNDEFINED"
281         a1pms_api_get_policy_status 200 $((2300+$i)) STD2 EMPTY EMPTY
282         a1pms_api_get_policy_status 200 $((2400+$i)) STD2 EMPTY EMPTY
283     done
284
285     # Check status OSC
286     VAL='NOT IN EFFECT'
287     for ((i=1; i<=$OSC_NUM_RICS; i++))
288     do
289         a1pms_api_get_policy_status 200 $((3000+$i)) OSC "$VAL" "false"
290         a1pms_api_get_policy_status 200 $((4000+$i)) OSC "$VAL" "false"
291     done
292
293     # Note: Status callback is not tested since this callback (http POST) is made from the
294     # ricsim directly to the receiver of the status, i.e. the status does NOT
295     # pass through A1PMS
296
297     check_a1pms_logs
298
299     if [[ $interface = *"SDNC"* ]]; then
300         check_sdnc_logs
301     fi
302
303     #### TEST COMPLETE ####
304
305     store_logs          "https__${interface}"
306
307 done
308
309 print_result
310
311 auto_clean_environment