blob: ce9aa73b38ff557003286f47d0bd043aaae892c8 [file] [log] [blame]
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +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
BjornMagnussonXAd8d05292020-10-02 10:54:51 +020023#App names to include in the test, space separated list
24INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM SDNC"
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +020025
BjornMagnussonXAa8a30622020-11-12 11:03:10 +010026#Supported test env file (profile)
27SUPPORTED_PROFILES="ONAP-MASTER ONAP-GUILIN"
28
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +020029. ../common/testcase_common.sh $@
30. ../common/agent_api_functions.sh
31. ../common/ricsimulator_api_functions.sh
BjornMagnussonXAa8a30622020-11-12 11:03:10 +010032. ../common/cr_api_functions.sh
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +020033
34#### TEST BEGIN ####
35
36
37generate_uuid
38
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +020039# Tested variants of REST/DMAAP/SDNC config
40TESTED_VARIANTS="REST DMAAP"
41#Test agent and simulator protocol versions (others are http only)
42TESTED_PROTOCOLS="HTTP HTTPS"
43
44for __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
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +020053 # Clean container and start all needed containers #
54 clean_containers
55
56 if [ $__httpx == "HTTPS" ]; then
BjornMagnussonXAa8a30622020-11-12 11:03:10 +010057 use_cr_https
58 #echo "Using secure ports between agent and MR"
59 use_mr_https
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +020060 #"Using secure ports towards simulators"
61 use_simulator_https
BjornMagnussonXAa8a30622020-11-12 11:03:10 +010062 use_agent_rest_https
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +020063 else
BjornMagnussonXAa8a30622020-11-12 11:03:10 +010064 use_cr_http
65 #"Using non-secure ports between agent and MR"
66 use_mr_http
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +020067 #"Using non-secure ports towards simulators"
68 use_simulator_http
BjornMagnussonXAa8a30622020-11-12 11:03:10 +010069 use_agent_rest_http
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +020070 fi
71
72 start_ric_simulators ricsim_g1 1 OSC_2.1.0
73 start_ric_simulators ricsim_g2 1 STD_1.1.3
74
75 start_mr
76
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +020077 start_cr
78
BjornMagnussonXAa8a30622020-11-12 11:03:10 +010079 start_policy_agent
80
81 set_agent_debug
82
83 # Create service to be able to receive events when rics becomes available
84 # Must use rest towards the agent since dmaap is not configured yet
85 api_put_service 201 "ric-registration" 0 "$CR_PATH/ric-registration"
86
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +020087 if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
88
89 start_sdnc
90
91 if [ $__httpx == "HTTPS" ]; then
92 # "Using secure ports towards SDNC"
93 use_sdnc_https
94 else
95 #"Using non-secure ports towards SDNC"
96 use_sdnc_http
97 fi
98 fi
99
BjornMagnussonXAa8a30622020-11-12 11:03:10 +0100100 cr_equal received_callbacks 0
101
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +0200102 start_consul_cbs
103
104 if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
105 prepare_consul_config SDNC ".consul_config.json"
106 else
107 prepare_consul_config NOSDNC ".consul_config.json"
108 fi
109
110 consul_config_app ".consul_config.json"
111
112 start_control_panel
113
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +0200114 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
115 if [ $__httpx == "HTTPS" ]; then
116 echo "Using secure ports towards dmaap"
117 use_agent_dmaap_https
118 else
119 echo "Using non-secure ports towards dmaap"
120 use_agent_dmaap_http
121 fi
122 else
123 if [ $__httpx == "HTTPS" ]; then
124 echo "Using secure ports towards the agent"
125 use_agent_rest_https
126 else
127 echo "Using non-secure ports towards the agent"
128 use_agent_rest_http
129 fi
130 fi
131
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +0200132 mr_equal requests_submitted 0
133
134 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
135
BjornMagnussonXAa8a30622020-11-12 11:03:10 +0100136 if [ "$PMS_VERSION" == "V2" ]; then
137 api_equal json:rics 2 60
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +0200138
BjornMagnussonXAa8a30622020-11-12 11:03:10 +0100139 api_equal json:policy-types 2 120
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +0200140
BjornMagnussonXAa8a30622020-11-12 11:03:10 +0100141 api_equal json:policies 0
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +0200142
BjornMagnussonXAa8a30622020-11-12 11:03:10 +0100143 api_equal json:policy-instances 0
144 else
145 api_equal json:rics 2 60
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +0200146
BjornMagnussonXAa8a30622020-11-12 11:03:10 +0100147 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 fi
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +0200155
156 echo "############################################"
157 echo "############## Health check ################"
158 echo "############################################"
159
160 api_get_status 200
161
162 echo "############################################"
163 echo "##### Service registry and supervision #####"
164 echo "############################################"
165
166 api_put_service 201 "serv1" 1000 "$CR_PATH/1"
167
BjornMagnussonXAa8a30622020-11-12 11:03:10 +0100168 api_get_service_ids 200 "serv1" "ric-registration"
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +0200169
170 api_put_services_keepalive 200 "serv1"
171
172 echo "############################################"
173 echo "############## RIC Repository ##############"
174 echo "############################################"
175
176 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"
177
178 echo "############################################"
179 echo "########### A1 Policy Management ###########"
180 echo "############################################"
181
BjornMagnussonXAa8a30622020-11-12 11:03:10 +0100182 if [ "$PMS_VERSION" == "V2" ]; then
183 notificationurl=$CR_PATH/2
184 else
185 notificationurl=""
186 fi
187 api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
188 api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +0200189
BjornMagnussonXAa8a30622020-11-12 11:03:10 +0100190 api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
191 api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +0200192
193 api_delete_policy 204 5000
194
195 api_delete_policy 204 5100
196
197 api_equal json:policies 0
198
BjornMagnussonXAa8a30622020-11-12 11:03:10 +0100199 if [ "$PMS_VERSION" == "V2" ]; then
200 api_equal json:policy-instances 0
201 else
202 api_equal json:policy_ids 0
203 fi
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +0200204
BjornMagnussonXAa8a30622020-11-12 11:03:10 +0100205 if [ "$PMS_VERSION" == "V2" ]; then
206 cr_equal received_callbacks?id=ric-registration 2
207
208 cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1
209 fi
BjornMagnussonXA52bcf1e2020-09-07 14:06:35 +0200210
211 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
212 VAL=11 # Number of Agent API calls over DMAAP
213 mr_equal requests_fetched $VAL
214 mr_equal responses_submitted $VAL
215 mr_equal responses_fetched $VAL
216 mr_equal current_requests 0
217 mr_equal current_responses 0
218 else
219 mr_equal requests_submitted 0
220 fi
221
222 if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
223 sim_contains_str ricsim_g1_1 remote_hosts "a1-controller"
224 sim_contains_str ricsim_g2_1 remote_hosts "a1-controller"
225 else
226 sim_contains_str ricsim_g1_1 remote_hosts "policy-agent"
227 sim_contains_str ricsim_g2_1 remote_hosts "policy-agent"
228 fi
229
230 check_policy_agent_logs
231 check_control_panel_logs
232
233 store_logs "${__httpx}__${interface}"
234
235 done
236
237done
238
239#### TEST COMPLETE ####
240
241
242print_result
243
244auto_clean_containers