Merge "Fix main manifest attribute in rAPP Catalogue"
[nonrtric.git] / test / auto-test / FTC300.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="Resync 10000 policies using OSC and STD interface"
21
22 #App names to include in the test, space separated list
23 INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
24
25 #SUPPORTED TEST ENV FILE
26 SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN ORAN-MASTER"
27
28 . ../common/testcase_common.sh  $@
29 . ../common/agent_api_functions.sh
30 . ../common/ricsimulator_api_functions.sh
31
32 #### TEST BEGIN ####
33
34 generate_uuid
35
36 # Tested variants of REST/DMAAP/SDNC config
37 TESTED_VARIANTS="REST   DMAAP   REST+SDNC   DMAAP+SDNC DMAAP_BATCH DMAAP_BATCH+SDNC"
38 #Test agent and simulator protocol versions (others are http only)
39 TESTED_PROTOCOLS="HTTP HTTPS"
40 for __httpx in $TESTED_PROTOCOLS ; do
41     for interface in $TESTED_VARIANTS ; do
42
43         echo "#####################################################################"
44         echo "#####################################################################"
45         echo "### Testing agent: "$interface" and "$__httpx
46         echo "#####################################################################"
47         echo "#####################################################################"
48
49         if [ $__httpx == "HTTPS" ]; then
50             use_cr_https
51             use_simulator_https
52             use_mr_https
53             if [[ $interface = *"SDNC"* ]]; then
54                 use_sdnc_https
55             fi
56             if [[ $interface = *"DMAAP"* ]]; then
57                 use_agent_dmaap_https
58             else
59                 use_agent_rest_https
60             fi
61         else
62             use_cr_http
63             use_simulator_http
64             use_mr_http
65             if [[ $interface = *"SDNC"* ]]; then
66                 use_sdnc_http
67             fi
68             if [[ $interface = *"DMAAP"* ]]; then
69                 use_agent_dmaap_http
70             else
71                 use_agent_rest_http
72             fi
73         fi
74
75         # Clean container and start all needed containers #
76         clean_containers
77
78         start_ric_simulators ricsim_g1 4 OSC_2.1.0
79
80         start_ric_simulators ricsim_g2 4 STD_1.1.3
81
82         if [ "$PMS_VERSION" == "V2" ]; then
83             start_ric_simulators ricsim_g3 4  STD_2.0.0
84         fi
85
86         start_mr
87
88         start_cr
89
90         start_consul_cbs
91
92         if [[ $interface = *"SDNC"* ]]; then
93             start_sdnc
94             prepare_consul_config      SDNC    ".consul_config.json"
95         else
96             prepare_consul_config      NOSDNC  ".consul_config.json"
97         fi
98
99         consul_config_app                  ".consul_config.json"
100
101         start_control_panel
102
103         start_policy_agent
104
105         set_agent_debug
106
107         api_get_status 200
108
109         sim_print ricsim_g1_1 interface
110
111         sim_print ricsim_g2_1 interface
112
113         if [ "$PMS_VERSION" == "V2" ]; then
114             sim_print ricsim_g3_1 interface
115         fi
116
117         sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
118
119         if [ "$PMS_VERSION" == "V2" ]; then
120             api_equal json:policy-types 2 120  #Wait for the agent to refresh types from the simulator
121         else
122             api_equal json:policy_types 2 120  #Wait for the agent to refresh types from the simulator
123         fi
124
125         api_put_service 201 "serv1" 3600 "$CR_PATH/1"
126
127         START_ID=2000
128         NUM_POLICIES=10000  # Must be at least 100
129
130         if [ "$PMS_VERSION" == "V2" ]; then
131             notificationurl=$CR_PATH"/test"
132         else
133             notificationurl=""
134         fi
135
136         if [[ $interface == *"BATCH"* ]]; then
137             api_put_policy_batch 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_POLICIES
138         else
139             api_put_policy 201 "serv1" ricsim_g1_1 1 $START_ID NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json $NUM_POLICIES
140         fi
141
142         sim_equal ricsim_g1_1 num_instances $NUM_POLICIES
143
144         sim_post_delete_instances 200 ricsim_g1_1
145
146         sim_equal ricsim_g1_1 num_instances 0
147
148         sim_equal ricsim_g1_1 num_instances $NUM_POLICIES 300
149
150         START_ID2=$(($START_ID+$NUM_POLICIES))
151
152         if [[ $interface == *"BATCH"* ]]; then
153             api_put_policy_batch 201 "serv1" ricsim_g2_1 NOTYPE $START_ID2 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_POLICIES
154         else
155             api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE $START_ID2 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json $NUM_POLICIES
156         fi
157         sim_equal ricsim_g2_1 num_instances $NUM_POLICIES
158
159         sim_post_delete_instances 200 ricsim_g2_1
160
161         sim_equal ricsim_g2_1 num_instances 0
162
163         sim_equal ricsim_g2_1 num_instances $NUM_POLICIES 300
164
165         api_delete_policy 204 $(($START_ID+47))
166
167         api_delete_policy 204 $(($START_ID+$NUM_POLICIES-39))
168
169         sim_post_delete_instances 200 ricsim_g1_1
170
171         sim_equal ricsim_g1_1 num_instances $(($NUM_POLICIES-2)) 300
172
173         api_delete_policy 204 $(($START_ID2+37))
174
175         api_delete_policy 204 $(($START_ID2+$NUM_POLICIES-93))
176
177         api_delete_policy 204 $(($START_ID2+$NUM_POLICIES-91))
178
179         sim_post_delete_instances 200 ricsim_g2_1
180
181         sim_equal ricsim_g1_1 num_instances $(($NUM_POLICIES-2)) 300
182
183         sim_equal ricsim_g2_1 num_instances $(($NUM_POLICIES-3)) 300
184
185         api_equal json:policies $(($NUM_POLICIES-2+$NUM_POLICIES-3))
186
187         check_policy_agent_logs
188         if [[ $interface = *"SDNC"* ]]; then
189             check_sdnc_logs
190         fi
191
192         store_logs          "${__httpx}__${interface}"
193
194     done
195
196 done
197
198
199 #### TEST COMPLETE ####
200
201
202 print_result
203
204 auto_clean_containers