Updated function test env with new tests and features
[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 exclude checking pulling images for, space separated list
23 EXCLUDED_IMAGES="SDNC_ONAP"
24
25 . ../common/testcase_common.sh  $@
26 . ../common/agent_api_functions.sh
27 . ../common/ricsimulator_api_functions.sh
28
29 #### TEST BEGIN ####
30
31 #Local vars in test script
32 ##########################
33 # Path to callback receiver
34 CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
35 # Number of RICs per interface type (OSC and STD)
36 NUM_RICS=30
37 # Number of policy instances per RIC
38 NUM_INSTANCES=5
39
40 DAYS=3
41
42 clean_containers
43
44 # use http or https for all apis
45 HTTPX=https
46
47 if [ $HTTPX == "http" ]; then
48    use_agent_rest_http
49    use_sdnc_http
50    use_simulator_http
51 else
52    use_agent_rest_https
53    use_sdnc_https
54    use_simulator_https
55 fi
56
57 start_ric_simulators ricsim_g1 $NUM_RICS OSC_2.1.0
58
59 start_ric_simulators ricsim_g2 $NUM_RICS STD_1.1.3
60
61 start_mr
62
63 start_cr
64
65 start_consul_cbs
66
67 prepare_consul_config      SDNC  ".consul_config.json"
68 consul_config_app                  ".consul_config.json"
69
70 start_sdnc
71
72 start_control_panel
73
74 start_policy_agent
75
76
77 api_get_status 200
78
79 echo "Print the interface for group 1 simulators, shall be OSC"
80 for ((i=1; i<=$NUM_RICS; i++))
81 do
82    sim_print ricsim_g1_$i interface
83 done
84
85 echo "Print the interface for group 2 simulators, shall be STD"
86 for ((i=1; i<=$NUM_RICS; i++))
87 do
88    sim_print ricsim_g2_$i interface
89 done
90
91 echo "Load policy type in group 1 simulators"
92 for ((i=1; i<=$NUM_RICS; i++))
93 do
94    sim_put_policy_type 201 ricsim_g1_$i 1 testdata/OSC/sim_1.json
95 done
96
97 echo "Check the number of instances in  group 1 simulators, shall be 0"
98 for ((i=1; i<=$NUM_RICS; i++))
99 do
100    sim_equal ricsim_g1_$i num_instances 0
101 done
102
103 echo "Check the number of instances in  group 2 simulators, shall be 0"
104 for ((i=1; i<=$NUM_RICS; i++))
105 do
106    sim_equal ricsim_g2_$i num_instances 0
107 done
108
109 echo "Wait for the agent to refresh types from the simulator"
110 api_equal json:policy_types 2 120
111
112 echo "Check the number of types in the agent for each ric is 1"
113 for ((i=1; i<=$NUM_RICS; i++))
114 do
115    api_equal json:policy_types?ric=ricsim_g1_$i 1 120
116 done
117
118 echo "Register a service"
119 api_put_service 201 "serv1" 0 "$CR_PATH/1"
120
121 TEST_DURATION=$((24*3600*$DAYS))
122 TEST_START=$SECONDS
123
124 AGENT_INTERFACES="REST REST_PARALLEL DMAAP DMAAP-BATCH"
125
126 MR_MESSAGES=0
127
128 while [ $(($SECONDS-$TEST_START)) -lt $TEST_DURATION ]; do
129
130     echo ""
131     echo "#########################################################################################################"
132     echo -e $BOLD"INFO: Test executed for: "$(($SECONDS-$TEST_START)) "seconds. Target is: "$TEST_DURATION" seconds."$EBOLD
133     echo "#########################################################################################################"
134     echo ""
135
136    for interface in $AGENT_INTERFACES ; do
137
138       echo "############################################"
139       echo "## Testing using agent interface: $interface ##"
140       echo "############################################"
141
142       if [ $interface == "REST" ] || [ $interface == "REST_PARALLEL" ]; then
143          if [ $HTTPX == "http" ]; then
144             use_agent_rest_http
145          else
146             use_agent_rest_https
147          fi
148       else
149          use_agent_dmaap
150       fi
151
152       echo "Create $NUM_INSTANCES instances in each OSC RIC"
153       INSTANCE_ID=200000
154       INSTANCES=0
155       if [ $interface == "REST_PARALLEL" ]; then
156          api_put_policy_parallel 201 "serv1" ricsim_g1_ $NUM_RICS 1 $INSTANCE_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_INSTANCES 3
157       fi
158       for ((i=1; i<=$NUM_RICS; i++))
159       do
160          if [ $interface == "DMAAP-BATCH" ]; then
161             api_put_policy_batch 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_INSTANCES
162          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
163             api_put_policy 201 "serv1" ricsim_g1_$i 1 $INSTANCE_ID NOTRANSIENT testdata/OSC/pi1_template.json $NUM_INSTANCES
164          fi
165          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
166             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
167          fi
168          sim_equal ricsim_g1_$i num_instances $NUM_INSTANCES
169          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
170          INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
171       done
172
173       api_equal json:policy_ids $INSTANCES
174
175       echo "Create $NUM_INSTANCES instances in each STD RIC"
176       if [ $interface == "REST_PARALLEL" ]; then
177          api_put_policy_parallel 201 "serv1" ricsim_g2_ $NUM_RICS NOTYPE $INSTANCE_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_INSTANCES 3
178       fi
179       for ((i=1; i<=$NUM_RICS; i++))
180       do
181          if [ $interface == "DMAAP-BATCH" ]; then
182             api_put_policy_batch 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_INSTANCES
183          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
184             api_put_policy 201 "serv1" ricsim_g2_$i NOTYPE $INSTANCE_ID NOTRANSIENT testdata/STD/pi1_template.json $NUM_INSTANCES
185          fi
186          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
187             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
188          fi
189          sim_equal ricsim_g2_$i num_instances $NUM_INSTANCES
190          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
191          INSTANCES=$(($INSTANCES+$NUM_INSTANCES))
192       done
193
194       api_equal json:policy_ids $INSTANCES
195
196
197       echo "Delete all instances in each OSC RIC"
198
199       INSTANCE_ID=200000
200       if [ $interface == "REST_PARALLEL" ]; then
201          api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
202       fi
203       for ((i=1; i<=$NUM_RICS; i++))
204       do
205          if [ $interface == "DMAAP-BATCH" ]; then
206             api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
207          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
208             api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
209          fi
210          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
211             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
212          fi
213          INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
214          sim_equal ricsim_g1_$i num_instances 0
215          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
216       done
217
218       api_equal json:policy_ids $INSTANCES
219
220       echo "Delete all instances in each STD RIC"
221
222       if [ $interface == "REST_PARALLEL" ]; then
223          api_delete_policy_parallel 204 $NUM_RICS $INSTANCE_ID $NUM_INSTANCES 3
224       fi
225       for ((i=1; i<=$NUM_RICS; i++))
226       do
227          if [ $interface == "DMAAP-BATCH" ]; then
228             api_delete_policy_batch 204 $INSTANCE_ID $NUM_INSTANCES
229          elif [ $interface == "DMAAP" ] || [ $interface == "REST" ]; then
230             api_delete_policy 204 $INSTANCE_ID $NUM_INSTANCES
231          fi
232          if [ $interface == "DMAAP" ] || [ $interface == "DMAAP-BATCH" ]; then
233             MR_MESSAGES=$(($MR_MESSAGES+$NUM_INSTANCES))
234          fi
235          INSTANCES=$(($INSTANCES-$NUM_INSTANCES))
236          sim_equal ricsim_g2_$i num_instances 0
237          INSTANCE_ID=$(($INSTANCE_ID+$NUM_INSTANCES))
238       done
239
240       api_equal json:policy_ids 0
241
242       cr_equal received_callbacks 0
243
244       mr_equal requests_submitted $MR_MESSAGES
245       mr_equal requests_fetched $MR_MESSAGES
246       mr_equal responses_submitted $MR_MESSAGES
247       mr_equal responses_fetched $MR_MESSAGES
248       mr_equal current_requests 0
249       mr_equal current_responses 0
250
251
252       for ((i=1; i<=$NUM_RICS; i++))
253       do
254          sim_contains_str ricsim_g1_$i remote_hosts "a1-controller"
255          sim_contains_str ricsim_g2_$i remote_hosts "a1-controller"
256       done
257
258    done
259
260 done
261
262 check_policy_agent_logs
263
264 #### TEST COMPLETE ####
265
266 store_logs          END
267
268 print_result
269
270 auto_clean_containers