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. |
Dennis Dmitriev | 8ce8515 | 2017-11-29 00:05:12 +0200 | [diff] [blame] | 14 | from devops.helpers import helpers |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 15 | import pytest |
| 16 | |
| 17 | from tcp_tests import logger |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 18 | from tcp_tests.helpers import ext |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 19 | |
| 20 | LOG = logger.logger |
| 21 | |
| 22 | |
| 23 | class TestFailover(object): |
| 24 | """Test class for testing OpenStack nodes failover""" |
| 25 | |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 26 | @staticmethod |
Dennis Dmitriev | 28fd049 | 2017-11-29 13:33:21 +0200 | [diff] [blame] | 27 | def check_influxdb_xfail(sl_deployed, node_name, value): |
| 28 | |
| 29 | def check_influxdb_data(): |
| 30 | return value in sl_deployed.check_data_in_influxdb(node_name) |
| 31 | |
| 32 | try: |
| 33 | helpers.wait( |
| 34 | check_influxdb_data, |
| 35 | timeout=10, interval=2, |
| 36 | timeout_msg=('Influxdb data {0} was not replicated to {1} ' |
| 37 | '[https://mirantis.jira.com/browse/PROD-16272]' |
| 38 | .format(value, node_name))) |
| 39 | except Exception: |
| 40 | pytest.xfail('Influxdb data {0} was not replicated to {1} ' |
| 41 | '[https://mirantis.jira.com/browse/PROD-16272]' |
| 42 | .format(value, node_name)) |
| 43 | |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 44 | @pytest.mark.grab_versions |
| 45 | @pytest.mark.fail_snapshot |
| 46 | def test_warm_shutdown_ctl01_node(self, underlay, openstack_deployed, |
| 47 | openstack_actions, show_step): |
| 48 | """Test warm shutdown ctl01 |
| 49 | |
| 50 | Scenario: |
| 51 | 1. Prepare salt on hosts |
| 52 | 2. Setup controller nodes |
| 53 | 3. Setup compute nodes |
| 54 | 4. Shutdown ctl01 |
| 55 | 5. Run tempest smoke after failover |
| 56 | |
| 57 | |
| 58 | """ |
| 59 | # STEP #1,2,3 |
| 60 | show_step(1) |
| 61 | show_step(2) |
| 62 | show_step(3) |
| 63 | # STEP #4 |
| 64 | show_step(4) |
| 65 | openstack_actions.warm_shutdown_openstack_nodes('ctl01') |
| 66 | # STEP #5 |
| 67 | show_step(5) |
| 68 | openstack_actions.run_tempest(pattern='smoke') |
| 69 | |
| 70 | LOG.info("*************** DONE **************") |
| 71 | |
| 72 | @pytest.mark.grab_versions |
| 73 | @pytest.mark.fail_snapshot |
| 74 | def test_restart_ctl01_node(self, underlay, openstack_deployed, |
Dennis Dmitriev | 9b02c8b | 2017-11-13 15:31:35 +0200 | [diff] [blame] | 75 | openstack_actions, show_step): |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 76 | """Test restart ctl01 |
| 77 | |
| 78 | Scenario: |
| 79 | 1. Prepare salt on hosts |
| 80 | 2. Setup controller nodes |
| 81 | 3. Setup compute nodes |
| 82 | 4. Restart ctl01 |
| 83 | 5. Run tempest smoke after failover |
| 84 | |
| 85 | |
| 86 | """ |
| 87 | # STEP #1,2,3 |
| 88 | show_step(1) |
| 89 | show_step(2) |
| 90 | show_step(3) |
| 91 | |
| 92 | # STEP #4 |
| 93 | show_step(4) |
| 94 | openstack_actions.warm_restart_nodes('ctl01') |
| 95 | # STEP #5 |
| 96 | show_step(5) |
| 97 | openstack_actions.run_tempest(pattern='smoke') |
| 98 | |
| 99 | LOG.info("*************** DONE **************") |
| 100 | |
| 101 | @pytest.mark.grab_versions |
| 102 | @pytest.mark.fail_snapshot |
| 103 | def test_warm_shutdown_cmp01_node(self, underlay, openstack_deployed, |
| 104 | openstack_actions, show_step): |
| 105 | """Test warm shutdown cmp01 |
| 106 | |
| 107 | Scenario: |
| 108 | 1. Prepare salt on hosts |
| 109 | 2. Setup controller nodes |
| 110 | 3. Setup compute nodes |
| 111 | 4. Shutdown cmp01 |
| 112 | 5. Run tempest smoke after failover |
| 113 | |
| 114 | |
| 115 | """ |
| 116 | # STEP #1,2,3 |
| 117 | show_step(1) |
| 118 | show_step(2) |
| 119 | show_step(3) |
| 120 | |
| 121 | # STEP #4 |
| 122 | show_step(4) |
| 123 | openstack_actions.warm_shutdown_openstack_nodes('cmp01') |
| 124 | # STEP #5 |
| 125 | show_step(5) |
| 126 | openstack_actions.run_tempest(pattern='smoke') |
| 127 | |
| 128 | LOG.info("*************** DONE **************") |
| 129 | |
| 130 | @pytest.mark.grab_versions |
| 131 | @pytest.mark.fail_snapshot |
| 132 | def test_restart_cmp01_node(self, underlay, openstack_deployed, |
| 133 | openstack_actions, show_step): |
| 134 | """Test restart cmp01 |
| 135 | |
| 136 | Scenario: |
| 137 | 1. Prepare salt on hosts |
| 138 | 2. Setup controller nodes |
| 139 | 3. Setup compute nodes |
| 140 | 4. Restart cmp01 |
| 141 | 5. Run tempest smoke after failover |
| 142 | |
| 143 | |
| 144 | """ |
| 145 | # STEP #1,2,3 |
| 146 | show_step(1) |
| 147 | show_step(2) |
| 148 | show_step(3) |
| 149 | |
| 150 | # STEP #4 |
| 151 | show_step(4) |
| 152 | openstack_actions.warm_restart_nodes('cmp01') |
| 153 | # STEP #5 |
| 154 | show_step(5) |
| 155 | openstack_actions.run_tempest(pattern='smoke') |
| 156 | |
| 157 | LOG.info("*************** DONE **************") |
| 158 | |
| 159 | @pytest.mark.grab_versions |
| 160 | @pytest.mark.fail_snapshot |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 161 | @pytest.mark.revert_snapshot(ext.SNAPSHOT.sl_deployed) |
Dennis Dmitriev | 513fdf7 | 2017-11-30 12:22:25 +0200 | [diff] [blame] | 162 | def test_restart_mon01_node(self, openstack_actions, |
| 163 | sl_os_deployed, show_step): |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 164 | """Test restart mon01 |
| 165 | |
| 166 | Scenario: |
| 167 | 1. Prepare salt on hosts |
| 168 | 2. Setup controller nodes |
| 169 | 3. Setup compute, monitoring nodes |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 170 | 4. Check targets before restart |
| 171 | 5. Restart mon01 |
| 172 | 6. Check targets after restart |
Oleksii Butenko | 112ebdf | 2018-01-05 11:33:39 +0200 | [diff] [blame] | 173 | 7. Run LMA smoke after failover |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 174 | |
| 175 | |
| 176 | """ |
| 177 | # STEP #1,2,3 |
| 178 | show_step(1) |
| 179 | show_step(2) |
| 180 | show_step(3) |
| 181 | |
| 182 | # STEP #4 |
| 183 | show_step(4) |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 184 | mon_nodes = sl_os_deployed.get_monitoring_nodes() |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 185 | LOG.debug('Mon nodes list {0}'.format(mon_nodes)) |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 186 | sl_os_deployed.check_prometheus_targets(mon_nodes) |
| 187 | before_result = sl_os_deployed.run_sl_tests_json( |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 188 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 189 | 'tests/prometheus/', 'test_alerts.py') |
| 190 | failed_tests = [test['name'] for test in |
| 191 | before_result if 'passed' not in test['outcome']] |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 192 | # STEP #5 |
| 193 | show_step(5) |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 194 | openstack_actions.warm_restart_nodes('mon01') |
| 195 | # STEP #6 |
| 196 | show_step(6) |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 197 | sl_os_deployed.check_prometheus_targets(mon_nodes) |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 198 | # STEP #7 |
| 199 | show_step(7) |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 200 | # Run SL component tetsts |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 201 | after_result = sl_os_deployed.run_sl_tests_json( |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 202 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 203 | 'tests/prometheus/', 'test_alerts.py') |
| 204 | for test in after_result: |
| 205 | if test['name'] not in failed_tests: |
| 206 | assert 'passed' in test['outcome'], \ |
| 207 | 'Failed test {}'.format(test) |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 208 | LOG.info("*************** DONE **************") |
| 209 | |
| 210 | @pytest.mark.grab_versions |
| 211 | @pytest.mark.fail_snapshot |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 212 | @pytest.mark.revert_snapshot(ext.SNAPSHOT.sl_deployed) |
| 213 | def test_warm_shutdown_mon01_node(self, openstack_actions, |
| 214 | sl_os_deployed, |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 215 | show_step): |
| 216 | """Test warm shutdown mon01 |
| 217 | |
| 218 | Scenario: |
| 219 | 1. Prepare salt on hosts |
| 220 | 2. Setup controller nodes |
| 221 | 3. Setup compute, monitoring nodes |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 222 | 4. Check LMA before mon node shutdown |
| 223 | 5. Shutdown mon01 node |
| 224 | 6. Run LMA tests after failover |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 225 | |
| 226 | |
| 227 | """ |
| 228 | # STEP #1,2,3 |
| 229 | show_step(1) |
| 230 | show_step(2) |
| 231 | show_step(3) |
| 232 | |
| 233 | # STEP #4 |
| 234 | show_step(4) |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 235 | mon_nodes = sl_os_deployed.get_monitoring_nodes() |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 236 | LOG.debug('Mon nodes list {0}'.format(mon_nodes)) |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 237 | sl_os_deployed.check_prometheus_targets(mon_nodes) |
| 238 | before_result = sl_os_deployed.run_sl_tests_json( |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 239 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 240 | 'tests/prometheus/', 'test_alerts.py') |
| 241 | failed_tests = [test['name'] for test in |
| 242 | before_result if 'passed' not in test['outcome']] |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 243 | # STEP #5 |
| 244 | show_step(5) |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 245 | openstack_actions.warm_shutdown_openstack_nodes('mon01') |
| 246 | # STEP #6 |
| 247 | show_step(6) |
| 248 | # Run SL component tetsts |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 249 | after_result = sl_os_deployed.run_sl_tests_json( |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 250 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 251 | 'tests/prometheus/', 'test_alerts.py') |
| 252 | for test in after_result: |
| 253 | if test['name'] not in failed_tests: |
| 254 | assert 'passed' in test['outcome'], \ |
| 255 | 'Failed test {}'.format(test) |
| 256 | LOG.info("*************** DONE **************") |
| 257 | |
| 258 | @pytest.mark.grab_versions |
| 259 | @pytest.mark.fail_snapshot |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 260 | @pytest.mark.revert_snapshot(ext.SNAPSHOT.sl_deployed) |
| 261 | def test_kill_influxdb_relay_mon01_node(self, sl_os_deployed, |
| 262 | show_step): |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 263 | """Test kill influxdb relay on mon01 node |
| 264 | |
| 265 | Scenario: |
| 266 | 1. Prepare salt on hosts |
| 267 | 2. Setup controller nodes |
| 268 | 3. Setup compute, monitoring nodes |
| 269 | 4. Check LMA before mon node shutdown |
| 270 | 5. Kill influxdb relay on mon01 node |
| 271 | 6. Post data into influx |
| 272 | 7. Get data from all healthy nodes |
| 273 | 8. Start influx db |
| 274 | 9. Request data on mon01 |
| 275 | 10. Run LMA tests after fail and compare with result before fail |
| 276 | |
| 277 | |
| 278 | """ |
| 279 | # STEP #1,2,3 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 280 | show_step(1) |
| 281 | show_step(2) |
| 282 | show_step(3) |
| 283 | |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 284 | # STEP #4 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 285 | show_step(4) |
| 286 | mon_nodes = sl_os_deployed.get_monitoring_nodes() |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 287 | LOG.debug('Mon nodes list {0}'.format(mon_nodes)) |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 288 | before_result = sl_os_deployed.run_sl_tests_json( |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 289 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 290 | 'tests/prometheus/', 'test_alerts.py') |
| 291 | failed_tests = [test['name'] for test in |
| 292 | before_result if 'passed' not in test['outcome']] |
Dennis Dmitriev | 8ce8515 | 2017-11-29 00:05:12 +0200 | [diff] [blame] | 293 | |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 294 | # STEP #5 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 295 | show_step(5) |
| 296 | sl_os_deployed.kill_sl_service_on_node('mon01', 'influxdb-relay') |
Dennis Dmitriev | 8ce8515 | 2017-11-29 00:05:12 +0200 | [diff] [blame] | 297 | |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 298 | # STEP #6 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 299 | show_step(6) |
| 300 | sl_os_deployed.post_data_into_influx('mon02') |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 301 | |
Dennis Dmitriev | 8ce8515 | 2017-11-29 00:05:12 +0200 | [diff] [blame] | 302 | # STEP #7 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 303 | show_step(7) |
| 304 | assert 'mymeas' in sl_os_deployed.check_data_in_influxdb('mon02') |
| 305 | assert 'mymeas' in sl_os_deployed.check_data_in_influxdb('mon03') |
Dennis Dmitriev | 8ce8515 | 2017-11-29 00:05:12 +0200 | [diff] [blame] | 306 | |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 307 | # STEP #8 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 308 | show_step(8) |
| 309 | sl_os_deployed.start_service('mon01', 'influxdb-relay') |
Dennis Dmitriev | 8ce8515 | 2017-11-29 00:05:12 +0200 | [diff] [blame] | 310 | |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 311 | # STEP #9 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 312 | show_step(9) |
| 313 | assert 'mymeas' in sl_os_deployed.check_data_in_influxdb('mon01') |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 314 | |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 315 | # STEP #10 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 316 | show_step(10) |
| 317 | after_result = sl_os_deployed.run_sl_tests_json( |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 318 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 319 | 'tests/prometheus/', 'test_alerts.py') |
| 320 | for test in after_result: |
| 321 | if test['name'] not in failed_tests: |
| 322 | assert 'passed' in test['outcome'], \ |
| 323 | 'Failed test {}'.format(test) |
| 324 | LOG.info("*************** DONE **************") |
| 325 | |
| 326 | @pytest.mark.grab_versions |
| 327 | @pytest.mark.fail_snapshot |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 328 | @pytest.mark.revert_snapshot(ext.SNAPSHOT.sl_deployed) |
| 329 | def test_kill_influxdb_mon01_node(self, sl_os_deployed, show_step): |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 330 | """Test kill influxdb on mon01 node |
| 331 | |
| 332 | Scenario: |
| 333 | 1. Prepare salt on hosts |
| 334 | 2. Setup controller nodes |
| 335 | 3. Setup compute, monitoring nodes |
| 336 | 4. Check LMA before mon node shutdown |
| 337 | 5. Kill influxdb on mon01 node |
| 338 | 6. Post data into influx |
| 339 | 7. Get data from all healthy nodes |
| 340 | 8. Start influx db |
| 341 | 9. Request data on mon01 |
| 342 | 10. Run LMA tests after fail and compare with result before fail |
| 343 | |
| 344 | |
| 345 | """ |
| 346 | # STEP #1,2,3 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 347 | show_step(1) |
| 348 | show_step(2) |
| 349 | show_step(3) |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 350 | |
| 351 | # STEP #4 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 352 | show_step(4) |
| 353 | mon_nodes = sl_os_deployed.get_monitoring_nodes() |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 354 | LOG.debug('Mon nodes list {0}'.format(mon_nodes)) |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 355 | before_result = sl_os_deployed.run_sl_tests_json( |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 356 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 357 | 'tests/prometheus/', 'test_alerts.py') |
| 358 | failed_tests = [test['name'] for test in |
| 359 | before_result if 'passed' not in test['outcome']] |
| 360 | # STEP #5 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 361 | show_step(5) |
| 362 | sl_os_deployed.kill_sl_service_on_node('mon01', 'influxd') |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 363 | |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 364 | # STEP #6 |
| 365 | show_step(6) |
| 366 | sl_os_deployed.post_data_into_influx('mon02') |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 367 | |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 368 | # STEP #7 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 369 | show_step(7) |
| 370 | assert 'mymeas' in sl_os_deployed.check_data_in_influxdb('mon02') |
| 371 | assert 'mymeas' in sl_os_deployed.check_data_in_influxdb('mon03') |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 372 | |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 373 | # STEP #8 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 374 | show_step(8) |
| 375 | sl_os_deployed.start_service('mon01', 'influxd') |
Dennis Dmitriev | 8ce8515 | 2017-11-29 00:05:12 +0200 | [diff] [blame] | 376 | |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 377 | # STEP #9 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 378 | show_step(9) |
| 379 | self.check_influxdb_xfail(sl_os_deployed, 'mon01', 'mymeas') |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 380 | |
Dennis Dmitriev | 28fd049 | 2017-11-29 13:33:21 +0200 | [diff] [blame] | 381 | # STEP #10 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 382 | show_step(10) |
| 383 | after_result = sl_os_deployed.run_sl_tests_json( |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 384 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 385 | 'tests/prometheus/', 'test_alerts.py') |
| 386 | for test in after_result: |
| 387 | if test['name'] not in failed_tests: |
| 388 | assert 'passed' in test['outcome'], \ |
| 389 | 'Failed test {}'.format(test) |
| 390 | LOG.info("*************** DONE **************") |
| 391 | |
| 392 | @pytest.mark.grab_versions |
| 393 | @pytest.mark.fail_snapshot |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 394 | @pytest.mark.revert_snapshot(ext.SNAPSHOT.sl_deployed) |
| 395 | def test_stop_influxdb_relay_mon_nodes(self, sl_os_deployed, |
| 396 | show_step): |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 397 | """Test stop influxdb relay on mon01 node |
| 398 | |
| 399 | Scenario: |
| 400 | 1. Prepare salt on hosts |
| 401 | 2. Setup controller nodes |
| 402 | 3. Setup compute, monitoring nodes |
| 403 | 4. Check LMA before mon node shutdown |
| 404 | 5. Stop influxdb relay on mon01 and mon02 nodes |
| 405 | 6. Post data into influx |
| 406 | 7. Get data from all healthy nodes |
| 407 | 8. Start influx db |
| 408 | 9. Request data on mon01, 02 |
| 409 | 10. Run LMA tests after fail and compare with result before fail |
| 410 | |
| 411 | |
| 412 | """ |
| 413 | # STEP #1,2,3 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 414 | show_step(1) |
| 415 | show_step(2) |
| 416 | show_step(3) |
| 417 | |
| 418 | # STEP #4 |
| 419 | show_step(4) |
| 420 | mon_nodes = sl_os_deployed.get_monitoring_nodes() |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 421 | LOG.debug('Mon nodes list {0}'.format(mon_nodes)) |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 422 | before_result = sl_os_deployed.run_sl_tests_json( |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 423 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 424 | 'tests/prometheus/', 'test_alerts.py') |
| 425 | failed_tests = [test['name'] for test in |
| 426 | before_result if 'passed' not in test['outcome']] |
| 427 | # STEP #5 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 428 | show_step(5) |
| 429 | sl_os_deployed.stop_sl_service_on_node('mon01', 'influxdb-relay') |
| 430 | sl_os_deployed.stop_sl_service_on_node('mon02', 'influxdb-relay') |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 431 | |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 432 | # STEP #6 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 433 | show_step(6) |
| 434 | sl_os_deployed.post_data_into_influx('mon03') |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 435 | |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 436 | # STEP #7 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 437 | show_step(7) |
| 438 | assert 'mymeas' in sl_os_deployed.check_data_in_influxdb('mon03') |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 439 | |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 440 | # STEP #8 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 441 | show_step(8) |
| 442 | sl_os_deployed.start_service('mon01', 'influxdb-relay') |
| 443 | sl_os_deployed.start_service('mon02', 'influxdb-relay') |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 444 | |
Dennis Dmitriev | 8ce8515 | 2017-11-29 00:05:12 +0200 | [diff] [blame] | 445 | # STEP #9 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 446 | show_step(9) |
| 447 | assert 'mymeas' in sl_os_deployed.check_data_in_influxdb('mon01') |
| 448 | assert 'mymeas' in sl_os_deployed.check_data_in_influxdb('mon02') |
Dennis Dmitriev | 8ce8515 | 2017-11-29 00:05:12 +0200 | [diff] [blame] | 449 | |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 450 | # STEP #10 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 451 | show_step(10) |
| 452 | after_result = sl_os_deployed.run_sl_tests_json( |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 453 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 454 | 'tests/prometheus/', 'test_alerts.py') |
| 455 | for test in after_result: |
| 456 | if test['name'] not in failed_tests: |
| 457 | assert 'passed' in test['outcome'], \ |
| 458 | 'Failed test {}'.format(test) |
| 459 | LOG.info("*************** DONE **************") |
| 460 | |
| 461 | @pytest.mark.grab_versions |
| 462 | @pytest.mark.fail_snapshot |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 463 | @pytest.mark.revert_snapshot(ext.SNAPSHOT.sl_deployed) |
| 464 | def test_stop_influxdb_mon_nodes(self, sl_os_deployed, show_step): |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 465 | """Test stop influxdb on mon01 node |
| 466 | |
| 467 | Scenario: |
| 468 | 1. Prepare salt on hosts |
| 469 | 2. Setup controller nodes |
| 470 | 3. Setup compute, monitoring nodes |
| 471 | 4. Check LMA before mon node shutdown |
| 472 | 5. Stop influxdb on mon01 and mon02 node |
| 473 | 6. Post data into influx |
| 474 | 7. Get data from all healthy nodes |
| 475 | 8. Start influx db |
| 476 | 9. Request data on mon01 |
| 477 | 10. Run LMA tests after fail and compare with result before fail |
| 478 | |
| 479 | |
| 480 | """ |
| 481 | # STEP #1,2,3 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 482 | show_step(1) |
| 483 | show_step(2) |
| 484 | show_step(3) |
| 485 | |
| 486 | # STEP #4 |
| 487 | show_step(4) |
| 488 | mon_nodes = sl_os_deployed.get_monitoring_nodes() |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 489 | LOG.debug('Mon nodes list {0}'.format(mon_nodes)) |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 490 | before_result = sl_os_deployed.run_sl_tests_json( |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 491 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 492 | 'tests/prometheus/', 'test_alerts.py') |
| 493 | failed_tests = [test['name'] for test in |
| 494 | before_result if 'passed' not in test['outcome']] |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 495 | |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 496 | # STEP #5 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 497 | show_step(5) |
| 498 | sl_os_deployed.stop_sl_service_on_node('mon01', 'influxdb') |
| 499 | sl_os_deployed.stop_sl_service_on_node('mon02', 'influxdb') |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 500 | |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 501 | # STEP #6 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 502 | show_step(6) |
| 503 | sl_os_deployed.post_data_into_influx('mon03') |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 504 | |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 505 | # STEP #7 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 506 | show_step(7) |
| 507 | assert 'mymeas' in sl_os_deployed.check_data_in_influxdb('mon03') |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 508 | |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 509 | # STEP #8 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 510 | show_step(8) |
| 511 | sl_os_deployed.start_service('mon01', 'influxdb') |
| 512 | sl_os_deployed.start_service('mon02', 'influxdb') |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 513 | |
Dennis Dmitriev | 8ce8515 | 2017-11-29 00:05:12 +0200 | [diff] [blame] | 514 | # STEP #9 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 515 | show_step(9) |
| 516 | self.check_influxdb_xfail(sl_os_deployed, 'mon01', 'mymeas') |
| 517 | self.check_influxdb_xfail(sl_os_deployed, 'mon02', 'mymeas') |
Dennis Dmitriev | 8ce8515 | 2017-11-29 00:05:12 +0200 | [diff] [blame] | 518 | |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 519 | # STEP #10 |
Dennis Dmitriev | 17b9a9e | 2017-11-29 15:04:28 +0200 | [diff] [blame] | 520 | show_step(10) |
| 521 | after_result = sl_os_deployed.run_sl_tests_json( |
Tatyana Leontovich | a6c64a7 | 2017-10-25 22:21:18 +0300 | [diff] [blame] | 522 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 523 | 'tests/prometheus/', 'test_alerts.py') |
| 524 | for test in after_result: |
| 525 | if test['name'] not in failed_tests: |
| 526 | assert 'passed' in test['outcome'], \ |
| 527 | 'Failed test {}'.format(test) |
Tatyana Leontovich | e5ccdb3 | 2017-10-09 20:10:43 +0300 | [diff] [blame] | 528 | LOG.info("*************** DONE **************") |
Oleksii Butenko | 112ebdf | 2018-01-05 11:33:39 +0200 | [diff] [blame] | 529 | |
| 530 | @pytest.mark.grab_versions |
| 531 | @pytest.mark.fail_snapshot |
| 532 | @pytest.mark.revert_snapshot(ext.SNAPSHOT.sl_deployed) |
| 533 | def test_restart_mon_with_vip(self, sl_os_deployed, |
| 534 | openstack_actions, salt_actions, |
| 535 | common_services_actions, show_step): |
| 536 | """Test restart mon with VIP |
| 537 | |
| 538 | Scenario: |
| 539 | 1. Prepare salt on hosts |
| 540 | 2. Setup controller nodes |
| 541 | 3. Setup compute and monitoring nodes |
| 542 | 4. Check LMA before mon node restart |
| 543 | 5. Find mon minion id with VIP |
| 544 | 6. Restart mon minion id with VIP |
| 545 | 7. Check that VIP was actually migrated on a new node |
| 546 | 8. Run tempest smoke after failover |
| 547 | |
| 548 | |
| 549 | """ |
| 550 | # TR case #4753939 |
| 551 | common_services_actions.check_keepalived_pillar() |
| 552 | salt = salt_actions |
| 553 | |
| 554 | # STEP #1,2,3 |
| 555 | show_step(1) |
| 556 | show_step(2) |
| 557 | show_step(3) |
| 558 | |
| 559 | # STEP #4 |
| 560 | show_step(4) |
| 561 | mon_nodes = sl_os_deployed.get_monitoring_nodes() |
| 562 | LOG.debug('Mon nodes list {0}'.format(mon_nodes)) |
| 563 | before_result = sl_os_deployed.run_sl_tests_json( |
| 564 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 565 | 'tests/prometheus/', 'test_alerts.py') |
| 566 | failed_tests = [test['name'] for test in |
| 567 | before_result if 'passed' not in test['outcome']] |
| 568 | |
| 569 | # STEP #5 |
| 570 | show_step(5) |
| 571 | mon_vip_pillar = salt.get_pillar( |
| 572 | tgt="mon0*", |
| 573 | pillar="_param:cluster_vip_address")[0] |
| 574 | vip = [vip for minion_id, vip in mon_vip_pillar.items()][0] |
| 575 | minion_vip = common_services_actions.get_keepalived_vip_minion_id(vip) |
| 576 | LOG.info("VIP {0} is on {1}".format(vip, minion_vip)) |
| 577 | |
| 578 | # STEP #6 |
| 579 | show_step(6) |
| 580 | openstack_actions.warm_restart_nodes(minion_vip) |
| 581 | |
| 582 | # STEP #7 |
| 583 | show_step(7) |
| 584 | # Check that VIP has been actually migrated to a new node |
| 585 | new_minion_vip = common_services_actions.get_keepalived_vip_minion_id( |
| 586 | vip) |
| 587 | LOG.info("Migrated VIP {0} is on {1}".format(vip, new_minion_vip)) |
| 588 | assert new_minion_vip != minion_vip, ( |
| 589 | "VIP {0} wasn't migrated from {1} after node reboot!" |
| 590 | .format(vip, new_minion_vip)) |
| 591 | common_services_actions.check_keepalived_pillar() |
| 592 | |
| 593 | # STEP #8 |
| 594 | show_step(8) |
| 595 | # Run SL component tetsts |
| 596 | after_result = sl_os_deployed.run_sl_tests_json( |
| 597 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
| 598 | 'tests/prometheus/', 'test_alerts.py') |
| 599 | for test in after_result: |
| 600 | if test['name'] not in failed_tests: |
| 601 | assert 'passed' in test['outcome'], \ |
| 602 | 'Failed test {}'.format(test) |
| 603 | LOG.info("*************** DONE **************") |