Added tests and improvements
[nonrtric.git] / test / auto-test / FTC2002.sh
1 #!/usr/bin/env 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 TC_ONELINE_DESCR="Testing southbound proxy for SDNC - docker only"
21
22 #App names to include in the test when running docker, space separated list
23 DOCKER_INCLUDED_IMAGES="RICSIM SDNC HTTPPROXY KUBEPROXY"
24 #App names to include in the test when running kubernetes, space separated list
25 KUBE_INCLUDED_IMAGES=""
26 #Prestarted app (not started by script) to include in the test when running kubernetes, space separated list
27 KUBE_PRESTARTED_IMAGES=" "
28
29 #Supported test environment profiles
30 SUPPORTED_PROFILES="ONAP-ISTANBUL"
31 #Supported run modes
32 SUPPORTED_RUNMODES="DOCKER"
33
34 . ../common/testcase_common.sh  $@
35 . ../common/controller_api_functions.sh
36 . ../common/ricsimulator_api_functions.sh
37 . ../common/kube_proxy_api_functions.sh
38 . ../common/http_proxy_api_functions.sh
39
40 setup_testenvironment
41
42 #### TEST BEGIN ####
43
44 generate_policy_uuid
45
46 #Test agent and simulator protocol versions (others are http only)
47 NB_TESTED_PROTOCOLS="HTTP HTTPS"
48 SB_TESTED_PROTOCOLS="HTTP HTTPS"
49
50 for __nb_httpx in $NB_TESTED_PROTOCOLS ; do
51     for __sb_httpx in $SB_TESTED_PROTOCOLS ; do
52
53         echo "#####################################################################"
54         echo "#####################################################################"
55         echo "### Testing SDNC using Northbound: $__nb_httpx and Southbound: $__sb_httpx"
56         echo "#####################################################################"
57         echo "#####################################################################"
58
59         if [ $__sb_httpx == "HTTPS" ]; then
60             deviation "Southbound https proxy is currently not supported"
61             break
62         fi
63
64
65         # Clean container and start all needed containers #
66         clean_environment
67
68         start_kube_proxy
69
70         start_http_proxy
71
72         start_ric_simulators ricsim_g1 1  OSC_2.1.0
73         start_ric_simulators ricsim_g2 1  STD_1.1.3
74         if [ "$PMS_VERSION" == "V2" ]; then
75             start_ric_simulators ricsim_g3 1  STD_2.0.0
76         fi
77
78         start_sdnc
79
80         if [ $__nb_httpx == "HTTPS" ]; then
81             # "Using secure ports towards SDNC"
82             use_sdnc_https
83         else
84             #"Using non-secure ports towards SDNC"
85             use_sdnc_http
86         fi
87
88         if [ $__sb_httpx == "HTTPS" ]; then
89             # "Using secure ports towards SDNC"
90             use_simulator_https
91             use_http_proxy_https
92         else
93             #"Using non-secure ports towards SDNC"
94             use_simulator_http
95             use_http_proxy_http
96         fi
97
98         echo -e $BOLD"Configure proxy in SDNC"$EBOLD
99         echo ""
100
101         if [ $__sb_httpx == "HTTPS" ]; then
102             echo "
103             sed  -i 's/a1Mediator.proxy.url=/a1Mediator.proxy.url=https:\/\/httpproxy:8433/g' /opt/onap/ccsdk/data/properties/a1-adapter-api-dg.properties
104             " | docker exec -i a1controller bash
105         else
106             echo "
107             sed  -i 's/a1Mediator.proxy.url=/a1Mediator.proxy.url=http:\/\/httpproxy:8080/g' /opt/onap/ccsdk/data/properties/a1-adapter-api-dg.properties
108             " | docker exec -i a1controller bash
109         fi
110
111         # Restart SDNC to use the updated config
112         stop_sdnc
113         start_stopped_sdnc
114
115         # API tests
116
117         controller_api_get_A1_policy_type 404 OSC ricsim_g1_1 1
118
119         sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json
120
121
122         controller_api_get_A1_policy_ids 200 OSC ricsim_g1_1 1
123         controller_api_get_A1_policy_ids 200 STD ricsim_g2_1
124
125         controller_api_get_A1_policy_type 200 OSC ricsim_g1_1 1
126         controller_api_get_A1_policy_type 200 OSC ricsim_g1_1 1 testdata/OSC/sim_1.json
127         controller_api_get_A1_policy_type 404 OSC ricsim_g1_1 99
128
129         controller_api_put_A1_policy 202 OSC ricsim_g1_1 1 4000 testdata/OSC/pi1_template.json
130         controller_api_put_A1_policy 404 OSC ricsim_g1_1 5 1001 testdata/OSC/pi1_template.json
131
132         controller_api_put_A1_policy 201 STD ricsim_g2_1   5000 testdata/STD/pi1_template.json
133
134         controller_api_get_A1_policy_ids 200 OSC ricsim_g1_1 1 4000
135         controller_api_get_A1_policy_ids 200 STD ricsim_g2_1 5000
136
137         controller_api_get_A1_policy_status 200 OSC ricsim_g1_1 1 4000
138         controller_api_get_A1_policy_status 200 STD ricsim_g2_1 5000
139
140         VAL='NOT IN EFFECT'
141         controller_api_get_A1_policy_status 200 OSC ricsim_g1_1 1 4000 "$VAL" "false"
142         controller_api_get_A1_policy_status 200 STD ricsim_g2_1 5000 "UNDEFINED"
143
144
145         deviation "SDNC does not return original response code from sim"
146         controller_api_delete_A1_policy 202 OSC ricsim_g1_1 1 4000
147
148         deviation "SDNC does not return original response code from sim"
149         controller_api_delete_A1_policy 204 STD ricsim_g2_1 5000
150
151         sim_contains_str ricsim_g1_1 remote_hosts httpproxy.nonrtric-docker-net
152         sim_contains_str ricsim_g2_1 remote_hosts httpproxy.nonrtric-docker-net
153
154         check_sdnc_logs
155
156         store_logs          "NB_"$__nb_httpx"_SB_"$__sb_httpx
157
158     done
159
160 done
161
162 #### TEST COMPLETE ####
163
164 print_result
165
166 auto_clean_environment