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