Adapted test scripts to changes in PMS 2.0
[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-MASTER ONAP-GUILIN"
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             api_equal json:rics 3 60
124
125             api_equal json:policy-types 2 120
126
127             api_equal json:policies 0
128
129             api_equal json:policy-instances 0
130
131             cr_equal received_callbacks 3 120
132
133             cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1
134
135         else
136             api_equal json:rics 2 60
137
138             api_equal json:policy_schemas 2 120
139
140             api_equal json:policy_types 2
141
142             api_equal json:policies 0
143
144             api_equal json:policy_ids 0
145         fi
146
147         echo "############################################"
148         echo "############## Health check ################"
149         echo "############################################"
150
151         api_get_status 200
152
153         echo "############################################"
154         echo "##### Service registry and supervision #####"
155         echo "############################################"
156
157         api_put_service 201 "serv1" 1000 "$CR_PATH/1"
158
159         api_get_service_ids 200 "serv1" "ric-registration"
160
161         api_put_services_keepalive 200 "serv1"
162
163         echo "############################################"
164         echo "############## RIC Repository ##############"
165         echo "############################################"
166
167         if [ "$PMS_VERSION" == "V2" ]; then
168             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:NOTYPE:AVAILABLE"
169         else
170             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"
171         fi
172
173         echo "############################################"
174         echo "########### A1 Policy Management ###########"
175         echo "############################################"
176
177         if [ "$PMS_VERSION" == "V2" ]; then
178             notificationurl=$CR_PATH"/test"
179         else
180             notificationurl=""
181         fi
182         api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
183         api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
184
185         api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
186         api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
187
188         api_delete_policy 204 5000
189
190         api_delete_policy 204 5100
191
192         if [ "$PMS_VERSION" == "V2" ]; then
193             api_equal json:policies 0
194
195             api_equal json:policy-instances 0
196         else
197             api_equal json:policies 0
198
199             api_equal json:policy_ids 0
200         fi
201
202         if [ "$PMS_VERSION" == "V2" ]; then
203             cr_equal received_callbacks 3
204         fi
205
206         if [[ $interface = *"DMAAP"* ]]; then
207             VAL=11 # Number of Agent API calls over DMAAP
208             mr_equal requests_fetched $VAL
209             mr_equal responses_submitted $VAL
210             mr_equal responses_fetched $VAL
211             mr_equal current_requests 0
212             mr_equal current_responses 0
213         else
214             mr_equal requests_submitted 0
215         fi
216
217         if [[ $interface = *"SDNC"* ]]; then
218             sim_contains_str ricsim_g1_1 remote_hosts "a1-controller"
219             sim_contains_str ricsim_g2_1 remote_hosts "a1-controller"
220             if [ "$PMS_VERSION" == "V2" ]; then
221                 sim_contains_str ricsim_g3_1 remote_hosts "a1-controller"
222             fi
223         else
224             sim_contains_str ricsim_g1_1 remote_hosts "policy-agent"
225             sim_contains_str ricsim_g2_1 remote_hosts "policy-agent"
226             if [ "$PMS_VERSION" == "V2" ]; then
227                 sim_contains_str ricsim_g3_1 remote_hosts "policy-agent"
228             fi
229         fi
230
231         check_policy_agent_logs
232         check_control_panel_logs
233
234         if [[ $interface = *"SDNC"* ]]; then
235             check_sdnc_logs
236         fi
237
238         store_logs          "${__httpx}__${interface}"
239
240     done
241
242 done
243
244 #### TEST COMPLETE ####
245
246
247 print_result
248
249 auto_clean_containers