BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 1 | #!/bin/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 | |
| 21 | TC_ONELINE_DESCR="Sanity test, create service and then create,update and delete a policy using http/https and Agent REST/DMAAP with/without SDNC controller" |
| 22 | |
BjornMagnussonXA | e0b665e | 2021-01-08 22:19:18 +0100 | [diff] [blame] | 23 | #App names to include in the test when running docker, space separated list |
| 24 | DOCKER_INCLUDED_IMAGES="CBS CONSUL CP CR MR DMAAPMR PA RICSIM SDNC" |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 25 | |
BjornMagnussonXA | e0b665e | 2021-01-08 22:19:18 +0100 | [diff] [blame] | 26 | #App names to include in the test when running kubernetes, space separated list |
| 27 | KUBE_INCLUDED_IMAGES="CP CR MR PA RICSIM SDNC" |
| 28 | #Prestarted app (not started by script) to include in the test when running kubernetes, space separated list |
| 29 | KUBE_PRESTARTED_IMAGES="" |
| 30 | |
| 31 | #Supported test environment profiles |
BjornMagnussonXA | 89b64ab | 2020-12-16 09:21:01 +0100 | [diff] [blame] | 32 | SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN" |
BjornMagnussonXA | e0b665e | 2021-01-08 22:19:18 +0100 | [diff] [blame] | 33 | #Supported run modes |
| 34 | SUPPORTED_RUNMODES="DOCKER KUBE" |
BjornMagnussonXA | 49f0e5a | 2020-11-08 22:41:39 +0100 | [diff] [blame] | 35 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 36 | . ../common/testcase_common.sh $@ |
| 37 | . ../common/agent_api_functions.sh |
BjornMagnussonXA | e0b665e | 2021-01-08 22:19:18 +0100 | [diff] [blame] | 38 | . ../common/consul_cbs_functions.sh |
| 39 | . ../common/control_panel_api_functions.sh |
| 40 | . ../common/controller_api_functions.sh |
BjornMagnussonXA | 49f0e5a | 2020-11-08 22:41:39 +0100 | [diff] [blame] | 41 | . ../common/cr_api_functions.sh |
BjornMagnussonXA | e0b665e | 2021-01-08 22:19:18 +0100 | [diff] [blame] | 42 | . ../common/mr_api_functions.sh |
| 43 | . ../common/ricsimulator_api_functions.sh |
| 44 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 45 | |
| 46 | #### TEST BEGIN #### |
| 47 | |
BjornMagnussonXA | ad04778 | 2020-06-08 15:54:11 +0200 | [diff] [blame] | 48 | generate_uuid |
| 49 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 50 | # Tested variants of REST/DMAAP/SDNC config |
| 51 | TESTED_VARIANTS="REST DMAAP REST+SDNC DMAAP+SDNC" |
| 52 | #Test agent and simulator protocol versions (others are http only) |
| 53 | TESTED_PROTOCOLS="HTTP HTTPS" |
| 54 | for __httpx in $TESTED_PROTOCOLS ; do |
| 55 | for interface in $TESTED_VARIANTS ; do |
| 56 | |
| 57 | echo "#####################################################################" |
| 58 | echo "#####################################################################" |
| 59 | echo "### Testing agent: $interface using $__httpx" |
| 60 | echo "#####################################################################" |
| 61 | echo "#####################################################################" |
| 62 | |
BjornMagnussonXA | e0b665e | 2021-01-08 22:19:18 +0100 | [diff] [blame] | 63 | clean_environment |
BjornMagnussonXA | 496156d | 2020-08-10 14:16:24 +0200 | [diff] [blame] | 64 | |
| 65 | if [ $__httpx == "HTTPS" ]; then |
BjornMagnussonXA | 49f0e5a | 2020-11-08 22:41:39 +0100 | [diff] [blame] | 66 | use_agent_rest_https |
| 67 | else |
| 68 | use_agent_rest_http |
| 69 | fi |
| 70 | |
BjornMagnussonXA | e0b665e | 2021-01-08 22:19:18 +0100 | [diff] [blame] | 71 | start_policy_agent NORPOXY $SIM_GROUP/$POLICY_AGENT_COMPOSE_DIR/application.yaml |
BjornMagnussonXA | 49f0e5a | 2020-11-08 22:41:39 +0100 | [diff] [blame] | 72 | |
| 73 | set_agent_trace |
| 74 | |
| 75 | # Create service to be able to receive events when rics becomes available |
| 76 | # Must use rest towards the agent since dmaap is not configured yet |
BjornMagnussonXA | e0b665e | 2021-01-08 22:19:18 +0100 | [diff] [blame] | 77 | api_put_service 201 "ric-registration" 0 "$CR_SERVICE_PATH/ric-registration" |
BjornMagnussonXA | 49f0e5a | 2020-11-08 22:41:39 +0100 | [diff] [blame] | 78 | |
| 79 | if [ $__httpx == "HTTPS" ]; then |
BjornMagnussonXA | 496156d | 2020-08-10 14:16:24 +0200 | [diff] [blame] | 80 | use_cr_https |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 81 | use_simulator_https |
| 82 | use_mr_https |
| 83 | if [[ $interface = *"SDNC"* ]]; then |
| 84 | use_sdnc_https |
| 85 | fi |
| 86 | if [[ $interface = *"DMAAP"* ]]; then |
| 87 | use_agent_dmaap_https |
| 88 | else |
| 89 | use_agent_rest_https |
| 90 | fi |
BjornMagnussonXA | 496156d | 2020-08-10 14:16:24 +0200 | [diff] [blame] | 91 | else |
BjornMagnussonXA | 496156d | 2020-08-10 14:16:24 +0200 | [diff] [blame] | 92 | use_cr_http |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 93 | use_simulator_http |
| 94 | use_mr_http |
| 95 | if [[ $interface = *"SDNC"* ]]; then |
| 96 | use_sdnc_http |
| 97 | fi |
| 98 | if [[ $interface = *"DMAAP"* ]]; then |
| 99 | use_agent_dmaap_http |
| 100 | else |
| 101 | use_agent_rest_http |
| 102 | fi |
BjornMagnussonXA | 496156d | 2020-08-10 14:16:24 +0200 | [diff] [blame] | 103 | fi |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 104 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 105 | start_ric_simulators ricsim_g1 1 OSC_2.1.0 |
| 106 | start_ric_simulators ricsim_g2 1 STD_1.1.3 |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 107 | if [ "$PMS_VERSION" == "V2" ]; then |
| 108 | start_ric_simulators ricsim_g3 1 STD_2.0.0 |
| 109 | fi |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 110 | |
| 111 | start_mr |
| 112 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 113 | start_cr |
| 114 | |
BjornMagnussonXA | e0b665e | 2021-01-08 22:19:18 +0100 | [diff] [blame] | 115 | start_control_panel $SIM_GROUP/$CONTROL_PANEL_COMPOSE_DIR/application.properties |
BjornMagnussonXA | 49f0e5a | 2020-11-08 22:41:39 +0100 | [diff] [blame] | 116 | |
BjornMagnussonXA | e0b665e | 2021-01-08 22:19:18 +0100 | [diff] [blame] | 117 | if [ $RUNMODE == "DOCKER" ]; then |
| 118 | start_consul_cbs |
| 119 | fi |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 120 | |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 121 | if [[ $interface = *"SDNC"* ]]; then |
| 122 | start_sdnc |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 123 | prepare_consul_config SDNC ".consul_config.json" |
| 124 | else |
| 125 | prepare_consul_config NOSDNC ".consul_config.json" |
| 126 | fi |
| 127 | |
BjornMagnussonXA | e0b665e | 2021-01-08 22:19:18 +0100 | [diff] [blame] | 128 | if [ $RUNMODE == "KUBE" ]; then |
| 129 | agent_load_config ".consul_config.json" |
| 130 | else |
| 131 | consul_config_app ".consul_config.json" |
| 132 | fi |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 133 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 134 | mr_equal requests_submitted 0 |
| 135 | |
| 136 | sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json |
| 137 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 138 | if [ "$PMS_VERSION" == "V2" ]; then |
BjornMagnussonXA | 2791e08 | 2020-11-12 00:52:08 +0100 | [diff] [blame] | 139 | |
| 140 | sim_put_policy_type 201 ricsim_g3_1 STD_QOS_0_2_0 testdata/STD2/sim_qos.json |
| 141 | |
BjornMagnussonXA | e0b665e | 2021-01-08 22:19:18 +0100 | [diff] [blame] | 142 | api_equal json:rics 3 300 |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 143 | |
BjornMagnussonXA | 7b36db6 | 2020-11-23 10:57:57 +0100 | [diff] [blame] | 144 | api_equal json:policy-types 3 120 |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 145 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 146 | api_equal json:policies 0 |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 147 | |
BjornMagnussonXA | 49f0e5a | 2020-11-08 22:41:39 +0100 | [diff] [blame] | 148 | api_equal json:policy-instances 0 |
| 149 | |
| 150 | cr_equal received_callbacks 3 120 |
| 151 | |
| 152 | cr_api_check_all_sync_events 200 ric-registration ricsim_g1_1 ricsim_g2_1 ricsim_g3_1 |
| 153 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 154 | else |
BjornMagnussonXA | e0b665e | 2021-01-08 22:19:18 +0100 | [diff] [blame] | 155 | api_equal json:rics 2 300 |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 156 | |
| 157 | api_equal json:policy_schemas 2 120 |
| 158 | |
| 159 | api_equal json:policy_types 2 |
| 160 | |
| 161 | api_equal json:policies 0 |
| 162 | |
| 163 | api_equal json:policy_ids 0 |
| 164 | fi |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 165 | |
| 166 | echo "############################################" |
| 167 | echo "############## Health check ################" |
| 168 | echo "############################################" |
| 169 | |
| 170 | api_get_status 200 |
| 171 | |
| 172 | echo "############################################" |
| 173 | echo "##### Service registry and supervision #####" |
| 174 | echo "############################################" |
| 175 | |
BjornMagnussonXA | e0b665e | 2021-01-08 22:19:18 +0100 | [diff] [blame] | 176 | api_put_service 201 "serv1" 1000 "$CR_SERVICE_PATH/1" |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 177 | |
BjornMagnussonXA | 49f0e5a | 2020-11-08 22:41:39 +0100 | [diff] [blame] | 178 | api_get_service_ids 200 "serv1" "ric-registration" |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 179 | |
| 180 | api_put_services_keepalive 200 "serv1" |
| 181 | |
| 182 | echo "############################################" |
| 183 | echo "############## RIC Repository ##############" |
| 184 | echo "############################################" |
| 185 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 186 | if [ "$PMS_VERSION" == "V2" ]; then |
BjornMagnussonXA | 2791e08 | 2020-11-12 00:52:08 +0100 | [diff] [blame] | 187 | api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:AVAILABLE ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE ricsim_g3_1:me1_ricsim_g3_1,me2_ricsim_g3_1:STD_QOS_0_2_0:AVAILABLE" |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 188 | else |
| 189 | api_get_rics 200 NOTYPE "ricsim_g1_1:me1_ricsim_g1_1,me2_ricsim_g1_1:1:AVAILABLE ricsim_g2_1:me1_ricsim_g2_1,me2_ricsim_g2_1:EMPTYTYPE:AVAILABLE" |
| 190 | fi |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 191 | |
| 192 | echo "############################################" |
| 193 | echo "########### A1 Policy Management ###########" |
| 194 | echo "############################################" |
| 195 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 196 | if [ "$PMS_VERSION" == "V2" ]; then |
BjornMagnussonXA | e0b665e | 2021-01-08 22:19:18 +0100 | [diff] [blame] | 197 | notificationurl=$CR_SERVICE_PATH"/test" |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 198 | else |
| 199 | notificationurl="" |
| 200 | fi |
| 201 | api_put_policy 201 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json |
| 202 | api_put_policy 200 "serv1" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json |
BjornMagnussonXA | 2791e08 | 2020-11-12 00:52:08 +0100 | [diff] [blame] | 203 | if [ "$PMS_VERSION" == "V2" ]; then |
| 204 | api_put_policy 201 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json |
| 205 | api_put_policy 200 "serv1" ricsim_g3_1 STD_QOS_0_2_0 5200 true $notificationurl testdata/STD2/pi_qos_template.json |
| 206 | fi |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 207 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 208 | api_put_policy 201 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json |
| 209 | api_put_policy 200 "serv1" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 210 | |
BjornMagnussonXA | 2791e08 | 2020-11-12 00:52:08 +0100 | [diff] [blame] | 211 | if [ "$PMS_VERSION" == "V2" ]; then |
| 212 | api_equal json:policies 3 |
| 213 | else |
| 214 | api_equal json:policies 2 |
| 215 | fi |
| 216 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 217 | api_delete_policy 204 5000 |
| 218 | |
| 219 | api_delete_policy 204 5100 |
| 220 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 221 | if [ "$PMS_VERSION" == "V2" ]; then |
BjornMagnussonXA | 2791e08 | 2020-11-12 00:52:08 +0100 | [diff] [blame] | 222 | api_delete_policy 204 5200 |
| 223 | fi |
| 224 | |
| 225 | if [ "$PMS_VERSION" == "V2" ]; then |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 226 | api_equal json:policies 0 |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 227 | |
BjornMagnussonXA | 49f0e5a | 2020-11-08 22:41:39 +0100 | [diff] [blame] | 228 | api_equal json:policy-instances 0 |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 229 | else |
| 230 | api_equal json:policies 0 |
| 231 | |
| 232 | api_equal json:policy_ids 0 |
| 233 | fi |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 234 | |
BjornMagnussonXA | 49f0e5a | 2020-11-08 22:41:39 +0100 | [diff] [blame] | 235 | if [ "$PMS_VERSION" == "V2" ]; then |
| 236 | cr_equal received_callbacks 3 |
| 237 | fi |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 238 | |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 239 | if [[ $interface = *"DMAAP"* ]]; then |
BjornMagnussonXA | 2791e08 | 2020-11-12 00:52:08 +0100 | [diff] [blame] | 240 | |
| 241 | if [ "$PMS_VERSION" == "V2" ]; then |
| 242 | VAL=14 # Number of Agent API calls over DMAAP |
| 243 | else |
| 244 | VAL=11 # Number of Agent API calls over DMAAP |
| 245 | fi |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 246 | mr_equal requests_fetched $VAL |
| 247 | mr_equal responses_submitted $VAL |
| 248 | mr_equal responses_fetched $VAL |
| 249 | mr_equal current_requests 0 |
| 250 | mr_equal current_responses 0 |
| 251 | else |
| 252 | mr_equal requests_submitted 0 |
| 253 | fi |
| 254 | |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 255 | if [[ $interface = *"SDNC"* ]]; then |
BjornMagnussonXA | e0b665e | 2021-01-08 22:19:18 +0100 | [diff] [blame] | 256 | sim_contains_str ricsim_g1_1 remote_hosts $SDNC_APP_NAME |
| 257 | sim_contains_str ricsim_g2_1 remote_hosts $SDNC_APP_NAME |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 258 | if [ "$PMS_VERSION" == "V2" ]; then |
BjornMagnussonXA | e0b665e | 2021-01-08 22:19:18 +0100 | [diff] [blame] | 259 | sim_contains_str ricsim_g3_1 remote_hosts $SDNC_APP_NAME |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 260 | fi |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 261 | else |
BjornMagnussonXA | e0b665e | 2021-01-08 22:19:18 +0100 | [diff] [blame] | 262 | sim_contains_str ricsim_g1_1 remote_hosts $POLICY_AGENT_APP_NAME |
| 263 | sim_contains_str ricsim_g2_1 remote_hosts $POLICY_AGENT_APP_NAME |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 264 | if [ "$PMS_VERSION" == "V2" ]; then |
BjornMagnussonXA | e0b665e | 2021-01-08 22:19:18 +0100 | [diff] [blame] | 265 | sim_contains_str ricsim_g3_1 remote_hosts $POLICY_AGENT_APP_NAME |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 266 | fi |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 267 | fi |
| 268 | |
| 269 | check_policy_agent_logs |
| 270 | check_control_panel_logs |
| 271 | |
BjornMagnussonXA | 49f0e5a | 2020-11-08 22:41:39 +0100 | [diff] [blame] | 272 | if [[ $interface = *"SDNC"* ]]; then |
| 273 | check_sdnc_logs |
| 274 | fi |
| 275 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 276 | store_logs "${__httpx}__${interface}" |
| 277 | |
| 278 | done |
| 279 | |
| 280 | done |
| 281 | |
| 282 | #### TEST COMPLETE #### |
| 283 | |
| 284 | |
| 285 | print_result |
| 286 | |
BjornMagnussonXA | e0b665e | 2021-01-08 22:19:18 +0100 | [diff] [blame] | 287 | auto_clean_environment |