Merge "HTTPS support for rApp Catalogue"
[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 agent 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="CBS CONSUL CP CR MR PA RICSIM SDNC"
24
25 #App names to include in the test when running kubernetes, space separated list
26 KUBE_INCLUDED_IMAGES="CP CR MR PA RICSIM SDNC"
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/ricsimulator_api_functions.sh
38 . ../common/cr_api_functions.sh
39 . ../common/mr_api_functions.sh
40 . ../common/control_panel_api_functions.sh
41 . ../common/controller_api_functions.sh
42
43 #### TEST BEGIN ####
44
45 generate_uuid
46
47 #Local vars in test script
48 ##########################
49
50 # Number of RICs per interface type (OSC and STD)
51 NUM_RICS=30
52 if [ "$PMS_VERSION" == "V2" ]; then
53    NUM_RICS=20 # 3 A1 interfaces test, less sims per interface. total sims will be same
54 fi
55
56 # Number of policy instances per RIC
57 NUM_INSTANCES=5
58
59 DAYS=3
60
61 clean_environment
62
63 # use HTTP or HTTPS for all apis
64 HTTPX=HTTPS
65
66 if [ $HTTPX == "HTTP" ]; then
67    use_cr_http
68    use_agent_rest_http
69    use_sdnc_http
70    use_simulator_http
71 else
72    use_cr_https
73    use_agent_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 if [ "$PMS_VERSION" == "V2" ]; then
83    start_ric_simulators ricsim_g3 $NUM_RICS  STD_2.0.0
84 fi
85
86 start_mr
87
88 start_cr
89
90 start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/application.properties
91
92 start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/application.yaml
93
94 if [ $RUNMODE == "DOCKER" ]; then
95    start_consul_cbs
96 fi
97
98 prepare_consul_config      SDNC  ".consul_config.json"
99
100 if [ $RUNMODE == "KUBE" ]; then
101    agent_load_config                       ".consul_config.json"
102 else
103    consul_config_app                      ".consul_config.json"
104 fi
105
106 start_sdnc
107
108
109 api_get_status 200
110
111 echo "Print the interface for group 1 simulators, shall be OSC"
112 for ((i=1; i<=$NUM_RICS; i++))
113 do
114    sim_print ricsim_g1_$i interface
115 done
116
117 echo "Print the interface for group 2 simulators, shall be STD"
118 for ((i=1; i<=$NUM_RICS; i++))
119 do
120    sim_print ricsim_g2_$i interface
121 done
122
123 if [ "$PMS_VERSION" == "V2" ]; then
124    echo "Print the interface for group 2 simulators, shall be STD 2"
125    for ((i=1; i<=$NUM_RICS; i++))
126    do
127       sim_print ricsim_g3_$i interface
128    done
129 fi
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 if [ "$PMS_VERSION" == "V2" ]; then
138    echo "Load policy type in group 3 simulators"
139    for ((i=1; i<=$NUM_RICS; i++))
140    do
141       sim_put_policy_type 201 ricsim_g3_$i STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json
142    done
143 fi
144
145 echo "Check the number of instances in  group 1 simulators, shall be 0"
146 for ((i=1; i<=$NUM_RICS; i++))
147 do
148    sim_equal ricsim_g1_$i num_instances 0
149 done
150
151 echo "Check the number of instances in  group 2 simulators, shall be 0"
152 for ((i=1; i<=$NUM_RICS; i++))
153 do
154    sim_equal ricsim_g2_$i num_instances 0
155 done
156
157 if [ "$PMS_VERSION" == "V2" ]; then
158    echo "Check the number of instances in group 3 simulators, shall be 0"
159    for ((i=1; i<=$NUM_RICS; i++))
160    do
161       sim_equal ricsim_g3_$i num_instances 0
162    done
163 fi
164
165 echo "Wait for the agent to refresh types from the simulator"
166 if [ "$PMS_VERSION" == "V2" ]; then
167    api_equal json:policy-types 3 300
168 else
169    api_equal json:policy_types 2 300
170 fi
171
172 echo "Check the number of types in the agent for each ric is 1"
173 for ((i=1; i<=$NUM_RICS; i++))
174 do
175    if [ "$PMS_VERSION" == "V2" ]; then
176       api_equal json:policy-types?ric_id=ricsim_g1_$i 1 120
177       api_equal json:policy-types?ric_id=ricsim_g3_$i 1 120
178    else
179       api_equal json:policy_types?ric=ricsim_g1_$i 1 120
180    fi
181 done
182
183 echo "Register a service"
184 api_put_service 201 "serv1" 0 "$CR_SERVICE_PATH/1"
185
186 TEST_DURATION=$((24*3600*$DAYS))
187 TEST_START=$SECONDS
188
189 AGENT_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH"
190
191 MR_MESSAGES=0
192
193 if [ "$PMS_VERSION" == "V2" ]; then
194       notificationurl=$CR_SERVICE_PATH"/test"
195 else
196       notificationurl=""
197 fi
198
199 while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
200
201     echo ""
202     echo "#########################################################################################################"
203     echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD
204     echo "#########################################################################################################"
205     echo ""
206
207    for interface in $AGENT_INTERFACES ; do
208
209       echo "############################################"
210       echo "## Testing using agent interface: $interface ##"
211       echo "############################################"
212
213       if [ $interface == "REST" ] || [ $interface == "REST_PARALLEL" ]; then
214          if [ $HTTPX == "HTTP" ]; then
215             use_agent_rest_http
216          else
217             use_agent_rest_https
218          fi
219       else
220          if [ $HTTPX == "HTTPS" ]; then
221                echo "Using secure ports towards dmaap"
222                use_agent_dmaap_https
223          else
224                echo "Using non-secure ports towards dmaap"
225                use_agent_dmaap_http
226          fi
227       fi
228
229       echo "Create $NUM_INSTANCES instances in each OSC RIC"
230       INSTANCE_ID=200000
231       INSTANCES=0
232       if [ $interface == "REST_PARALLEL" ]; then
233          api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES 3
234       fi
235       for ((i=1; i<=$NUM_RICS; i++))
236       do
237          if [ $interface == "DMAAP-BATCH" ]; then
238             api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
239          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
240             api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_INSTANCES
241          fi
242          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
243             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
244          fi
245          sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
246          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
247          INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
248       done
249
250       if [ "$PMS_VERSION" == "V2" ]; then
251          api_equal json:policy-instances $INSTANCES
252       else
253          api_equal json:policy_ids $INSTANCES
254       fi
255
256       echo "Create $NUM_INSTANCES instances in each STD RIC"
257       if [ $interface == "REST_PARALLEL" ]; then
258          api_put_policy_parallel 201 "serv1" ricsim_g2_ $NUM_RICS NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES 3
259       fi
260       for ((i=1; i<=$NUM_RICS; i++))
261       do
262          if [ $interface == "DMAAP-BATCH" ]; then
263             api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
264          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
265             api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_INSTANCES
266          fi
267          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
268             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
269          fi
270          sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
271          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
272          INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
273       done
274
275       if [ "$PMS_VERSION" == "V2" ]; then
276          api_equal json:policy-instances $INSTANCES
277       else
278          api_equal json:policy_ids $INSTANCES
279       fi
280
281       if [ "$PMS_VERSION" == "V2" ]; then
282          echo "Create $NUM_INSTANCES instances in each STD 2 RIC"
283          if [ $interface == "REST_PARALLEL" ]; then
284             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
285          fi
286          for ((i=1; i<=$NUM_RICS; i++))
287          do
288             if [ $interface == "DMAAP-BATCH" ]; then
289                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
290             elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
291                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
292             fi
293             if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
294                MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
295             fi
296             sim_equal ricsim_g3_$i num_instances $NUM_INSTANCES
297             INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
298             INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
299          done
300
301          if [ "$PMS_VERSION" == "V2" ]; then
302             api_equal json:policy-instances $INSTANCES
303          else
304             api_equal json:policy_ids $INSTANCES
305          fi
306       fi
307
308
309       echo "Delete all instances in each OSC RIC"
310
311       INSTANCE_ID=200000
312       if [ $interface == "REST_PARALLEL" ]; then
313          api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
314       fi
315       for ((i=1; i<=$NUM_RICS; i++))
316       do
317          if [ $interface == "DMAAP-BATCH" ]; then
318             api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
319          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
320             api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
321          fi
322          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
323             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
324          fi
325          INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
326          sim_equal ricsim_g1_$i num_instances 0
327          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
328       done
329
330       if [ "$PMS_VERSION" == "V2" ]; then
331          api_equal json:policy-instances $INSTANCES
332       else
333          api_equal json:policy_ids $INSTANCES
334       fi
335
336       echo "Delete all instances in each STD RIC"
337
338       if [ $interface == "REST_PARALLEL" ]; then
339          api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
340       fi
341       for ((i=1; i<=$NUM_RICS; i++))
342       do
343          if [ $interface == "DMAAP-BATCH" ]; then
344             api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
345          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
346             api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
347          fi
348          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
349             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
350          fi
351          INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
352          sim_equal ricsim_g2_$i num_instances 0
353          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
354       done
355
356       if [ "$PMS_VERSION" == "V2" ]; then
357          api_equal json:policy-instances $INSTANCES
358       else
359          api_equal json:policy_ids $INSTANCES
360       fi
361
362       if [ "$PMS_VERSION" == "V2" ]; then
363          echo "Delete all instances in each STD 2 RIC"
364
365          if [ $interface == "REST_PARALLEL" ]; then
366             api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
367          fi
368          for ((i=1; i<=$NUM_RICS; i++))
369          do
370             if [ $interface == "DMAAP-BATCH" ]; then
371                api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
372             elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
373                api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
374             fi
375             if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
376                MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
377             fi
378             INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
379             sim_equal ricsim_g3_$i num_instances 0
380             INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
381          done
382
383          if [ "$PMS_VERSION" == "V2" ]; then
384             api_equal json:policy-instances $INSTANCES
385          else
386             api_equal json:policy_ids $INSTANCES
387          fi
388       fi
389
390       mr_equal requests_submitted $MR_MESSAGES
391       mr_equal requests_fetched $MR_MESSAGES
392       mr_equal responses_submitted $MR_MESSAGES
393       mr_equal responses_fetched $MR_MESSAGES
394       mr_equal current_requests 0
395       mr_equal current_responses 0
396
397
398       for ((i=1; i<=$NUM_RICS; i++))
399       do
400          sim_contains_str ricsim_g1_$i remote_hosts $SDNC_APP_NAME
401          sim_contains_str ricsim_g2_$i remote_hosts $SDNC_APP_NAME
402
403          if [ "$PMS_VERSION" == "V2" ]; then
404             sim_contains_str ricsim_g3_$i remote_hosts $SDNC_APP_NAME
405          fi
406       done
407
408    done
409
410 done
411
412 check_policy_agent_logs
413 check_sdnc_logs
414
415 #### TEST COMPLETE ####
416
417 store_logs          END
418
419 print_result
420
421 auto_clean_environment