Merge "Add code formatting to rAPP Catalogue"
[nonrtric.git] / test / auto-test / FTC1.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
21 TC_ONELINE_DESCR="Sanity test, create service and then create,update and delete a policy using http/https and Agent REST/DMAAP with/without SDNC controller"
22
23 #App names to include in the test, space separated list
24 INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
25
26 #SUPPORTED TEST ENV FILE
27 SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU  ORAN-CHERRY ORAN-DAWN"
28
29 . ../common/testcase_common.sh  $@
30 . ../common/agent_api_functions.sh
31 . ../common/ricsimulator_api_functions.sh
32 . ../common/cr_api_functions.sh
33
34 #### TEST BEGIN ####
35
36
37 generate_uuid
38
39 # Tested variants of REST/DMAAP/SDNC config
40 TESTED_VARIANTS="REST   DMAAP   REST+SDNC   DMAAP+SDNC"
41 #Test agent and simulator protocol versions (others are http only)
42 TESTED_PROTOCOLS="HTTP HTTPS"
43 for __httpx in $TESTED_PROTOCOLS ; do
44     for interface in $TESTED_VARIANTS ; do
45
46         echo "#####################################################################"
47         echo "#####################################################################"
48         echo "### Testing agent: $interface using $__httpx"
49         echo "#####################################################################"
50         echo "#####################################################################"
51
52         # Clean container and start all needed containers #
53         clean_containers
54
55         if [ $__httpx == "HTTPS" ]; then
56             use_agent_rest_https
57         else
58             use_agent_rest_http
59         fi
60
61         start_policy_agent
62
63         set_agent_trace
64
65         # Create service to be able to receive events when rics becomes available
66         # Must use rest towards the agent since dmaap is not configured yet
67         api_put_service 201 "ric-registration" 0 "$CR_PATH/ric-registration"
68
69         if [ $__httpx == "HTTPS" ]; then
70             use_cr_https
71             use_simulator_https
72             use_mr_https
73             if [[ $interface = *"SDNC"* ]]; then
74                 use_sdnc_https
75             fi
76             if [[ $interface = *"DMAAP"* ]]; then
77                 use_agent_dmaap_https
78             else
79                 use_agent_rest_https
80             fi
81         else
82             use_cr_http
83             use_simulator_http
84             use_mr_http
85             if [[ $interface = *"SDNC"* ]]; then
86                 use_sdnc_http
87             fi
88             if [[ $interface = *"DMAAP"* ]]; then
89                 use_agent_dmaap_http
90             else
91                 use_agent_rest_http
92             fi
93         fi
94
95         start_ric_simulators ricsim_g1 1  OSC_2.1.0
96         start_ric_simulators ricsim_g2 1  STD_1.1.3
97         if [ "$PMS_VERSION" == "V2" ]; then
98             start_ric_simulators ricsim_g3 1  STD_2.0.0
99         fi
100
101         start_mr
102
103         start_cr
104
105         start_control_panel
106
107         start_consul_cbs
108
109         if [[ $interface = *"SDNC"* ]]; then
110             start_sdnc
111             prepare_consul_config      SDNC    ".consul_config.json"
112         else
113             prepare_consul_config      NOSDNC  ".consul_config.json"
114         fi
115
116         consul_config_app                      ".consul_config.json"
117
118         mr_equal requests_submitted 0
119
120         sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
121
122         if [ "$PMS_VERSION" == "V2" ]; then
123
124             sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
125
126             api_equal json:rics 3 60
127
128             api_equal json:policy-types 3 120
129
130             api_equal json:policies 0
131
132             api_equal json:policy-instances 0
133
134             cr_equal received_callbacks 3 120
135
136             cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1
137
138         else
139             api_equal json:rics 2 60
140
141             api_equal json:policy_schemas 2 120
142
143             api_equal json:policy_types 2
144
145             api_equal json:policies 0
146
147             api_equal json:policy_ids 0
148         fi
149
150         echo "############################################"
151         echo "############## Health check ################"
152         echo "############################################"
153
154         api_get_status 200
155
156         echo "############################################"
157         echo "##### Service registry and supervision #####"
158         echo "############################################"
159
160         api_put_service 201 "serv1" 1000 "$CR_PATH/1"
161
162         api_get_service_ids 200 "serv1" "ric-registration"
163
164         api_put_services_keepalive 200 "serv1"
165
166         echo "############################################"
167         echo "############## RIC Repository ##############"
168         echo "############################################"
169
170         if [ "$PMS_VERSION" == "V2" ]; then
171             api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:AVAILABLE  ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE ricsim_g3_1:me1_ricsim_g3_1,me2_ricsim_g3_1:STD_QOS_0_2_0:AVAILABLE"
172         else
173             api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:AVAILABLE  ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE"
174         fi
175
176         echo "############################################"
177         echo "########### A1 Policy Management ###########"
178         echo "############################################"
179
180         if [ "$PMS_VERSION" == "V2" ]; then
181             notificationurl=$CR_PATH"/test"
182         else
183             notificationurl=""
184         fi
185         api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
186         api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
187         if [ "$PMS_VERSION" == "V2" ]; then
188             api_put_policy 201 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json
189             api_put_policy 200 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json
190         fi
191
192         api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
193         api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
194
195         if [ "$PMS_VERSION" == "V2" ]; then
196             api_equal json:policies 3
197         else
198             api_equal json:policies 2
199         fi
200
201         api_delete_policy 204 5000
202
203         api_delete_policy 204 5100
204
205         if [ "$PMS_VERSION" == "V2" ]; then
206             api_delete_policy 204 5200
207         fi
208
209         if [ "$PMS_VERSION" == "V2" ]; then
210             api_equal json:policies 0
211
212             api_equal json:policy-instances 0
213         else
214             api_equal json:policies 0
215
216             api_equal json:policy_ids 0
217         fi
218
219         if [ "$PMS_VERSION" == "V2" ]; then
220             cr_equal received_callbacks 3
221         fi
222
223         if [[ $interface = *"DMAAP"* ]]; then
224
225             if [ "$PMS_VERSION" == "V2" ]; then
226                 VAL=14 # Number of Agent API calls over DMAAP
227             else
228                 VAL=11 # Number of Agent API calls over DMAAP
229             fi
230             mr_equal requests_fetched $VAL
231             mr_equal responses_submitted $VAL
232             mr_equal responses_fetched $VAL
233             mr_equal current_requests 0
234             mr_equal current_responses 0
235         else
236             mr_equal requests_submitted 0
237         fi
238
239         if [[ $interface = *"SDNC"* ]]; then
240             sim_contains_str ricsim_g1_1 remote_hosts "a1-controller"
241             sim_contains_str ricsim_g2_1 remote_hosts "a1-controller"
242             if [ "$PMS_VERSION" == "V2" ]; then
243                 sim_contains_str ricsim_g3_1 remote_hosts "a1-controller"
244             fi
245         else
246             sim_contains_str ricsim_g1_1 remote_hosts "policy-agent"
247             sim_contains_str ricsim_g2_1 remote_hosts "policy-agent"
248             if [ "$PMS_VERSION" == "V2" ]; then
249                 sim_contains_str ricsim_g3_1 remote_hosts "policy-agent"
250             fi
251         fi
252
253         check_policy_agent_logs
254         check_control_panel_logs
255
256         if [[ $interface = *"SDNC"* ]]; then
257             check_sdnc_logs
258         fi
259
260         store_logs          "${__httpx}__${interface}"
261
262     done
263
264 done
265
266 #### TEST COMPLETE ####
267
268
269 print_result
270
271 auto_clean_containers