Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 1 | # Copyright 2017 Mirantis, Inc. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 14 | import pytest |
| 15 | |
| 16 | from tcp_tests import logger |
| 17 | |
| 18 | LOG = logger.logger |
| 19 | |
| 20 | |
| 21 | class TestFailover(object): |
| 22 | """Test class for testing OpenStack nodes failover""" |
| 23 | |
| 24 | @pytest.mark.grab_versions |
| 25 | @pytest.mark.fail_snapshot |
| 26 | def test_warm_shutdown_ctl01_node(self, underlay, openstack_deployed, |
| 27 | openstack_actions, show_step): |
| 28 | """Test warm shutdown ctl01 |
| 29 | |
| 30 | Scenario: |
| 31 | 1. Prepare salt on hosts |
| 32 | 2. Setup controller nodes |
| 33 | 3. Setup compute nodes |
| 34 | 4. Shutdown ctl01 |
| 35 | 5. Run tempest smoke after failover |
| 36 | |
| 37 | |
| 38 | """ |
| 39 | # STEP #1,2,3 |
| 40 | show_step(1) |
| 41 | show_step(2) |
| 42 | show_step(3) |
| 43 | # STEP #4 |
| 44 | show_step(4) |
| 45 | openstack_actions.warm_shutdown_openstack_nodes('ctl01') |
| 46 | # STEP #5 |
| 47 | show_step(5) |
| 48 | openstack_actions.run_tempest(pattern='smoke') |
| 49 | |
| 50 | LOG.info("*************** DONE **************") |
| 51 | |
| 52 | @pytest.mark.grab_versions |
| 53 | @pytest.mark.fail_snapshot |
| 54 | def test_restart_ctl01_node(self, underlay, openstack_deployed, |
Dennis Dmitriev | 9b02c8b | 2017-11-13 15:31:35 +0200 | [diff] [blame] | 55 | openstack_actions, show_step): |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 56 | """Test restart ctl01 |
| 57 | |
| 58 | Scenario: |
| 59 | 1. Prepare salt on hosts |
| 60 | 2. Setup controller nodes |
| 61 | 3. Setup compute nodes |
| 62 | 4. Restart ctl01 |
| 63 | 5. Run tempest smoke after failover |
| 64 | |
| 65 | |
| 66 | """ |
| 67 | # STEP #1,2,3 |
| 68 | show_step(1) |
| 69 | show_step(2) |
| 70 | show_step(3) |
| 71 | |
| 72 | # STEP #4 |
| 73 | show_step(4) |
| 74 | openstack_actions.warm_restart_nodes('ctl01') |
| 75 | # STEP #5 |
| 76 | show_step(5) |
| 77 | openstack_actions.run_tempest(pattern='smoke') |
| 78 | |
| 79 | LOG.info("*************** DONE **************") |
| 80 | |
| 81 | @pytest.mark.grab_versions |
| 82 | @pytest.mark.fail_snapshot |
| 83 | def test_warm_shutdown_cmp01_node(self, underlay, openstack_deployed, |
| 84 | openstack_actions, show_step): |
| 85 | """Test warm shutdown cmp01 |
| 86 | |
| 87 | Scenario: |
| 88 | 1. Prepare salt on hosts |
| 89 | 2. Setup controller nodes |
| 90 | 3. Setup compute nodes |
| 91 | 4. Shutdown cmp01 |
| 92 | 5. Run tempest smoke after failover |
| 93 | |
| 94 | |
| 95 | """ |
| 96 | # STEP #1,2,3 |
| 97 | show_step(1) |
| 98 | show_step(2) |
| 99 | show_step(3) |
| 100 | |
| 101 | # STEP #4 |
| 102 | show_step(4) |
| 103 | openstack_actions.warm_shutdown_openstack_nodes('cmp01') |
| 104 | # STEP #5 |
| 105 | show_step(5) |
| 106 | openstack_actions.run_tempest(pattern='smoke') |
| 107 | |
| 108 | LOG.info("*************** DONE **************") |
| 109 | |
| 110 | @pytest.mark.grab_versions |
| 111 | @pytest.mark.fail_snapshot |
| 112 | def test_restart_cmp01_node(self, underlay, openstack_deployed, |
| 113 | openstack_actions, show_step): |
| 114 | """Test restart cmp01 |
| 115 | |
| 116 | Scenario: |
| 117 | 1. Prepare salt on hosts |
| 118 | 2. Setup controller nodes |
| 119 | 3. Setup compute nodes |
| 120 | 4. Restart cmp01 |
| 121 | 5. Run tempest smoke after failover |
| 122 | |
| 123 | |
| 124 | """ |
| 125 | # STEP #1,2,3 |
| 126 | show_step(1) |
| 127 | show_step(2) |
| 128 | show_step(3) |
| 129 | |
| 130 | # STEP #4 |
| 131 | show_step(4) |
| 132 | openstack_actions.warm_restart_nodes('cmp01') |
| 133 | # STEP #5 |
| 134 | show_step(5) |
| 135 | openstack_actions.run_tempest(pattern='smoke') |
| 136 | |
| 137 | LOG.info("*************** DONE **************") |
| 138 | |
| 139 | @pytest.mark.grab_versions |
| 140 | @pytest.mark.fail_snapshot |
| 141 | def test_restart_mon01_node(self, underlay, openstack_deployed, |
| 142 | openstack_actions, sl_deployed, |
| 143 | show_step): |
| 144 | """Test restart mon01 |
| 145 | |
| 146 | Scenario: |
| 147 | 1. Prepare salt on hosts |
| 148 | 2. Setup controller nodes |
| 149 | 3. Setup compute, monitoring nodes |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 150 | 4. Check targets before restart |
| 151 | 5. Restart mon01 |
| 152 | 6. Check targets after restart |
| 153 | 6. Run LMA smoke after failover |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 154 | |
| 155 | |
| 156 | """ |
| 157 | # STEP #1,2,3 |
| 158 | show_step(1) |
| 159 | show_step(2) |
| 160 | show_step(3) |
| 161 | |
| 162 | # STEP #4 |
| 163 | show_step(4) |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 164 | mon_nodes = sl_deployed.get_monitoring_nodes() |
| 165 | LOG.debug('Mon nodes list {0}'.format(mon_nodes)) |
| 166 | sl_deployed.check_prometheus_targets(mon_nodes) |
| 167 | before_result = sl_deployed.run_sl_tests_json( |
| 168 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 169 | 'tests/prometheus/', 'test_alerts.py') |
| 170 | failed_tests = [test['name'] for test in |
| 171 | before_result if 'passed' not in test['outcome']] |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 172 | # STEP #5 |
| 173 | show_step(5) |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 174 | openstack_actions.warm_restart_nodes('mon01') |
| 175 | # STEP #6 |
| 176 | show_step(6) |
| 177 | sl_deployed.check_prometheus_targets(mon_nodes) |
| 178 | # STEP #7 |
| 179 | show_step(7) |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 180 | # Run SL component tetsts |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 181 | after_result = sl_deployed.run_sl_tests_json( |
| 182 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 183 | 'tests/prometheus/', 'test_alerts.py') |
| 184 | for test in after_result: |
| 185 | if test['name'] not in failed_tests: |
| 186 | assert 'passed' in test['outcome'], \ |
| 187 | 'Failed test {}'.format(test) |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 188 | LOG.info("*************** DONE **************") |
| 189 | |
| 190 | @pytest.mark.grab_versions |
| 191 | @pytest.mark.fail_snapshot |
| 192 | def test_warm_shutdown_mon01_node(self, underlay, openstack_deployed, |
| 193 | openstack_actions, sl_deployed, |
| 194 | show_step): |
| 195 | """Test warm shutdown mon01 |
| 196 | |
| 197 | Scenario: |
| 198 | 1. Prepare salt on hosts |
| 199 | 2. Setup controller nodes |
| 200 | 3. Setup compute, monitoring nodes |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 201 | 4. Check LMA before mon node shutdown |
| 202 | 5. Shutdown mon01 node |
| 203 | 6. Run LMA tests after failover |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 204 | |
| 205 | |
| 206 | """ |
| 207 | # STEP #1,2,3 |
| 208 | show_step(1) |
| 209 | show_step(2) |
| 210 | show_step(3) |
| 211 | |
| 212 | # STEP #4 |
| 213 | show_step(4) |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 214 | mon_nodes = sl_deployed.get_monitoring_nodes() |
| 215 | LOG.debug('Mon nodes list {0}'.format(mon_nodes)) |
| 216 | sl_deployed.check_prometheus_targets(mon_nodes) |
| 217 | before_result = sl_deployed.run_sl_tests_json( |
| 218 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 219 | 'tests/prometheus/', 'test_alerts.py') |
| 220 | failed_tests = [test['name'] for test in |
| 221 | before_result if 'passed' not in test['outcome']] |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 222 | # STEP #5 |
| 223 | show_step(5) |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 224 | openstack_actions.warm_shutdown_openstack_nodes('mon01') |
| 225 | # STEP #6 |
| 226 | show_step(6) |
| 227 | # Run SL component tetsts |
| 228 | after_result = sl_deployed.run_sl_tests_json( |
| 229 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 230 | 'tests/prometheus/', 'test_alerts.py') |
| 231 | for test in after_result: |
| 232 | if test['name'] not in failed_tests: |
| 233 | assert 'passed' in test['outcome'], \ |
| 234 | 'Failed test {}'.format(test) |
| 235 | LOG.info("*************** DONE **************") |
| 236 | |
| 237 | @pytest.mark.grab_versions |
| 238 | @pytest.mark.fail_snapshot |
| 239 | def test_kill_influxdb_relay_mon01_node(self, underlay, |
| 240 | openstack_deployed, |
| 241 | openstack_actions, |
| 242 | sl_deployed): |
| 243 | """Test kill influxdb relay on mon01 node |
| 244 | |
| 245 | Scenario: |
| 246 | 1. Prepare salt on hosts |
| 247 | 2. Setup controller nodes |
| 248 | 3. Setup compute, monitoring nodes |
| 249 | 4. Check LMA before mon node shutdown |
| 250 | 5. Kill influxdb relay on mon01 node |
| 251 | 6. Post data into influx |
| 252 | 7. Get data from all healthy nodes |
| 253 | 8. Start influx db |
| 254 | 9. Request data on mon01 |
| 255 | 10. Run LMA tests after fail and compare with result before fail |
| 256 | |
| 257 | |
| 258 | """ |
| 259 | # STEP #1,2,3 |
| 260 | # STEP #4 |
| 261 | mon_nodes = sl_deployed.get_monitoring_nodes() |
| 262 | LOG.debug('Mon nodes list {0}'.format(mon_nodes)) |
| 263 | before_result = sl_deployed.run_sl_tests_json( |
| 264 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 265 | 'tests/prometheus/', 'test_alerts.py') |
| 266 | failed_tests = [test['name'] for test in |
| 267 | before_result if 'passed' not in test['outcome']] |
| 268 | # STEP #5 |
| 269 | |
| 270 | sl_deployed.kill_sl_service_on_node('mon01', 'influxdb-relay') |
| 271 | # STEP #6 |
| 272 | |
| 273 | sl_deployed.post_data_into_influx('mon02') |
| 274 | # STEP #7 |
| 275 | |
| 276 | assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon02') |
| 277 | assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon03') |
| 278 | # STEP #8 |
| 279 | |
| 280 | sl_deployed.start_service('mon01', 'influxdb-relay') |
| 281 | # STEP #9 |
| 282 | |
| 283 | assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon01') |
| 284 | # STEP #10 |
| 285 | |
| 286 | after_result = sl_deployed.run_sl_tests_json( |
| 287 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 288 | 'tests/prometheus/', 'test_alerts.py') |
| 289 | for test in after_result: |
| 290 | if test['name'] not in failed_tests: |
| 291 | assert 'passed' in test['outcome'], \ |
| 292 | 'Failed test {}'.format(test) |
| 293 | LOG.info("*************** DONE **************") |
| 294 | |
| 295 | @pytest.mark.grab_versions |
| 296 | @pytest.mark.fail_snapshot |
| 297 | def test_kill_influxdb_mon01_node(self, underlay, |
| 298 | openstack_deployed, |
| 299 | openstack_actions, |
| 300 | sl_deployed): |
| 301 | """Test kill influxdb on mon01 node |
| 302 | |
| 303 | Scenario: |
| 304 | 1. Prepare salt on hosts |
| 305 | 2. Setup controller nodes |
| 306 | 3. Setup compute, monitoring nodes |
| 307 | 4. Check LMA before mon node shutdown |
| 308 | 5. Kill influxdb on mon01 node |
| 309 | 6. Post data into influx |
| 310 | 7. Get data from all healthy nodes |
| 311 | 8. Start influx db |
| 312 | 9. Request data on mon01 |
| 313 | 10. Run LMA tests after fail and compare with result before fail |
| 314 | |
| 315 | |
| 316 | """ |
| 317 | # STEP #1,2,3 |
| 318 | |
| 319 | # STEP #4 |
| 320 | |
| 321 | mon_nodes = sl_deployed.get_monitoring_nodes() |
| 322 | LOG.debug('Mon nodes list {0}'.format(mon_nodes)) |
| 323 | before_result = sl_deployed.run_sl_tests_json( |
| 324 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 325 | 'tests/prometheus/', 'test_alerts.py') |
| 326 | failed_tests = [test['name'] for test in |
| 327 | before_result if 'passed' not in test['outcome']] |
| 328 | # STEP #5 |
| 329 | |
| 330 | sl_deployed.kill_sl_service_on_node('mon01', 'influxd') |
| 331 | |
| 332 | sl_deployed.post_data_into_influx('mon02') |
| 333 | # STEP #7 |
| 334 | |
| 335 | assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon02') |
| 336 | assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon03') |
| 337 | # STEP #8 |
| 338 | |
| 339 | sl_deployed.start_service('mon01', 'influxd') |
| 340 | # STEP #9 |
| 341 | assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon01') |
| 342 | # STEP #10 |
| 343 | |
| 344 | after_result = sl_deployed.run_sl_tests_json( |
| 345 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 346 | 'tests/prometheus/', 'test_alerts.py') |
| 347 | for test in after_result: |
| 348 | if test['name'] not in failed_tests: |
| 349 | assert 'passed' in test['outcome'], \ |
| 350 | 'Failed test {}'.format(test) |
| 351 | LOG.info("*************** DONE **************") |
| 352 | |
| 353 | @pytest.mark.grab_versions |
| 354 | @pytest.mark.fail_snapshot |
| 355 | def test_stop_influxdb_relay_mon_nodes(self, underlay, |
Dennis Dmitriev | 9b02c8b | 2017-11-13 15:31:35 +0200 | [diff] [blame] | 356 | openstack_deployed, |
| 357 | openstack_actions, |
| 358 | sl_deployed): |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 359 | """Test stop influxdb relay on mon01 node |
| 360 | |
| 361 | Scenario: |
| 362 | 1. Prepare salt on hosts |
| 363 | 2. Setup controller nodes |
| 364 | 3. Setup compute, monitoring nodes |
| 365 | 4. Check LMA before mon node shutdown |
| 366 | 5. Stop influxdb relay on mon01 and mon02 nodes |
| 367 | 6. Post data into influx |
| 368 | 7. Get data from all healthy nodes |
| 369 | 8. Start influx db |
| 370 | 9. Request data on mon01, 02 |
| 371 | 10. Run LMA tests after fail and compare with result before fail |
| 372 | |
| 373 | |
| 374 | """ |
| 375 | # STEP #1,2,3 |
| 376 | mon_nodes = sl_deployed.get_monitoring_nodes() |
| 377 | LOG.debug('Mon nodes list {0}'.format(mon_nodes)) |
| 378 | before_result = sl_deployed.run_sl_tests_json( |
| 379 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 380 | 'tests/prometheus/', 'test_alerts.py') |
| 381 | failed_tests = [test['name'] for test in |
| 382 | before_result if 'passed' not in test['outcome']] |
| 383 | # STEP #5 |
| 384 | |
| 385 | sl_deployed.stop_sl_service_on_node('mon01', 'influxdb-relay') |
| 386 | sl_deployed.stop_sl_service_on_node('mon02', 'influxdb-relay') |
| 387 | # STEP #6 |
| 388 | |
| 389 | sl_deployed.post_data_into_influx('mon03') |
| 390 | # STEP #7 |
| 391 | |
| 392 | assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon03') |
| 393 | # STEP #8 |
| 394 | |
| 395 | sl_deployed.start_service('mon01', 'influxdb-relay') |
| 396 | sl_deployed.start_service('mon02', 'influxdb-relay') |
| 397 | # STEP #9 |
| 398 | |
| 399 | assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon01') |
| 400 | assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon02') |
| 401 | # STEP #10 |
| 402 | |
| 403 | after_result = sl_deployed.run_sl_tests_json( |
| 404 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 405 | 'tests/prometheus/', 'test_alerts.py') |
| 406 | for test in after_result: |
| 407 | if test['name'] not in failed_tests: |
| 408 | assert 'passed' in test['outcome'], \ |
| 409 | 'Failed test {}'.format(test) |
| 410 | LOG.info("*************** DONE **************") |
| 411 | |
| 412 | @pytest.mark.grab_versions |
| 413 | @pytest.mark.fail_snapshot |
| 414 | def test_stop_influxdb_mon_nodes(self, underlay, |
Dennis Dmitriev | 9b02c8b | 2017-11-13 15:31:35 +0200 | [diff] [blame] | 415 | openstack_deployed, |
| 416 | openstack_actions, |
| 417 | sl_deployed): |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 418 | """Test stop influxdb on mon01 node |
| 419 | |
| 420 | Scenario: |
| 421 | 1. Prepare salt on hosts |
| 422 | 2. Setup controller nodes |
| 423 | 3. Setup compute, monitoring nodes |
| 424 | 4. Check LMA before mon node shutdown |
| 425 | 5. Stop influxdb on mon01 and mon02 node |
| 426 | 6. Post data into influx |
| 427 | 7. Get data from all healthy nodes |
| 428 | 8. Start influx db |
| 429 | 9. Request data on mon01 |
| 430 | 10. Run LMA tests after fail and compare with result before fail |
| 431 | |
| 432 | |
| 433 | """ |
| 434 | # STEP #1,2,3 |
| 435 | mon_nodes = sl_deployed.get_monitoring_nodes() |
| 436 | LOG.debug('Mon nodes list {0}'.format(mon_nodes)) |
| 437 | before_result = sl_deployed.run_sl_tests_json( |
| 438 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 439 | 'tests/prometheus/', 'test_alerts.py') |
| 440 | failed_tests = [test['name'] for test in |
| 441 | before_result if 'passed' not in test['outcome']] |
| 442 | # STEP #5 |
| 443 | |
| 444 | sl_deployed.stop_sl_service_on_node('mon01', 'influxdb') |
| 445 | sl_deployed.stop_sl_service_on_node('mon02', 'influxdb') |
| 446 | # STEP #6 |
| 447 | |
| 448 | sl_deployed.post_data_into_influx('mon03') |
| 449 | # STEP #7 |
| 450 | |
| 451 | assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon03') |
| 452 | # STEP #8 |
| 453 | |
| 454 | sl_deployed.start_service('mon01', 'influxdb') |
| 455 | sl_deployed.start_service('mon02', 'influxdb') |
| 456 | # STEP #9 |
| 457 | |
| 458 | assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon01') |
| 459 | assert 'mymeas' in sl_deployed.check_data_in_influxdb('mon02') |
| 460 | # STEP #10 |
Dennis Dmitriev | 9b02c8b | 2017-11-13 15:31:35 +0200 | [diff] [blame] | 461 | |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 462 | after_result = sl_deployed.run_sl_tests_json( |
| 463 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 464 | 'tests/prometheus/', 'test_alerts.py') |
| 465 | for test in after_result: |
| 466 | if test['name'] not in failed_tests: |
| 467 | assert 'passed' in test['outcome'], \ |
| 468 | 'Failed test {}'.format(test) |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 469 | LOG.info("*************** DONE **************") |