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