6b80bb7eeb770823cc2cbb97631ef7ee0f40ebdb
[nonrtric.git] / test / auto-test / FTC1_RICMEDIATORONLY.sh
1 #!/bin/bash
2 #  ============LICENSE_START===============================================
3 #  Copyright (C) 2023 Nordix Foundation. 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
19
20 TC_ONELINE_DESCR="Sanity test, create service and then create, update and delete a policy using http and A1PMS REST"
21
22 # App names to include in the test when running docker, space separated list
23 DOCKER_INCLUDED_IMAGES="CP CR A1PMS RICSIM RICMEDIATORSIM NGW KUBEPROXY"
24
25 # App names to include in the test when running kubernetes, space separated list
26 KUBE_INCLUDED_IMAGES="CP CR A1PMS RICSIM RICMEDIATORSIM NGW KUBEPROXY "
27 # Pre-started app (not started by script) to include in the test when running kubernetes, space separated list
28 KUBE_PRESTARTED_IMAGES=""
29 # Ignore image in DOCKER_INCLUDED_IMAGES, KUBE_INCLUDED_IMAGES if the image is not configured in the supplied env_file
30 # Used for images not applicable to all supported profile
31 CONDITIONALLY_IGNORED_IMAGES="NGW "
32
33 # Supported test environment profiles
34 SUPPORTED_PROFILES="ORAN-H-RELEASE"
35 # Supported run modes
36 SUPPORTED_RUNMODES="DOCKER KUBE"
37
38 . ../common/testcase_common.sh $@
39 setup_testenvironment
40
41 #### TEST BEGIN ####
42 sim_generate_policy_uuid
43
44 # Tested variants of REST config
45 TESTED_VARIANTS="REST"
46
47 # Test a1pms and mediator protocol versions
48 TESTED_PROTOCOLS="HTTP"
49
50 for __httpx in $TESTED_PROTOCOLS ; do
51     for interface in $TESTED_VARIANTS ; do
52         echo "#####################################################################"
53         echo "#####################################################################"
54         echo "### Testing a1pms: $interface using $__httpx"
55         echo "#####################################################################"
56         echo "#####################################################################"
57         
58         clean_environment
59         
60         start_kube_proxy
61         
62         use_a1pms_rest_http
63         use_ricmediator_simulator_http
64
65         start_a1pms NORPOXY $SIM_GROUP/$A1PMS_COMPOSE_DIR/$A1PMS_CONFIG_FILE
66         set_a1pms_trace
67
68         a1pms_api_put_service 201 "ric-registration" 0 "$CR_SERVICE_APP_PATH_0/ric-registration"
69
70         use_cr_http
71         use_ricmediator_simulator_http
72         use_a1pms_rest_http
73         
74         start_ricmediator_simulators ricsim_g4 1  NONE
75         start_cr 1
76         start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/$CONTROL_PANEL_CONFIG_FILE
77
78         if [ ! -z "$NRT_GATEWAY_APP_NAME" ]; then
79             start_gateway $SIM_GROUP/$NRT_GATEWAY_COMPOSE_DIR/$NRT_GATEWAY_CONFIG_FILE
80         fi
81
82         prepare_a1pms_config NOSDNC ".a1pms_config.json"
83
84         if [ $RUNMODE == "KUBE" ]; then
85             a1pms_load_config ".a1pms_config.json"
86         else
87             a1pms_api_put_configuration 200 ".a1pms_config.json"
88         fi
89
90         ricmediatorsim_put_policy_type 201 ricsim_g4_1 1 testdata/OSC/sim_1.json
91
92         a1pms_equal json:rics 1 300
93         a1pms_equal json:policy-types 1 120
94         a1pms_equal json:policies 0
95         a1pms_equal json:policy-instances 0
96         cr_equal 0 received_callbacks 1 120
97         cr_api_check_all_sync_events 200 0 ric-registration ricsim_g4_1
98
99         echo "############################################"
100         echo "############## Health check ################"
101         echo "############################################"
102         sleep_wait 120 "Let A1PMS configuration take effect"
103         a1pms_api_get_status 200
104
105         echo "############################################"
106         echo "##### Service registry and supervision #####"
107         echo "############################################"
108         a1pms_api_put_service 201 "serv1" 1000 "$CR_SERVICE_APP_PATH_0/1"
109         a1pms_api_get_service_ids 200 "serv1" "ric-registration"
110         a1pms_api_put_services_keepalive 200 "serv1"
111
112         echo "############################################"
113         echo "############## RIC Repository ##############"
114         echo "############################################"
115         a1pms_api_get_rics 200 NOTYPE "ricsim_g4_1:me1_ricsim_g4_1,me2_ricsim_g4_1:1:AVAILABLE"
116
117         echo "############################################"
118         echo "########### A1 Policy Management ###########"
119         echo "############################################"
120         notificationurl=$CR_SERVICE_APP_PATH_0"/test"
121         a1pms_api_put_policy 201 "serv1" ricsim_g4_1 1 5300 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
122         a1pms_api_put_policy 200 "serv1" ricsim_g4_1 1 5300 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json
123
124         a1pms_equal json:policies 1
125         a1pms_api_delete_policy 204 5300
126         a1pms_equal json:policies 0
127         a1pms_equal json:policy-instances 0
128         cr_equal 0 received_callbacks 1
129         
130         check_a1pms_logs
131     done
132 done
133
134 #### TEST COMPLETE ####
135 print_result
136 auto_clean_environment