c4e299a43cfaf9af778ca230267a03d79bb9cbbb
[nonrtric.git] / test / auto-test / FTC1_A1PMS_ADAPTER.sh
1 #!/bin/bash
2
3 #  ============LICENSE_START===============================================
4 #  Copyright (C) 2020-2023 Nordix Foundation. All rights reserved.
5 #  Copyright (C) 2023 OpenInfra Foundation Europe. All rights reserved.
6 #  ========================================================================
7 #  Licensed under the Apache License, Version 2.0 (the "License");
8 #  you may not use this file except in compliance with the License.
9 #  You may obtain a copy of the License at
10 #
11 #       http://www.apache.org/licenses/LICENSE-2.0
12 #
13 #  Unless required by applicable law or agreed to in writing, software
14 #  distributed under the License is distributed on an "AS IS" BASIS,
15 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 #  See the License for the specific language governing permissions and
17 #  limitations under the License.
18 #  ============LICENSE_END=================================================
19 #
20
21
22 TC_ONELINE_DESCR="Sanity test, create service and then create,update and delete a policy with A1PMS adapter using http/https and A1PMS REST with/without SDNC controller"
23
24 #App names to include in the test when running docker, space separated list
25 DOCKER_INCLUDED_IMAGES="CP CR A1PMS RICSIM SDNC NGW KUBEPROXY"
26
27 #App names to include in the test when running kubernetes, space separated list
28 KUBE_INCLUDED_IMAGES="CP CR A1PMS RICSIM SDNC NGW KUBEPROXY "
29 #Pre-started app (not started by script) to include in the test when running kubernetes, space separated list
30 KUBE_PRESTARTED_IMAGES=""
31
32 #Ignore image in DOCKER_INCLUDED_IMAGES, KUBE_INCLUDED_IMAGES if
33 #the image is not configured in the supplied env_file
34 #Used for images not applicable to all supported profile
35 CONDITIONALLY_IGNORED_IMAGES="NGW "
36
37 #Supported test environment profiles
38 SUPPORTED_PROFILES="ORAN-I-RELEASE ONAP-MONTREAL"
39 #Supported run modes
40 SUPPORTED_RUNMODES="DOCKER KUBE"
41
42 . ../common/testcase_common.sh $@
43
44 setup_testenvironment
45
46 #### TEST BEGIN ####
47
48 sim_generate_policy_uuid
49
50 # Tested variants of REST/DMAAP/SDNC config
51 TESTED_VARIANTS="REST   REST+SDNC"
52
53 #Test a1pms and simulator protocol versions (others are http only)
54 TESTED_PROTOCOLS="HTTP HTTPS"
55 for __httpx in $TESTED_PROTOCOLS ; do
56     for interface in $TESTED_VARIANTS ; do
57
58         echo "#####################################################################"
59         echo "#####################################################################"
60         echo "### Testing a1pms: $interface using $__httpx"
61         echo "#####################################################################"
62         echo "#####################################################################"
63
64         clean_environment
65
66         start_kube_proxy
67
68         if [ $__httpx == "HTTPS" ]; then
69             use_a1pms_rest_https
70         else
71             use_a1pms_rest_http
72         fi
73
74         start_a1pms NORPOXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
75
76         set_a1pms_trace
77
78         # Create service to be able to receive events when rics becomes available
79         # Must use rest towards the a1pms since dmaap is not configured yet
80         a1pms_api_put_service 201 "ric-registration" 0 "$CR_SERVICE_APP_PATH_0/ric-registration"
81
82         if [ $__httpx == "HTTPS" ]; then
83             use_cr_https
84             use_simulator_https
85             if [[ $interface = *"SDNC"* ]]; then
86                 if [[ "$SDNC_FEATURE_LEVEL" == *"NO_NB_HTTPS"* ]]; then
87                     deviation "SDNC does not support NB https"
88                     use_sdnc_http
89                 else
90                     use_sdnc_https
91                 fi
92             fi
93             use_a1pms_rest_https
94         else
95             use_cr_http
96             use_simulator_http
97             if [[ $interface = *"SDNC"* ]]; then
98                 use_sdnc_http
99             fi
100             use_a1pms_rest_http
101         fi
102
103         start_ric_simulators ricsim_g1 1  STD_2.0.0
104         start_ric_simulators ricsim_g2 1  STD_2.0.0  #A1PMS will use adapter class towards this sim
105
106         start_cr 1
107
108         start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
109
110         if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
111             start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
112         fi
113
114         if [ -z "$A1PMS_ADAPTER_CLASS" ]; then
115             echo -e $RED"Env var A1PMS_ADAPTER_CLASS must be set with override file"$ERED
116             exit 1
117         fi
118         if [[ $interface = *"SDNC"* ]]; then
119             start_sdnc
120             controller_api_wait_for_status_ok 200 ricsim_g1_1
121             prepare_a1pms_config      SDNC    ".a1pms_config.json" ricsim-g2 $A1PMS_ADAPTER_CLASS
122         else
123             prepare_a1pms_config      NOSDNC  ".a1pms_config.json" ricsim-g2 $A1PMS_ADAPTER_CLASS
124         fi
125
126         if [ $RUNMODE == "KUBE" ]; then
127             a1pms_load_config                       ".a1pms_config.json"
128         else
129             #Temporary switch to http/https if dmaap use. Otherwise it is not possible to push config
130             if [ $__httpx == "HTTPS" ]; then
131                 use_a1pms_rest_https
132             else
133                 use_a1pms_rest_http
134             fi
135             a1pms_api_put_configuration 200 ".a1pms_config.json"
136             if [ $__httpx == "HTTPS" ]; then
137                 use_a1pms_rest_https
138             else
139                 use_a1pms_rest_http
140             fi
141         fi
142
143         sim_put_policy_type 201 ricsim_g1_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json
144         sim_put_policy_type 201 ricsim_g2_1 $A1PMS_ADAPTER_POLICY_NAME testdata/STD2/sim_qos.json
145
146         a1pms_equal json:rics 2 300
147
148         a1pms_equal json:policy-types 2 120
149
150         a1pms_equal json:policies 0
151
152         a1pms_equal json:policy-instances 0
153
154         cr_equal 0 received_callbacks 2 120
155
156         cr_api_check_all_sync_events 200 0 ric-registration ricsim_g1_1 ricsim_g2_1
157
158         echo "############################################"
159         echo "############## Health check ################"
160         echo "############################################"
161
162         sleep_wait 120 "Let A1PMS configuration take effect"
163
164         a1pms_api_get_status 200
165
166         echo "############################################"
167         echo "##### Service registry and supervision #####"
168         echo "############################################"
169
170         a1pms_api_put_service 201 "serv1" 1000 "$CR_SERVICE_APP_PATH_0/1"
171
172         a1pms_api_get_service_ids 200 "serv1" "ric-registration"
173
174         a1pms_api_put_services_keepalive 200 "serv1"
175
176         echo "############################################"
177         echo "############## RIC Repository ##############"
178         echo "############################################"
179
180         a1pms_api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:STD_QOS_0_2_0:AVAILABLE ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:$A1PMS_ADAPTER_POLICY_NAME:AVAILABLE"
181
182         echo "############################################"
183         echo "########### A1 Policy Management ###########"
184         echo "############################################"
185
186         notificationurl=$CR_SERVICE_APP_PATH_0"/test"
187
188         a1pms_api_put_policy 201 "serv1" ricsim_g1_1 STD_QOS_0_2_0 5000 true $notificationurl testdata/STD2/pi_qos_template.json
189         a1pms_api_put_policy 200 "serv1" ricsim_g1_1 STD_QOS_0_2_0 5000 true $notificationurl testdata/STD2/pi_qos_template.json
190
191         a1pms_api_put_policy 201 "serv1" ricsim_g2_1 $A1PMS_ADAPTER_POLICY_NAME 5100 true $notificationurl testdata/STD2/pi_qos_template.json
192         a1pms_api_put_policy 200 "serv1" ricsim_g2_1 $A1PMS_ADAPTER_POLICY_NAME 5100 true $notificationurl testdata/STD2/pi_qos_template.json
193
194         a1pms_equal json:policies 2
195
196         a1pms_api_delete_policy 204 5000
197
198         a1pms_api_delete_policy 204 5100
199
200         a1pms_equal json:policies 0
201
202         a1pms_equal json:policy-instances 0
203
204         cr_equal 0 received_callbacks 2
205
206
207         if [[ $interface = *"SDNC"* ]]; then
208             sim_contains_str ricsim_g1_1 remote_hosts $SDNC_APP_NAME
209             # Adapter does not go through SDNC
210             sim_contains_str ricsim_g2_1 remote_hosts $A1PMS_APP_NAME
211         else
212             sim_contains_str ricsim_g1_1 remote_hosts $A1PMS_APP_NAME
213             sim_contains_str ricsim_g2_1 remote_hosts $A1PMS_APP_NAME
214         fi
215
216         check_a1pms_logs
217
218
219         if [[ $interface = *"SDNC"* ]]; then
220             check_sdnc_logs
221         fi
222
223         store_logs          "${__httpx}__${interface}"
224
225     done
226
227 done
228
229 #### TEST COMPLETE ####
230
231
232 print_result
233
234 auto_clean_environment