e34d8aaa5459a3a3b16dcf6756ced6ae417ac81c
[nonrtric.git] / test / auto-test / FTC1_RICMEDIATOR.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 A1PMS REST with/without SDNC controller"
22
23 #App names to include in the test when running docker, space separated list
24 DOCKER_INCLUDED_IMAGES="CP CR A1PMS RICSIM RICMEDIATORSIM SDNC NGW KUBEPROXY"
25
26 #App names to include in the test when running kubernetes, space separated list
27 KUBE_INCLUDED_IMAGES="CP CR A1PMS RICSIM RICMEDIATORSIM SDNC NGW KUBEPROXY "
28 #Prestarted app (not started by script) to include in the test when running kubernetes, space separated list
29 KUBE_PRESTARTED_IMAGES=""
30
31 #Ignore image in DOCKER_INCLUDED_IMAGES, KUBE_INCLUDED_IMAGES if
32 #the image is not configured in the supplied env_file
33 #Used for images not applicable to all supported profile
34 CONDITIONALLY_IGNORED_IMAGES="NGW "
35
36 #Supported test environment profiles
37 SUPPORTED_PROFILES="ORAN-H-RELEASE"
38 #Supported run modes
39 SUPPORTED_RUNMODES="DOCKER KUBE"
40
41 . ../common/testcase_common.sh $@
42
43 setup_testenvironment
44
45 #### TEST BEGIN ####
46
47 sim_generate_policy_uuid
48
49 # Tested variants of REST/DMAAP/SDNC config
50 TESTED_VARIANTS="REST REST+SDNC"
51
52 #Test a1pms and simulator protocol versions (others are http only)
53 TESTED_PROTOCOLS="HTTP HTTPS"
54 for __httpx in $TESTED_PROTOCOLS ; do
55     for interface in $TESTED_VARIANTS ; do
56
57         echo "#####################################################################"
58         echo "#####################################################################"
59         echo "### Testing a1pms: $interface using $__httpx"
60         echo "#####################################################################"
61         echo "#####################################################################"
62
63         clean_environment
64
65         start_kube_proxy
66
67         if [ $__httpx == "HTTPS" ]; then
68             use_a1pms_rest_https
69             use_ricmediator_simulator_http
70         else
71             use_a1pms_rest_http
72             use_ricmediator_simulator_http
73         fi
74
75         start_a1pms NORPOXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
76
77         set_a1pms_trace
78
79         # Create service to be able to receive events when rics becomes available
80         # Must use rest towards the a1pms since dmaap is not configured yet
81         a1pms_api_put_service 201 "ric-registration" 0 "$CR_SERVICE_APP_PATH_0/ric-registration"
82
83         if [ $__httpx == "HTTPS" ]; then
84             use_cr_https
85             use_simulator_https
86             use_ricmediator_simulator_http
87             if [[ $interface = *"SDNC"* ]]; then
88                 if [[ "$SDNC_FEATURE_LEVEL" == *"NO_NB_HTTPS"* ]]; then
89                     deviation "SDNC does not support NB https"
90                     use_sdnc_http
91                 else
92                     use_sdnc_https
93                 fi
94             fi
95             use_a1pms_rest_https
96         else
97             use_cr_http
98             use_simulator_http
99             use_ricmediator_simulator_http
100             if [[ $interface = *"SDNC"* ]]; then
101                 use_sdnc_http
102             fi
103             if [[ $interface = *"DMAAP"* ]]; then
104                 use_a1pms_dmaap_http
105             else
106                 use_a1pms_rest_http
107             fi
108         fi
109
110         start_ric_simulators ricsim_g1 1  OSC_2.1.0
111         start_ric_simulators ricsim_g2 1  STD_1.1.3
112         start_ric_simulators ricsim_g3 1  STD_2.0.0
113         start_ricmediator_simulators ricsim_g4 1  NONE
114
115         start_cr 1
116
117         start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
118
119         if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
120             start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
121         fi
122
123
124         if [[ $interface = *"SDNC"* ]]; then
125             start_sdnc
126             controller_api_wait_for_status_ok 200 ricsim_g1_1
127             prepare_a1pms_config      SDNC    ".a1pms_config.json"
128         else
129             prepare_a1pms_config      NOSDNC  ".a1pms_config.json"
130         fi
131
132         if [ $RUNMODE == "KUBE" ]; then
133             a1pms_load_config                       ".a1pms_config.json"
134         else
135             #Temporary switch to http/https if dmaap use. Otherwise it is not possibble to push config
136             if [ $__httpx == "HTTPS" ]; then
137                 use_a1pms_rest_https
138             else
139                 use_a1pms_rest_http
140             fi
141             a1pms_api_put_configuration 200 ".a1pms_config.json"
142             if [ $__httpx == "HTTPS" ]; then
143                 use_a1pms_rest_https
144             else
145                 use_a1pms_rest_http
146             fi
147         fi
148
149         sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
150
151         sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
152
153         ricmediatorsim_put_policy_type 201 ricsim_g4_1 1 testdata/OSC/sim_1.json
154
155         a1pms_equal json:rics 4 300
156
157         a1pms_equal json:policy-types 3 120
158
159         a1pms_equal json:policies 0
160
161         a1pms_equal json:policy-instances 0
162
163         cr_equal 0 received_callbacks 4 120
164
165         cr_api_check_all_sync_events 200 0 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1 ricsim_g4_1
166
167         echo "############################################"
168         echo "############## Health check ################"
169         echo "############################################"
170
171         sleep_wait 120 "Let A1PMS cofiguration take effect"
172
173         a1pms_api_get_status 200
174
175         echo "############################################"
176         echo "##### Service registry and supervision #####"
177         echo "############################################"
178
179         a1pms_api_put_service 201 "serv1" 1000 "$CR_SERVICE_APP_PATH_0/1"
180
181         a1pms_api_get_service_ids 200 "serv1" "ric-registration"
182
183         a1pms_api_put_services_keepalive 200 "serv1"
184
185         echo "############################################"
186         echo "############## RIC Repository ##############"
187         echo "############################################"
188
189         a1pms_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 ricsim_g3_1:me1_ricsim_g3_1,me2_ricsim_g3_1:STD_QOS_0_2_0:AVAILABLE ricsim_g4_1:me1_ricsim_g4_1,me2_ricsim_g4_1:1:AVAILABLE "
190
191         echo "############################################"
192         echo "########### A1 Policy Management ###########"
193         echo "############################################"
194
195         notificationurl=$CR_SERVICE_APP_PATH_0"/test"
196         a1pms_api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
197         a1pms_api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
198         a1pms_api_put_policy 201 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json
199         a1pms_api_put_policy 200 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json
200         a1pms_api_put_policy 201 "serv1" ricsim_g4_1 1 5300 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
201         a1pms_api_put_policy 200 "serv1" ricsim_g4_1 1 5300 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
202
203         a1pms_api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
204         a1pms_api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json
205
206         a1pms_equal json:policies 4
207
208         a1pms_api_delete_policy 204 5000
209
210         a1pms_api_delete_policy 204 5100
211
212         a1pms_api_delete_policy 204 5200
213
214         a1pms_api_delete_policy 204 5300
215
216         a1pms_equal json:policies 0
217
218         a1pms_equal json:policy-instances 0
219
220         cr_equal 0 received_callbacks 4
221
222         if [[ $interface = *"SDNC"* ]]; then
223             sim_contains_str ricsim_g2_1 remote_hosts $SDNC_APP_NAME
224             sim_contains_str ricsim_g3_1 remote_hosts $SDNC_APP_NAME
225         else
226             sim_contains_str ricsim_g2_1 remote_hosts $A1PMS_APP_NAME
227             sim_contains_str ricsim_g3_1 remote_hosts $A1PMS_APP_NAME
228         fi
229
230         check_a1pms_logs
231
232
233         if [[ $interface = *"SDNC"* ]]; then
234             check_sdnc_logs
235         fi
236
237         store_logs          "${__httpx}__${interface}"
238
239     done
240
241 done
242
243 #### TEST COMPLETE ####
244
245
246 print_result
247
248 auto_clean_environment