5ce79c01485c6de77a14474c8e63a0d0cb721b4d
[nonrtric.git] / test / auto-test / FTC810.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="Repeatedly create and delete policies in each RICs for 24h (or configured number of days). Via a1pms REST/DMAAP/DMAAP_BATCH and SDNC using http or https"
21
22 #App names to include in the test when running docker, space separated list
23 DOCKER_INCLUDED_IMAGES="CP CR MR A1PMS RICSIM SDNC NGW KUBEPROXY"
24
25 #App names to include in the test when running kubernetes, space separated list
26 KUBE_INCLUDED_IMAGES="CP CR MR A1PMS RICSIM SDNC KUBEPROXY NGW"
27 #Prestarted app (not started by script) to include in the test when running kubernetes, space separated list
28 KUBE_PRESTARTED_IMAGES=""
29
30 #Ignore image in DOCKER_INCLUDED_IMAGES, KUBE_INCLUDED_IMAGES if
31 #the image is not configured in the supplied env_file
32 #Used for images not applicable to all supported profile
33 CONDITIONALLY_IGNORED_IMAGES="NGW"
34
35 #Supported test environment profiles
36 SUPPORTED_PROFILES="ONAP-JAKARTA ONAP-KOHN ONAP-LONDON  ORAN-F-RELEASE ORAN-G-RELEASE ORAN-H-RELEASE"
37 #Supported run modes
38 SUPPORTED_RUNMODES="DOCKER KUBE"
39
40 . ../common/testcase_common.sh $@
41
42 setup_testenvironment
43
44 #### TEST BEGIN ####
45
46 generate_policy_uuid
47
48 #Local vars in test script
49 ##########################
50
51 # Number of RICs per interface type (OSC and STD x 2)
52 NUM_RICS=20
53
54 # Number of policy instances per RIC
55 NUM_INSTANCES=5
56
57 DAYS=3
58
59 clean_environment
60
61 start_kube_proxy
62
63 # use HTTP or HTTPS for all apis
64 HTTPX=HTTPS
65
66 if [ $HTTPX == "HTTP" ]; then
67    use_cr_http
68    use_a1pms_rest_http
69    use_sdnc_http
70    use_simulator_http
71 else
72    use_cr_https
73    use_a1pms_rest_https
74    use_sdnc_https
75    use_simulator_https
76 fi
77
78 start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
79
80 start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3
81
82 start_ric_simulators ricsim_g3 $NUM_RICS  STD_2.0.0
83
84 start_mr
85
86 start_cr 1
87
88 start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
89
90 if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
91    start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
92 fi
93
94 A1PMS_RETRY_CODES=423
95 start_a1pms NORPOXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
96
97
98
99 prepare_a1pms_config      SDNC  ".a1pms_config.json"
100
101 if [ $RUNMODE == "KUBE" ]; then
102     a1pms_load_config                       ".a1pms_config.json"
103 else
104     a1pms_api_put_configuration 200 ".a1pms_config.json"
105 fi
106
107 start_sdnc
108
109 sleep_wait 120 "Let A1PMS cofiguration take effect"
110
111 a1pms_api_get_status 200
112
113 echo "Print the interface for group 1 simulators, shall be OSC"
114 for ((i=1; i<=$NUM_RICS; i++))
115 do
116    sim_print ricsim_g1_$i interface
117 done
118
119 echo "Print the interface for group 2 simulators, shall be STD"
120 for ((i=1; i<=$NUM_RICS; i++))
121 do
122    sim_print ricsim_g2_$i interface
123 done
124
125 echo "Print the interface for group 2 simulators, shall be STD 2"
126 for ((i=1; i<=$NUM_RICS; i++))
127 do
128    sim_print ricsim_g3_$i interface
129 done
130
131 echo "Load policy type in group 1 simulators"
132 for ((i=1; i<=$NUM_RICS; i++))
133 do
134    sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
135 done
136
137 echo "Load policy type in group 3 simulators"
138 for ((i=1; i<=$NUM_RICS; i++))
139 do
140    sim_put_policy_type 201 ricsim_g3_$i STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
141 done
142
143 echo "Check the number of instances in  group 1 simulators, shall be 0"
144 for ((i=1; i<=$NUM_RICS; i++))
145 do
146    sim_equal ricsim_g1_$i num_instances 0
147 done
148
149 echo "Check the number of instances in  group 2 simulators, shall be 0"
150 for ((i=1; i<=$NUM_RICS; i++))
151 do
152    sim_equal ricsim_g2_$i num_instances 0
153 done
154
155 echo "Check the number of instances in group 3 simulators, shall be 0"
156 for ((i=1; i<=$NUM_RICS; i++))
157 do
158    sim_equal ricsim_g3_$i num_instances 0
159 done
160
161 echo "Wait for the a1pms to refresh types from the simulator"
162 a1pms_equal json:policy-types 3 300
163
164 echo "Check the number of types in the a1pms for each ric is 1"
165 for ((i=1; i<=$NUM_RICS; i++))
166 do
167    a1pms_equal json:policy-types?ric_id=ricsim_g1_$i 1 120
168    a1pms_equal json:policy-types?ric_id=ricsim_g3_$i 1 120
169 done
170
171 echo "Register a service"
172 a1pms_api_put_service 201 "serv1" 0 "$CR_SERVICE_APP_PATH_0/1"
173
174 TEST_DURATION=$((24*3600*$DAYS))
175 TEST_START=$SECONDS
176
177 A1PMS_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH"
178
179 MR_MESSAGES=0
180
181 notificationurl=$CR_SERVICE_APP_PATH_0"/test"
182
183 while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
184
185     echo ""
186     echo "#########################################################################################################"
187     echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD
188     echo "#########################################################################################################"
189     echo ""
190
191    for interface in $A1PMS_INTERFACES ; do
192
193       echo "############################################"
194       echo "## Testing using a1pms interface: $interface ##"
195       echo "############################################"
196
197       if [ $interface == "REST" ] || [ $interface == "REST_PARALLEL" ]; then
198          if [ $HTTPX == "HTTP" ]; then
199             use_a1pms_rest_http
200          else
201             use_a1pms_rest_https
202          fi
203       else
204          if [ $HTTPX == "HTTPS" ]; then
205                echo "Using secure ports towards dmaap"
206                use_a1pms_dmaap_https
207          else
208                echo "Using non-secure ports towards dmaap"
209                use_a1pms_dmaap_http
210          fi
211       fi
212
213       echo "Create $NUM_INSTANCES instances in each OSC RIC"
214       INSTANCE_ID=200000
215       INSTANCES=0
216       if [ $interface == "REST_PARALLEL" ]; then
217          a1pms_api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES 3
218       fi
219       for ((i=1; i<=$NUM_RICS; i++))
220       do
221          if [ $interface == "DMAAP-BATCH" ]; then
222             a1pms_api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
223          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
224             a1pms_api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
225          fi
226          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
227             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
228          fi
229          sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
230          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
231          INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
232       done
233
234       a1pms_equal json:policy-instances $INSTANCES
235
236       echo "Create $NUM_INSTANCES instances in each STD RIC"
237       if [ $interface == "REST_PARALLEL" ]; then
238          a1pms_api_put_policy_parallel 201 "serv1" ricsim_g2_ $NUM_RICS NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES 3
239       fi
240       for ((i=1; i<=$NUM_RICS; i++))
241       do
242          if [ $interface == "DMAAP-BATCH" ]; then
243             a1pms_api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
244          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
245             a1pms_api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
246          fi
247          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
248             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
249          fi
250          sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
251          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
252          INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
253       done
254
255       a1pms_equal json:policy-instances $INSTANCES
256
257       echo "Create $NUM_INSTANCES instances in each STD 2 RIC"
258       if [ $interface == "REST_PARALLEL" ]; then
259          a1pms_api_put_policy_parallel 201 "serv1" ricsim_g3_ $NUM_RICS STD_QOS2_0.1.0 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json $NUM_INSTANCES 3
260       fi
261       for ((i=1; i<=$NUM_RICS; i++))
262       do
263          if [ $interface == "DMAAP-BATCH" ]; then
264             a1pms_api_put_policy_batch 201 "serv1" ricsim_g3_$i STD_QOS2_0.1.0 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json $NUM_INSTANCES
265          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
266             a1pms_api_put_policy 201 "serv1" ricsim_g3_$i STD_QOS2_0.1.0 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json $NUM_INSTANCES
267          fi
268          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
269             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
270          fi
271          sim_equal ricsim_g3_$i num_instances $NUM_INSTANCES
272          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
273          INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
274       done
275
276       a1pms_equal json:policy-instances $INSTANCES
277
278       echo "Delete all instances in each OSC RIC"
279
280       INSTANCE_ID=200000
281       if [ $interface == "REST_PARALLEL" ]; then
282          a1pms_api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
283       fi
284       for ((i=1; i<=$NUM_RICS; i++))
285       do
286          if [ $interface == "DMAAP-BATCH" ]; then
287             a1pms_api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
288          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
289             a1pms_api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
290          fi
291          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
292             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
293          fi
294          INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
295          sim_equal ricsim_g1_$i num_instances 0
296          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
297       done
298
299       a1pms_equal json:policy-instances $INSTANCES
300
301       echo "Delete all instances in each STD RIC"
302
303       if [ $interface == "REST_PARALLEL" ]; then
304          a1pms_api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
305       fi
306       for ((i=1; i<=$NUM_RICS; i++))
307       do
308          if [ $interface == "DMAAP-BATCH" ]; then
309             a1pms_api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
310          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
311             a1pms_api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
312          fi
313          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
314             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
315          fi
316          INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
317          sim_equal ricsim_g2_$i num_instances 0
318          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
319       done
320
321       a1pms_equal json:policy-instances $INSTANCES
322
323       echo "Delete all instances in each STD 2 RIC"
324
325       if [ $interface == "REST_PARALLEL" ]; then
326          a1pms_api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
327       fi
328       for ((i=1; i<=$NUM_RICS; i++))
329       do
330          if [ $interface == "DMAAP-BATCH" ]; then
331             a1pms_api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
332          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
333             a1pms_api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
334          fi
335          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
336             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
337          fi
338          INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
339          sim_equal ricsim_g3_$i num_instances 0
340          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
341       done
342
343       a1pms_equal json:policy-instances $INSTANCES
344
345       mr_equal requests_submitted $MR_MESSAGES
346       mr_equal requests_fetched $MR_MESSAGES
347       mr_equal responses_submitted $MR_MESSAGES
348       mr_equal responses_fetched $MR_MESSAGES
349       mr_equal current_requests 0
350       mr_equal current_responses 0
351
352
353       for ((i=1; i<=$NUM_RICS; i++))
354       do
355          sim_contains_str ricsim_g1_$i remote_hosts $SDNC_APP_NAME
356          sim_contains_str ricsim_g2_$i remote_hosts $SDNC_APP_NAME
357
358          sim_contains_str ricsim_g3_$i remote_hosts $SDNC_APP_NAME
359       done
360
361    done
362
363 done
364
365 check_a1pms_logs
366 check_sdnc_logs
367
368 #### TEST COMPLETE ####
369
370 store_logs          END
371
372 print_result
373
374 auto_clean_environment