Fixing docker image pull rate issue in guilin
[integration/csit.git] / plans / ccsdk-oran / polmansuite / 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"
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"
41 #Test agent and simulator protocol versions (others are http only)
42 TESTED_PROTOCOLS="HTTP HTTPS"
43
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         #Local vars in test script
54         ##########################
55
56         if [ $__httpx == "HTTPS" ]; then
57             # Path to callback receiver
58             CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks"
59             use_cr_https
60         else
61             # Path to callback receiver
62             CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
63             use_cr_http
64         fi
65
66         # Clean container and start all needed containers #
67         clean_containers
68
69         if [ $__httpx == "HTTPS" ]; then
70             #"Using secure ports towards simulators"
71             use_simulator_https
72         else
73             #"Using non-secure ports towards simulators"
74             use_simulator_http
75         fi
76
77         start_ric_simulators ricsim_g1 1  OSC_2.1.0
78         start_ric_simulators ricsim_g2 1  STD_1.1.3
79
80         start_mr
81
82         if [ $__httpx == "HTTPS" ]; then
83             #echo "Using secure ports between agent and MR"
84             use_mr_https
85         else
86             #"Using non-secure ports between agent and MR"
87             use_mr_http
88         fi
89
90         start_cr
91
92         if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
93
94             start_sdnc
95
96             if [ $__httpx == "HTTPS" ]; then
97                 # "Using secure ports towards SDNC"
98                 use_sdnc_https
99             else
100                 #"Using non-secure ports towards SDNC"
101                 use_sdnc_http
102             fi
103         fi
104
105         start_consul_cbs
106
107         if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
108             prepare_consul_config      SDNC    ".consul_config.json"
109         else
110             prepare_consul_config      NOSDNC  ".consul_config.json"
111         fi
112
113         consul_config_app                      ".consul_config.json"
114
115         start_control_panel
116
117         start_policy_agent
118
119         set_agent_debug
120
121         if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
122             if [ $__httpx == "HTTPS" ]; then
123                 echo "Using secure ports towards dmaap"
124                 use_agent_dmaap_https
125             else
126                 echo "Using non-secure ports towards dmaap"
127                 use_agent_dmaap_http
128             fi
129         else
130             if [ $__httpx == "HTTPS" ]; then
131                 echo "Using secure ports towards the agent"
132                 use_agent_rest_https
133             else
134                 echo "Using non-secure ports towards the agent"
135                 use_agent_rest_http
136             fi
137         fi
138
139
140         cr_equal received_callbacks 0
141         mr_equal requests_submitted 0
142
143         sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
144
145         api_equal json:rics 2 60
146
147         api_equal json:policy_schemas 2 120
148
149         api_equal json:policy_types 2
150
151         api_equal json:policies 0
152
153         api_equal json:policy_ids 0
154
155         echo "############################################"
156         echo "############## Health check ################"
157         echo "############################################"
158
159         api_get_status 200
160
161         echo "############################################"
162         echo "##### Service registry and supervision #####"
163         echo "############################################"
164
165         api_put_service 201 "serv1" 1000 "$CR_PATH/1"
166
167         api_get_service_ids 200 "serv1"
168
169         api_put_services_keepalive 200 "serv1"
170
171         echo "############################################"
172         echo "############## RIC Repository ##############"
173         echo "############################################"
174
175         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"
176
177         echo "############################################"
178         echo "########### A1 Policy Management ###########"
179         echo "############################################"
180
181         api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json
182         api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json
183
184         api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT testdata/STD/pi1_template.json
185         api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT testdata/STD/pi1_template.json
186
187         api_delete_policy 204 5000
188
189         api_delete_policy 204 5100
190
191         api_equal json:policies 0
192
193         api_equal json:policy_ids 0
194
195         cr_equal received_callbacks 0
196
197         if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
198             VAL=11 # Number of Agent API calls over DMAAP
199             mr_equal requests_fetched $VAL
200             mr_equal responses_submitted $VAL
201             mr_equal responses_fetched $VAL
202             mr_equal current_requests 0
203             mr_equal current_responses 0
204         else
205             mr_equal requests_submitted 0
206         fi
207
208         if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
209             sim_contains_str ricsim_g1_1 remote_hosts "a1-controller"
210             sim_contains_str ricsim_g2_1 remote_hosts "a1-controller"
211         else
212             sim_contains_str ricsim_g1_1 remote_hosts "policy-agent"
213             sim_contains_str ricsim_g2_1 remote_hosts "policy-agent"
214         fi
215
216         check_policy_agent_logs
217         check_control_panel_logs
218
219         store_logs          "${__httpx}__${interface}"
220
221     done
222
223 done
224
225 #### TEST COMPLETE ####
226
227
228 print_result
229
230 auto_clean_containers