Functional Test Updates for I Release
[nonrtric.git] / test / auto-test / FTC150.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="Sample tests of the SDNC A1 controller restconf API using http/https (no a1pms)"
23
24 #App names to include in the test when running docker, space separated list
25 DOCKER_INCLUDED_IMAGES="RICSIM SDNC KUBEPROXY"
26 #App names to include in the test when running kubernetes, space separated list
27 KUBE_INCLUDED_IMAGES=" RICSIM SDNC KUBEPROXY"
28 #Pre-started 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=""
35
36 #Supported test environment profiles
37 SUPPORTED_PROFILES="ONAP-KOHN ONAP-LONDON ONAP-MONTREAL  ORAN-G-RELEASE ORAN-H-RELEASE ORAN-I-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 #Test a1pms and simulator protocol versions (others are http only)
50 NB_TESTED_PROTOCOLS="HTTP HTTPS"
51 SB_TESTED_PROTOCOLS="HTTP HTTPS"
52
53 for __nb_httpx in $NB_TESTED_PROTOCOLS ; do
54     for __sb_httpx in $SB_TESTED_PROTOCOLS ; do
55
56         echo "#####################################################################"
57         echo "#####################################################################"
58         echo "### Testing SDNC using Northbound: $__nb_httpx and Southbound: $__sb_httpx"
59         echo "#####################################################################"
60         echo "#####################################################################"
61
62
63         # Clean container and start all needed containers #
64         clean_environment
65
66         start_kube_proxy
67
68         start_ric_simulators ricsim_g1 1  OSC_2.1.0
69         start_ric_simulators ricsim_g2 1  STD_1.1.3
70         start_ric_simulators ricsim_g3 1  STD_2.0.0
71
72
73         if [ $__nb_httpx == "HTTPS" ]; then
74             # "Using secure ports towards SDNC"
75             if [[ "$SDNC_FEATURE_LEVEL" == *"NO_NB_HTTPS"* ]]; then
76                 deviation "SDNC does not support NB https"
77                 use_sdnc_http
78             else
79                 use_sdnc_https
80                 fi
81         else
82             #"Using non-secure ports towards SDNC"
83             use_sdnc_http
84         fi
85
86         start_sdnc
87         controller_api_wait_for_status_ok 200 ricsim_g1_1
88
89         if [ $__sb_httpx == "HTTPS" ]; then
90             # "Using secure ports towards SDNC"
91             use_simulator_https
92         else
93             #"Using non-secure ports towards SDNC"
94             use_simulator_http
95         fi
96
97         # API tests
98
99         controller_api_get_A1_policy_type 404 OSC ricsim_g1_1 1
100
101         sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
102
103
104         controller_api_get_A1_policy_ids 200 OSC ricsim_g1_1 1
105         controller_api_get_A1_policy_ids 200 STD ricsim_g2_1
106
107         controller_api_get_A1_policy_type 200 OSC ricsim_g1_1 1
108         controller_api_get_A1_policy_type 200 OSC ricsim_g1_1 1 testdata/OSC/sim_1.json
109         controller_api_get_A1_policy_type 404 OSC ricsim_g1_1 99
110
111         RESP=202
112         if [ $FLAVOUR == "ONAP" ] && [[ "$SDNC_FEATURE_LEVEL" != *"TRANS_RESP_CODE"* ]]; then
113             deviation "SDNC does not return original response code from sim"
114             RESP=200
115         fi
116         controller_api_put_A1_policy $RESP OSC ricsim_g1_1 1 4000 testdata/OSC/pi1_template.json
117         controller_api_put_A1_policy 404 OSC ricsim_g1_1 5 1001 testdata/OSC/pi1_template.json
118
119         RESP=201
120         if [ $FLAVOUR == "ONAP" ] && [[ "$SDNC_FEATURE_LEVEL" != *"TRANS_RESP_CODE"* ]]; then
121             deviation "SDNC does not return original response code from sim"
122             RESP=200
123         fi
124         controller_api_put_A1_policy $RESP STD ricsim_g2_1   5000 testdata/STD/pi1_template.json
125
126         controller_api_get_A1_policy_ids 200 OSC ricsim_g1_1 1 4000
127         controller_api_get_A1_policy_ids 200 STD ricsim_g2_1 5000
128
129         controller_api_get_A1_policy_status 200 OSC ricsim_g1_1 1 4000
130         controller_api_get_A1_policy_status 200 STD ricsim_g2_1 5000
131
132         VAL='NOT_ENFORCED'
133         controller_api_get_A1_policy_status 200 OSC ricsim_g1_1 1 4000 "$VAL" "OTHER_REASON"
134         controller_api_get_A1_policy_status 200 STD ricsim_g2_1 5000 "UNDEFINED"
135
136         RESP=202
137         if [ $FLAVOUR == "ONAP" ] && [[ "$SDNC_FEATURE_LEVEL" != *"TRANS_RESP_CODE"* ]]; then
138             deviation "SDNC does not return original response code from sim"
139             RESP=200
140         fi
141         controller_api_delete_A1_policy $RESP OSC ricsim_g1_1 1 4000
142
143         RESP=204
144         if [ $FLAVOUR == "ONAP" ] && [[ "$SDNC_FEATURE_LEVEL" != *"TRANS_RESP_CODE"* ]]; then
145             deviation "SDNC does not return original response code from sim"
146             RESP=200
147         fi
148         controller_api_delete_A1_policy $RESP STD ricsim_g2_1 5000
149
150         check_sdnc_logs
151
152         store_logs          "NB_"$__nb_httpx"_SB_"$__sb_httpx
153
154     done
155
156 done
157
158 #### TEST COMPLETE ####
159
160 print_result
161
162 auto_clean_environment