blob: 413b22e4d9c258086f956f112887c2a9d120f4ba [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
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +020023#App names to exclude checking pulling images for, space separated list
24EXCLUDED_IMAGES="SDNC_ONAP"
25
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020026. ../common/testcase_common.sh $@
27. ../common/agent_api_functions.sh
28. ../common/ricsimulator_api_functions.sh
29
30#### TEST BEGIN ####
31
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020032
BjornMagnussonXAad047782020-06-08 15:54:11 +020033generate_uuid
34
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020035# 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
BjornMagnussonXA496156d2020-08-10 14:16:24 +020048 #Local vars in test script
49 ##########################
50
51 if [ $__httpx == "HTTPS" ]; then
52 # Path to callback receiver
53 CR_PATH="https://$CR_APP_NAME:$CR_EXTERNAL_SECURE_PORT/callbacks"
54 use_cr_https
55 else
56 # Path to callback receiver
57 CR_PATH="http://$CR_APP_NAME:$CR_EXTERNAL_PORT/callbacks"
58 use_cr_http
59 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020060
61 # Clean container and start all needed containers #
62 clean_containers
63
64 if [ $__httpx == "HTTPS" ]; then
65 #"Using secure ports towards simulators"
66 use_simulator_https
67 else
68 #"Using non-secure ports towards simulators"
69 use_simulator_http
70 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
77 if [ $__httpx == "HTTPS" ]; then
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020078 #echo "Using secure ports between agent and MR"
BjornMagnussonXA0f9d5172020-06-17 15:43:39 +020079 use_mr_https
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020080 else
81 #"Using non-secure ports between agent and MR"
82 use_mr_http
83 fi
84
85 start_cr
86
BjornMagnussonXA496156d2020-08-10 14:16:24 +020087 if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
BjornMagnussonXA70e878f2020-05-11 14:11:30 +020088
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
100 start_consul_cbs
101
102 if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
103 prepare_consul_config SDNC ".consul_config.json"
104 else
105 prepare_consul_config NOSDNC ".consul_config.json"
106 fi
107
108 consul_config_app ".consul_config.json"
109
110 start_control_panel
111
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200112 start_policy_agent
113
114 set_agent_debug
115
116 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
BjornMagnussonXA496156d2020-08-10 14:16:24 +0200117 if [ $__httpx == "HTTPS" ]; then
118 echo "Using secure ports towards dmaap"
119 use_agent_dmaap_https
120 else
121 echo "Using non-secure ports towards dmaap"
122 use_agent_dmaap_http
123 fi
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200124 else
125 if [ $__httpx == "HTTPS" ]; then
126 echo "Using secure ports towards the agent"
127 use_agent_rest_https
128 else
129 echo "Using non-secure ports towards the agent"
130 use_agent_rest_http
131 fi
132 fi
133
134
135 cr_equal received_callbacks 0
136 mr_equal requests_submitted 0
137
138 sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
139
140 api_equal json:rics 2 60
141
142 api_equal json:policy_schemas 2 120
143
144 api_equal json:policy_types 2
145
146 api_equal json:policies 0
147
148 api_equal json:policy_ids 0
149
150 echo "############################################"
151 echo "############## Health check ################"
152 echo "############################################"
153
154 api_get_status 200
155
156 echo "############################################"
157 echo "##### Service registry and supervision #####"
158 echo "############################################"
159
160 api_put_service 201 "serv1" 1000 "$CR_PATH/1"
161
162 api_get_service_ids 200 "serv1"
163
164 api_put_services_keepalive 200 "serv1"
165
166 echo "############################################"
167 echo "############## RIC Repository ##############"
168 echo "############################################"
169
170 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"
171
172 echo "############################################"
173 echo "########### A1 Policy Management ###########"
174 echo "############################################"
175
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200176 api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json
177 api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT testdata/OSC/pi1_template.json
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200178
BjornMagnussonXAbbd2e9d2020-05-27 21:24:06 +0200179 api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT testdata/STD/pi1_template.json
180 api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT testdata/STD/pi1_template.json
BjornMagnussonXA70e878f2020-05-11 14:11:30 +0200181
182 api_delete_policy 204 5000
183
184 api_delete_policy 204 5100
185
186 api_equal json:policies 0
187
188 api_equal json:policy_ids 0
189
190 cr_equal received_callbacks 0
191
192 if [ $interface == "DMAAP" ] || [ $interface == "DMAAP+SDNC" ]; then
193 VAL=11 # Number of Agent API calls over DMAAP
194 mr_equal requests_fetched $VAL
195 mr_equal responses_submitted $VAL
196 mr_equal responses_fetched $VAL
197 mr_equal current_requests 0
198 mr_equal current_responses 0
199 else
200 mr_equal requests_submitted 0
201 fi
202
203 if [ $interface == "REST+SDNC" ] || [ $interface == "DMAAP+SDNC" ]; then
204 sim_contains_str ricsim_g1_1 remote_hosts "a1-controller"
205 sim_contains_str ricsim_g2_1 remote_hosts "a1-controller"
206 else
207 sim_contains_str ricsim_g1_1 remote_hosts "policy-agent"
208 sim_contains_str ricsim_g2_1 remote_hosts "policy-agent"
209 fi
210
211 check_policy_agent_logs
212 check_control_panel_logs
213
214 store_logs "${__httpx}__${interface}"
215
216 done
217
218done
219
220#### TEST COMPLETE ####
221
222
223print_result
224
225auto_clean_containers