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