Aligning FTC's for Mediator with Custom Adapter
[nonrtric.git] / test / auto-test / FTC1_MEDIATOR_ADAPTER.sh
1 #!/bin/bash
2 #  ============LICENSE_START===============================================
3 #  Copyright (C) 2024 OpenInfra Foundation Europe. All rights reserved.
4 #  ========================================================================
5 #  Licensed under the Apache License, Version 2.0 (the "License");
6 #  you may not use this file except in compliance with the License.
7 #  You may obtain a copy of the License at
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
11 #  Unless required by applicable law or agreed to in writing, software
12 #  distributed under the License is distributed on an "AS IS" BASIS,
13 #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #  See the License for the specific language governing permissions and
15 #  limitations under the License.
16 #  ============LICENSE_END=================================================
17
18 TC_ONELINE_DESCR="Sanity test, create service and then create, update and delete a policy using http and A1PMS REST and REST+SDNC"
19
20 # App names to include in the test when running docker, space separated list
21 DOCKER_INCLUDED_IMAGES="CP CR A1PMS RICSIM RICMEDIATORSIM NGW KUBEPROXY SDNC"
22
23 # App names to include in the test when running kubernetes, space separated list
24 KUBE_INCLUDED_IMAGES="CP CR A1PMS RICSIM RICMEDIATORSIM NGW KUBEPROXY SDNC"
25 # Pre-started app (not started by script) to include in the test when running kubernetes, space separated list
26 KUBE_PRESTARTED_IMAGES=""
27 # Ignore image in DOCKER_INCLUDED_IMAGES, KUBE_INCLUDED_IMAGES if the image is not configured in the supplied env_file
28 # Used for images not applicable to all supported profile
29 CONDITIONALLY_IGNORED_IMAGES="NGW "
30
31 # Supported test environment profiles
32 SUPPORTED_PROFILES="ORAN-I-RELEASE"
33 # Supported run modes
34 SUPPORTED_RUNMODES="DOCKER KUBE"
35
36 . ../common/testcase_common.sh $@
37 setup_testenvironment
38
39 #### TEST BEGIN ####
40 sim_generate_policy_uuid
41
42 # Tested variants of REST config
43 TESTED_VARIANTS="REST REST+SDNC"
44
45 # Test a1pms and mediator protocol versions
46 TESTED_PROTOCOLS="HTTP"
47
48 for __httpx in $TESTED_PROTOCOLS ; do
49     for interface in $TESTED_VARIANTS ; do
50         echo "#####################################################################"
51         echo "#####################################################################"
52         echo "### Testing a1pms: $interface using $__httpx"
53         echo "#####################################################################"
54         echo "#####################################################################"
55
56         clean_environment
57
58         start_kube_proxy
59
60         use_a1pms_rest_http
61         use_ricmediator_simulator_http
62
63         start_a1pms NORPOXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
64         set_a1pms_trace
65
66         a1pms_api_put_service 201 "ric-registration" 0 "$CR_SERVICE_APP_PATH_0/ric-registration"
67
68         use_cr_http
69         use_ricmediator_simulator_http
70         if [[ $interface = *"SDNC"* ]]; then
71             use_sdnc_http
72         fi
73         use_a1pms_rest_http
74
75         start_ricmediator_simulators ricsim_g4 1 NONE
76         start_cr 1
77         start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
78
79         if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
80             start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
81         fi
82
83         if [ -z "$A1PMS_SDNC_ADAPTER_CLASS" ] || [ -z "$A1PMS_NOSDNC_ADAPTER_CLASS" ]; then
84             echo -e $RED"Env vars A1PMS_SDNC_ADAPTER_CLASS and A1PMS_NOSDNC_ADAPTER_CLASS must be set with override file"$ERED
85             exit 1
86         fi
87
88         if [[ $interface = *"SDNC"* ]]; then
89             start_sdnc
90             prepare_a1pms_config SDNC ".a1pms_config.json" ricsim-g4 $A1PMS_SDNC_ADAPTER_CLASS
91         else
92             prepare_a1pms_config NOSDNC ".a1pms_config.json" ricsim-g4 $A1PMS_NOSDNC_ADAPTER_CLASS
93         fi
94
95         if [ $RUNMODE == "KUBE" ]; then
96             a1pms_load_config ".a1pms_config.json"
97         else
98             a1pms_api_put_configuration 200 ".a1pms_config.json"
99         fi
100
101         ricmediatorsim_put_policy_type 201 ricsim_g4_1 $A1PMS_ADAPTER_POLICY_TYPE testdata/OSC/sim_1.json
102
103         a1pms_equal json:rics 1 300
104         a1pms_equal json:policy-types 1 120
105         a1pms_equal json:policies 0
106         a1pms_equal json:policy-instances 0
107         cr_equal 0 received_callbacks 1 120
108         cr_api_check_all_sync_events 200 0 ric-registration ricsim_g4_1
109
110         echo "############################################"
111         echo "############## Health check ################"
112         echo "############################################"
113         sleep_wait 120 "Let A1PMS configuration take effect"
114         a1pms_api_get_status 200
115
116         echo "############################################"
117         echo "##### Service registry and supervision #####"
118         echo "############################################"
119         a1pms_api_put_service 201 "serv1" 1000 "$CR_SERVICE_APP_PATH_0/1"
120         a1pms_api_get_service_ids 200 "serv1" "ric-registration"
121         a1pms_api_put_services_keepalive 200 "serv1"
122
123         echo "############################################"
124         echo "############## RIC Repository ##############"
125         echo "############################################"
126         a1pms_api_get_rics 200 NOTYPE "ricsim_g4_1:me1_ricsim_g4_1,me2_ricsim_g4_1:$A1PMS_ADAPTER_POLICY_TYPE:AVAILABLE"
127
128         echo "############################################"
129         echo "########### A1 Policy Management ###########"
130         echo "############################################"
131         notificationurl=$CR_SERVICE_APP_PATH_0"/test"
132         a1pms_api_put_policy 201 "serv1" ricsim_g4_1 $A1PMS_ADAPTER_POLICY_TYPE 5300 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
133         a1pms_api_put_policy 200 "serv1" ricsim_g4_1 $A1PMS_ADAPTER_POLICY_TYPE 5300 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
134
135         a1pms_equal json:policies 1
136         a1pms_api_delete_policy 204 5300
137         a1pms_equal json:policies 0
138         a1pms_equal json:policy-instances 0
139         cr_equal 0 received_callbacks 1
140
141         check_a1pms_logs
142     done
143 done
144
145 #### TEST COMPLETE ####
146 print_result
147 auto_clean_environment