Updating FTC 850 to support a1pms V3 image
[nonrtric.git] / test / auto-test / FTC850.sh
1 #!/bin/bash
2
3 #  ============LICENSE_START===============================================
4 #  Copyright (C) 2020-2023 Nordix Foundation. All rights reserved.
5 #  Copyright (C) 2023-2024 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 TC_ONELINE_DESCR="Create/delete policies in parallel over a number of rics using a number of child process"
22
23 #App names to include in the test when running docker, space separated list
24 DOCKER_INCLUDED_IMAGES="CP CR MR 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 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  ORAN-G-RELEASE ORAN-H-RELEASE ORAN-I-RELEASE"
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 # Tested variants of REST/DMAAP/SDNC config
51 TESTED_VARIANTS="REST   REST+SDNC"
52
53 #Test a1pms and simulator protocol versions (others are http only)
54 TESTED_PROTOCOLS="HTTP HTTPS"
55
56 NUM_RICS=20
57 NUM_POLICIES_PER_RIC=500
58
59 sim_generate_policy_uuid
60
61 notificationurl=$CR_SERVICE_APP_PATH_0"/test"
62
63 VERSIONS_TO_RUN=2
64
65 if [ -n "$A1PMS_V3_FLAG" ] && [ "${A1PMS_V3_FLAG,,}" == "true" ]; then
66   VERSIONS_TO_RUN=3
67 fi
68
69 for version in $(seq 2 $VERSIONS_TO_RUN); do
70   if [ "$version" == "3" ]; then
71     if [ -n "$A1PMS_V3" ] && [ -n "$A1PMS_API_PREFIX_V3" ] && [ -n "$A1PMS_ALIVE_URL_V3" ]; then
72       export A1PMS_VERSION="$A1PMS_V3"
73       export A1PMS_API_PREFIX="$A1PMS_API_PREFIX_V3"
74       export A1PMS_ALIVE_URL="$A1PMS_API_PREFIX$A1PMS_ALIVE_URL_V3"
75     else
76       echo "One/All parameters not set in env file (<A1PMS_V3>, <A1PMS_API_PREFIX_V3>, <A1PMS_ALIVE_URL_V3>)"
77       break
78     fi
79   fi
80     for __httpx in $TESTED_PROTOCOLS ; do
81         for interface in $TESTED_VARIANTS ; do
82
83             echo "#####################################################################"
84             echo "#####################################################################"
85             echo "### Testing a1pms: "$interface" and "$__httpx" with a1pms V"$version
86             echo "#####################################################################"
87             echo "#####################################################################"
88
89             if [ $__httpx == "HTTPS" ]; then
90                 use_cr_https
91                 use_simulator_https
92                 if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
93                     :
94                 else
95                     use_mr_https
96                 fi
97                 if [[ $interface = *"SDNC"* ]]; then
98                     if [[ "$SDNC_FEATURE_LEVEL" == *"NO_NB_HTTPS"* ]]; then
99                         deviation "SDNC does not support NB https"
100                         use_sdnc_http
101                     else
102                         use_sdnc_https
103                     fi
104                 fi
105                 use_a1pms_rest_https
106             else
107                 use_cr_http
108                 use_simulator_http
109                 if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
110                     :
111                 else
112                     use_mr_http
113                 fi
114                 if [[ $interface = *"SDNC"* ]]; then
115                     use_sdnc_http
116                 fi
117                 use_a1pms_rest_http
118             fi
119
120             # Clean container and start all needed containers #
121             clean_environment
122
123             start_kube_proxy
124
125             start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
126
127             start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
128
129             if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
130                 start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
131             fi
132
133             start_a1pms NORPOXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
134
135             set_a1pms_debug
136
137
138
139             if [[ $interface = *"SDNC"* ]]; then
140                 start_sdnc
141                 controller_api_wait_for_status_ok 200 ricsim_g1_1
142                 prepare_a1pms_config      SDNC  ".a1pms_config.json"
143             else
144                 prepare_a1pms_config      NOSDNC  ".a1pms_config.json"
145             fi
146
147             if [ $RUNMODE == "KUBE" ]; then
148                 a1pms_load_config                       ".a1pms_config.json"
149             else
150                 a1pms_api_put_configuration 200 ".a1pms_config.json"
151             fi
152
153             if [[ "$A1PMS_FEATURE_LEVEL" == *"NO-DMAAP"* ]]; then
154                 :
155             else
156                 start_mr #Just to prevent errors in the a1pms log...
157             fi
158
159             start_cr 1
160
161             sleep_wait 120 "Let A1PMS configuration take effect"
162
163             a1pms_api_get_status 200
164
165             for ((i=1; i<=$NUM_RICS; i++))
166             do
167                 sim_print ricsim_g1_$i interface
168             done
169
170             echo "Load policy type in group 1 simulators"
171             for ((i=1; i<=$NUM_RICS; i++))
172             do
173                 sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
174             done
175
176             if [ "$A1PMS_VERSION" == "V2" ]; then
177               a1pms_equal json:policy-types 1 300  #Wait for the a1pms to refresh types from the simulator
178             elif [ "$A1PMS_VERSION" == "V3" ]; then
179               a1pms_equal json:policytypes 20 300
180             fi
181
182             a1pms_api_put_service 201 "serv1" 600 "$CR_SERVICE_APP_PATH_0/1"
183
184             echo "Check the number of types in the a1pms for each ric is 1"
185             for ((i=1; i<=$NUM_RICS; i++))
186             do
187               if [ "$A1PMS_VERSION" == "V2" ]; then
188                 a1pms_equal json:policy-types?ric_id=ricsim_g1_$i 1 120
189               elif [ "$A1PMS_VERSION" == "V3" ]; then
190                 a1pms_equal json:policytypes?nearRtRicId=ricsim_g1_$i 1 120
191               fi
192             done
193
194             START_ID=2000
195
196             start_timer "Create $((NUM_POLICIES_PER_RIC*$NUM_RICS)) polices over $interface using $__httpx and V$version policymanagementservice"
197
198             if [ "$A1PMS_VERSION" == "V3" ]; then
199               a1pms_api_post_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $START_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_POLICIES_PER_RIC 7
200             else
201               a1pms_api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $START_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_POLICIES_PER_RIC 7
202             fi
203
204             print_timer "Create $((NUM_POLICIES_PER_RIC*$NUM_RICS)) polices over $interface using $__httpx and V$version policymanagementservice"
205
206             INSTANCES=$(($NUM_RICS*$NUM_POLICIES_PER_RIC))
207             a1pms_equal json:policies $INSTANCES
208
209             for ((i=1; i<=$NUM_RICS; i++))
210             do
211                 sim_equal ricsim_g1_$i num_instances $NUM_POLICIES_PER_RIC
212             done
213
214             if [ "$A1PMS_VERSION" == "V3" ]; then
215               allPolicyIds_file_path="./tmp/.policyIds.split.res.txt"
216               allPolicies_file_path="./tmp/.allPolicies.get.res.json"
217               res="$(__do_curl $A1PMS_SERVICE_PATH$A1PMS_API_PREFIX"/v1/policies")"
218               echo $res > "./tmp/.allPolicies.get.res.json"
219               jq -r '.[].policyId' $allPolicies_file_path > $allPolicyIds_file_path
220             fi
221
222             if [ "$A1PMS_VERSION" == "V3" ]; then
223               start_timer "Update $((NUM_POLICIES_PER_RIC*$NUM_RICS)) polices over $interface using $__httpx and V$version policymanagementservice"
224               a1pms_api_update_policy_parallel 200 "serv1" ricsim_g1_ $NUM_RICS 1 14000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_POLICIES_PER_RIC 7 $allPolicyIds_file_path
225               print_timer "Update $((NUM_POLICIES_PER_RIC*$NUM_RICS)) polices over $interface using $__httpx and V$version policymanagementservice"
226             fi
227
228             start_timer "GET $((NUM_POLICIES_PER_RIC*$NUM_RICS)) polices over $interface using $__httpx and V$version policymanagementservice"
229
230             if [ "$A1PMS_VERSION" == "V3" ]; then
231               a1pms_api_get_policy_parallel_v3 200 $NUM_RICS $allPolicyIds_file_path $START_ID $NUM_POLICIES_PER_RIC 7
232             else
233               a1pms_api_get_policy_parallel 200 $NUM_RICS $START_ID $NUM_POLICIES_PER_RIC 7
234             fi
235
236             print_timer "GET $((NUM_POLICIES_PER_RIC*$NUM_RICS)) polices over $interface using $__httpx and V$version policymanagementservice"
237
238             INSTANCES=$(($NUM_RICS*$NUM_POLICIES_PER_RIC))
239             a1pms_equal json:policies $INSTANCES
240
241             for ((i=1; i<=$NUM_RICS; i++))
242             do
243                 sim_equal ricsim_g1_$i num_instances $NUM_POLICIES_PER_RIC
244             done
245
246             start_timer "Delete $((NUM_POLICIES_PER_RIC*$NUM_RICS)) polices over $interface using $__httpx and V$version policymanagementservice"
247
248             if [ "$A1PMS_VERSION" == "V3" ]; then
249               a1pms_api_delete_policy_parallel_v3 204 $NUM_RICS $allPolicyIds_file_path $START_ID $NUM_POLICIES_PER_RIC 7
250             else
251               a1pms_api_delete_policy_parallel 204 $NUM_RICS $START_ID $NUM_POLICIES_PER_RIC 7
252             fi
253
254             print_timer "Delete $((NUM_POLICIES_PER_RIC*$NUM_RICS)) polices over $interface using $__httpx and V$version policymanagementservice"
255
256             a1pms_equal json:policies 0
257
258             for ((i=1; i<=$NUM_RICS; i++))
259             do
260                 sim_equal ricsim_g1_$i num_instances 0
261             done
262
263             for ((i=1; i<=$NUM_RICS; i++))
264             do
265                 if [ $interface == "REST+SDNC" ]; then
266                     sim_contains_str ricsim_g1_$i remote_hosts $SDNC_APP_NAME
267                 else
268                     sim_contains_str ricsim_g1_$i remote_hosts $A1PMS_APP_NAME
269                 fi
270             done
271
272             check_a1pms_logs
273             if [[ $interface = *"SDNC"* ]]; then
274                 check_sdnc_logs
275             fi
276
277             store_logs          "${__httpx}__${interface}"
278
279         done
280
281     done
282
283 done
284
285
286 #### TEST COMPLETE ####
287
288 print_result
289
290 auto_clean_environment