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