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="Testing of service registration timeouts and keepalive" |
| 22 | |
BjornMagnussonXA | f38e1e8 | 2020-10-11 23:05:02 +0200 | [diff] [blame] | 23 | #App names to include in the test, space separated list |
| 24 | INCLUDED_IMAGES="CBS CONSUL CP CR MR PA RICSIM" |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 25 | |
BjornMagnussonXA | 49f0e5a | 2020-11-08 22:41:39 +0100 | [diff] [blame] | 26 | #SUPPORTED TEST ENV FILE |
BjornMagnussonXA | 89b64ab | 2020-12-16 09:21:01 +0100 | [diff] [blame] | 27 | SUPPORTED_PROFILES="ONAP-GUILIN ONAP-HONOLULU ORAN-CHERRY ORAN-DAWN" |
BjornMagnussonXA | 49f0e5a | 2020-11-08 22:41:39 +0100 | [diff] [blame] | 28 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 29 | . ../common/testcase_common.sh $@ |
| 30 | . ../common/agent_api_functions.sh |
| 31 | . ../common/ricsimulator_api_functions.sh |
BjornMagnussonXA | 49f0e5a | 2020-11-08 22:41:39 +0100 | [diff] [blame] | 32 | . ../common/cr_api_functions.sh |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 33 | |
BjornMagnussonXA | ad04778 | 2020-06-08 15:54:11 +0200 | [diff] [blame] | 34 | generate_uuid |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 35 | |
BjornMagnussonXA | 496156d | 2020-08-10 14:16:24 +0200 | [diff] [blame] | 36 | use_cr_http |
BjornMagnussonXA | bf3700b | 2020-10-05 08:39:40 +0200 | [diff] [blame] | 37 | use_simulator_http |
| 38 | use_mr_http |
| 39 | use_agent_rest_http |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 40 | |
| 41 | |
| 42 | #### TEST BEGIN #### |
| 43 | |
| 44 | clean_containers |
| 45 | |
| 46 | start_ric_simulators ricsim_g1 1 OSC_2.1.0 |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 47 | start_ric_simulators ricsim_g2 1 STD_1.1.3 |
| 48 | if [ "$PMS_VERSION" == "V2" ]; then |
| 49 | start_ric_simulators ricsim_g3 1 STD_2.0.0 |
| 50 | fi |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 51 | |
| 52 | start_mr |
| 53 | |
| 54 | start_cr |
| 55 | |
| 56 | start_consul_cbs |
| 57 | |
| 58 | prepare_consul_config NOSDNC ".consul_config.json" |
| 59 | consul_config_app ".consul_config.json" |
| 60 | |
| 61 | start_control_panel |
| 62 | |
| 63 | start_policy_agent |
| 64 | |
| 65 | set_agent_debug |
| 66 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 67 | mr_equal requests_submitted 0 |
| 68 | |
| 69 | #Check agent alive |
| 70 | api_get_status 200 |
| 71 | |
| 72 | #Print simulator interface version |
| 73 | sim_print ricsim_g1_1 interface |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 74 | sim_print ricsim_g2_1 interface |
| 75 | if [ "$PMS_VERSION" == "V2" ]; then |
| 76 | sim_print ricsim_g3_1 interface |
| 77 | fi |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 78 | |
| 79 | api_put_service 201 "service1" 15 "$CR_PATH/service1" |
| 80 | |
| 81 | api_get_services 200 "service1" "service1" 15 "$CR_PATH/service1" |
| 82 | |
| 83 | api_put_service 201 "service2" 120 "$CR_PATH/service2" |
| 84 | |
| 85 | api_get_services 200 "service2" "service2" 120 "$CR_PATH/service2" |
| 86 | |
| 87 | api_put_service 200 "service1" 50 "$CR_PATH/service1" |
| 88 | api_put_service 200 "service2" 180 "$CR_PATH/service2" |
| 89 | |
| 90 | api_get_services 200 "service1" "service1" 50 "$CR_PATH/service1" |
| 91 | api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2" |
| 92 | |
| 93 | api_get_service_ids 200 "service1" "service2" |
| 94 | |
| 95 | sleep_wait 30 "Waiting for keep alive timeout" |
| 96 | |
| 97 | api_get_services 200 "service1" "service1" 50 "$CR_PATH/service1" |
| 98 | api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2" |
| 99 | |
| 100 | sleep_wait 100 "Waiting for keep alive timeout" |
| 101 | |
| 102 | api_get_services 404 "service1" |
| 103 | api_get_services 200 "service2" "service2" 180 "$CR_PATH/service2" |
| 104 | |
| 105 | api_delete_services 204 "service2" |
| 106 | |
| 107 | api_get_services 404 "service1" |
| 108 | api_get_services 404 "service2" |
| 109 | |
| 110 | api_put_service 201 "service3" 60 "$CR_PATH/service3" |
| 111 | |
| 112 | api_get_services 200 "service3" "service3" 60 "$CR_PATH/service3" |
| 113 | |
| 114 | sleep_wait 30 "Waiting for keep alive timeout" |
| 115 | |
| 116 | api_put_service 200 "service3" 60 "$CR_PATH/service3" |
| 117 | |
| 118 | sleep_wait 100 "Waiting for keep alive timeout" |
| 119 | |
| 120 | api_get_services 404 "service3" |
| 121 | |
| 122 | api_put_service 201 "service4" 120 "$CR_PATH/service4" |
| 123 | |
| 124 | sleep_wait 60 "Waiting for keep alive timeout" |
| 125 | |
| 126 | api_get_services 200 "service4" "service4" 120 "$CR_PATH/service4" |
| 127 | |
| 128 | api_put_services_keepalive 200 "service4" |
| 129 | |
| 130 | sleep_wait 90 "Waiting for keep alive timeout" |
| 131 | |
| 132 | api_get_services 200 "service4" "service4" 120 "$CR_PATH/service4" |
| 133 | |
| 134 | api_delete_services 204 "service4" |
| 135 | |
| 136 | api_get_services 404 "service4" |
| 137 | |
| 138 | api_get_services 404 "service1" |
| 139 | api_get_services 404 "service2" |
| 140 | api_get_services 404 "service3" |
| 141 | |
| 142 | api_get_service_ids 200 |
| 143 | |
| 144 | api_delete_services 404 "service1" |
| 145 | api_delete_services 404 "service2" |
| 146 | api_delete_services 404 "service3" |
| 147 | api_delete_services 404 "service4" |
| 148 | |
| 149 | api_put_services_keepalive 404 "service1" |
| 150 | api_put_services_keepalive 404 "service2" |
| 151 | api_put_services_keepalive 404 "service3" |
| 152 | api_put_services_keepalive 404 "service4" |
| 153 | |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 154 | # Policy delete after timeout |
| 155 | api_put_service 201 "service10" 600 "$CR_PATH/service10" |
| 156 | |
| 157 | sim_put_policy_type 201 ricsim_g1_1 1 testdata/OSC/sim_1.json |
| 158 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 159 | if [ "$PMS_VERSION" == "V2" ]; then |
BjornMagnussonXA | 2791e08 | 2020-11-12 00:52:08 +0100 | [diff] [blame] | 160 | |
| 161 | sim_put_policy_type 201 ricsim_g3_1 STD_QOS2_0.1.0 testdata/STD2/sim_qos2.json |
| 162 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 163 | api_equal json:rics 3 60 |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 164 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 165 | #api_equal json:policy_schemas 2 120 |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 166 | |
BjornMagnussonXA | 2791e08 | 2020-11-12 00:52:08 +0100 | [diff] [blame] | 167 | api_equal json:policy-types 3 120 |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 168 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 169 | api_equal json:policies 0 |
| 170 | else |
| 171 | api_equal json:rics 2 60 |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 172 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 173 | api_equal json:policy_schemas 2 120 |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 174 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 175 | api_equal json:policy_types 2 |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 176 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 177 | api_equal json:policies 0 |
| 178 | fi |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 179 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 180 | if [ "$PMS_VERSION" == "V2" ]; then |
BjornMagnussonXA | 49f0e5a | 2020-11-08 22:41:39 +0100 | [diff] [blame] | 181 | notificationurl=$CR_PATH"/test" |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 182 | else |
| 183 | notificationurl="" |
| 184 | fi |
| 185 | |
| 186 | api_put_policy 201 "service10" ricsim_g1_1 1 5000 NOTRANSIENT $notificationurl testdata/OSC/pi1_template.json |
| 187 | api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5100 NOTRANSIENT $notificationurl testdata/STD/pi1_template.json |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 188 | |
BjornMagnussonXA | 2791e08 | 2020-11-12 00:52:08 +0100 | [diff] [blame] | 189 | if [ "$PMS_VERSION" == "V2" ]; then |
| 190 | api_put_policy 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5200 NOTRANSIENT $notificationurl testdata/STD2/pi_qos2_template.json |
| 191 | api_equal json:policies 3 |
| 192 | else |
| 193 | api_equal json:policies 2 |
| 194 | fi |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 195 | |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 196 | sim_equal ricsim_g1_1 num_instances 1 |
| 197 | sim_equal ricsim_g2_1 num_instances 1 |
| 198 | |
| 199 | api_put_policy 201 "service10" ricsim_g1_1 1 5001 true $notificationurl testdata/OSC/pi1_template.json |
| 200 | api_put_policy 201 "service10" ricsim_g2_1 NOTYPE 5101 true $notificationurl testdata/STD/pi1_template.json |
| 201 | |
BjornMagnussonXA | 2791e08 | 2020-11-12 00:52:08 +0100 | [diff] [blame] | 202 | if [ "$PMS_VERSION" == "V2" ]; then |
| 203 | api_put_policy 201 "service10" ricsim_g3_1 STD_QOS2_0.1.0 5201 true $notificationurl testdata/STD2/pi_qos2_template.json |
| 204 | api_equal json:policies 6 |
| 205 | else |
| 206 | api_equal json:policies 4 |
| 207 | fi |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 208 | |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 209 | sim_equal ricsim_g1_1 num_instances 2 |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 210 | sim_equal ricsim_g2_1 num_instances 2 |
BjornMagnussonXA | 2791e08 | 2020-11-12 00:52:08 +0100 | [diff] [blame] | 211 | if [ "$PMS_VERSION" == "V2" ]; then |
| 212 | sim_equal ricsim_g3_1 num_instances 2 |
| 213 | fi |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 214 | |
| 215 | sim_post_delete_instances 200 ricsim_g1_1 |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 216 | sim_post_delete_instances 200 ricsim_g2_1 |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 217 | |
BjornMagnussonXA | 2791e08 | 2020-11-12 00:52:08 +0100 | [diff] [blame] | 218 | if [ "$PMS_VERSION" == "V2" ]; then |
| 219 | sim_post_delete_instances 200 ricsim_g3_1 |
| 220 | fi |
| 221 | |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 222 | #Wait for recreate of non transient policy |
BjornMagnussonXA | 2791e08 | 2020-11-12 00:52:08 +0100 | [diff] [blame] | 223 | if [ "$PMS_VERSION" == "V2" ]; then |
| 224 | api_equal json:policies 3 180 |
| 225 | else |
| 226 | api_equal json:policies 2 180 |
| 227 | fi |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 228 | |
| 229 | sim_equal ricsim_g1_1 num_instances 1 |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 230 | sim_equal ricsim_g2_1 num_instances 1 |
BjornMagnussonXA | 2791e08 | 2020-11-12 00:52:08 +0100 | [diff] [blame] | 231 | if [ "$PMS_VERSION" == "V2" ]; then |
| 232 | sim_equal ricsim_g3_1 num_instances 1 |
| 233 | fi |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 234 | |
| 235 | api_put_service 200 "service10" 10 "$CR_PATH/service10" |
| 236 | |
| 237 | #Wait for service expiry |
| 238 | api_equal json:policies 0 120 |
| 239 | |
| 240 | sim_equal ricsim_g1_1 num_instances 0 |
BjornMagnussonXA | 4207b83 | 2020-11-03 09:52:49 +0100 | [diff] [blame] | 241 | sim_equal ricsim_g2_1 num_instances 0 |
BjornMagnussonXA | 2791e08 | 2020-11-12 00:52:08 +0100 | [diff] [blame] | 242 | if [ "$PMS_VERSION" == "V2" ]; then |
| 243 | sim_equal ricsim_g3_1 num_instances 0 |
| 244 | fi |
BjornMagnussonXA | bbd2e9d | 2020-05-27 21:24:06 +0200 | [diff] [blame] | 245 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 246 | api_get_service_ids 200 |
| 247 | |
BjornMagnussonXA | 70e878f | 2020-05-11 14:11:30 +0200 | [diff] [blame] | 248 | mr_equal requests_submitted 0 |
| 249 | |
| 250 | check_policy_agent_logs |
| 251 | check_control_panel_logs |
| 252 | |
| 253 | #### TEST COMPLETE #### |
| 254 | |
| 255 | store_logs END |
| 256 | |
| 257 | print_result |
| 258 | |
| 259 | auto_clean_containers |