Merge "Update Release Notes for Bronze"
[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 exclude checking pulling images for, space separated list
24 EXCLUDED_IMAGES="SDNC_ONAP"
25
26 . ../common/testcase_common.sh  $@
27 . ../common/agent_api_functions.sh
28 . ../common/ricsimulator_api_functions.sh
29
30 #### TEST BEGIN ####
31
32 #Local vars in test script
33 ##########################
34
35 # Path to callback receiver
36 CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
37
38 generate_uuid
39
40 # Tested variants of REST/DMAAP/SDNC config
41 TESTED_VARIANTS="REST   DMAAP   REST+SDNC   DMAAP+SDNC"
42 #Test agent and simulator protocol versions (others are http only)
43 TESTED_PROTOCOLS="HTTP HTTPS"
44 for __httpx in $TESTED_PROTOCOLS ; do
45     for interface in $TESTED_VARIANTS ; do
46
47         echo "#####################################################################"
48         echo "#####################################################################"
49         echo "### Testing agent: $interface using $__httpx"
50         echo "#####################################################################"
51         echo "#####################################################################"
52
53
54         # Clean container and start all needed containers #
55         clean_containers
56
57         if [ $__httpx == "HTTPS" ]; then
58             #"Using secure ports towards simulators"
59             use_simulator_https
60         else
61             #"Using non-secure ports towards simulators"
62             use_simulator_http
63         fi
64
65         start_ric_simulators ricsim_g1 1  OSC_2.1.0
66         start_ric_simulators ricsim_g2 1  STD_1.1.3
67
68         start_mr
69
70         if [ $__httpx == "HTTPS" ]; then
71             #echo "Using secure ports between agent and MR"
72             use_mr_https
73         else
74             #"Using non-secure ports between agent and MR"
75             use_mr_http
76         fi
77
78         start_cr
79
80         if [ $interface == "SDNC" ]; then
81
82             start_sdnc
83
84             if [ $__httpx == "HTTPS" ]; then
85                 # "Using secure ports towards SDNC"
86                 use_sdnc_https
87             else
88                 #"Using non-secure ports towards SDNC"
89                 use_sdnc_http
90             fi
91         fi
92
93         start_consul_cbs
94
95         if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
96             prepare_consul_config      SDNC    ".consul_config.json"
97         else
98             prepare_consul_config      NOSDNC  ".consul_config.json"
99         fi
100
101         consul_config_app                      ".consul_config.json"
102
103         start_control_panel
104
105         if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
106             start_sdnc
107         fi
108
109         start_policy_agent
110
111         set_agent_debug
112
113         if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
114             use_agent_dmaap
115         else
116             if [ $__httpx == "HTTPS" ]; then
117                 echo "Using secure ports towards the agent"
118                 use_agent_rest_https
119             else
120                 echo "Using non-secure ports towards the agent"
121                 use_agent_rest_http
122             fi
123         fi
124
125
126         cr_equal received_callbacks 0
127         mr_equal requests_submitted 0
128
129         sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
130
131         api_equal json:rics 2 60
132
133         api_equal json:policy_schemas 2 120
134
135         api_equal json:policy_types 2
136
137         api_equal json:policies 0
138
139         api_equal json:policy_ids 0
140
141         echo "############################################"
142         echo "############## Health check ################"
143         echo "############################################"
144
145         api_get_status 200
146
147         echo "############################################"
148         echo "##### Service registry and supervision #####"
149         echo "############################################"
150
151         api_put_service 201 "serv1" 1000 "$CR_PATH/1"
152
153         api_get_service_ids 200 "serv1"
154
155         api_put_services_keepalive 200 "serv1"
156
157         echo "############################################"
158         echo "############## RIC Repository ##############"
159         echo "############################################"
160
161         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"
162
163         echo "############################################"
164         echo "########### A1 Policy Management ###########"
165         echo "############################################"
166
167         api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json
168         api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json
169
170         api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT testdata/STD/pi1_template.json
171         api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT testdata/STD/pi1_template.json
172
173         api_delete_policy 204 5000
174
175         api_delete_policy 204 5100
176
177         api_equal json:policies 0
178
179         api_equal json:policy_ids 0
180
181         cr_equal received_callbacks 0
182
183         if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
184             VAL=11 # Number of Agent API calls over DMAAP
185             mr_equal requests_fetched $VAL
186             mr_equal responses_submitted $VAL
187             mr_equal responses_fetched $VAL
188             mr_equal current_requests 0
189             mr_equal current_responses 0
190         else
191             mr_equal requests_submitted 0
192         fi
193
194         if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
195             sim_contains_str ricsim_g1_1 remote_hosts "a1-controller"
196             sim_contains_str ricsim_g2_1 remote_hosts "a1-controller"
197         else
198             sim_contains_str ricsim_g1_1 remote_hosts "policy-agent"
199             sim_contains_str ricsim_g2_1 remote_hosts "policy-agent"
200         fi
201
202         check_policy_agent_logs
203         check_control_panel_logs
204
205         store_logs          "${__httpx}__${interface}"
206
207     done
208
209 done
210
211 #### TEST COMPLETE ####
212
213
214 print_result
215
216 auto_clean_containers