Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [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. |
| 14 | import pytest |
| 15 | |
| 16 | from tcp_tests import logger |
| 17 | from tcp_tests.helpers import ext |
| 18 | |
| 19 | LOG = logger.logger |
| 20 | |
| 21 | |
| 22 | class TestFailoverNodes(object): |
| 23 | """Test class for testing OpenStack nodes failover""" |
| 24 | |
| 25 | @pytest.mark.grab_versions |
| 26 | @pytest.mark.fail_snapshot |
Vladimir Jigulin | ee1faa5 | 2018-06-25 13:00:51 +0400 | [diff] [blame] | 27 | def test_warm_shutdown_ctl01_node(self, underlay, hardware, show_step, |
| 28 | openstack_deployed, openstack_actions): |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 29 | """Test warm shutdown ctl01 |
| 30 | |
| 31 | Scenario: |
| 32 | 1. Prepare salt on hosts |
| 33 | 2. Setup controller nodes |
| 34 | 3. Setup compute nodes |
| 35 | 4. Shutdown ctl01 |
| 36 | 5. Run tempest smoke after failover |
| 37 | |
| 38 | |
| 39 | """ |
| 40 | # STEP #1,2,3 |
| 41 | show_step(1) |
| 42 | show_step(2) |
| 43 | show_step(3) |
| 44 | # STEP #4 |
| 45 | show_step(4) |
Vladimir Jigulin | ee1faa5 | 2018-06-25 13:00:51 +0400 | [diff] [blame] | 46 | hardware.warm_shutdown_nodes(underlay, 'ctl01') |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 47 | # STEP #5 |
| 48 | show_step(5) |
| 49 | openstack_actions.run_tempest(pattern='smoke') |
| 50 | |
| 51 | LOG.info("*************** DONE **************") |
| 52 | |
| 53 | @pytest.mark.grab_versions |
| 54 | @pytest.mark.fail_snapshot |
Vladimir Jigulin | ee1faa5 | 2018-06-25 13:00:51 +0400 | [diff] [blame] | 55 | def test_restart_ctl01_node(self, underlay, hardware, openstack_deployed, |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 56 | openstack_actions, show_step): |
| 57 | """Test restart ctl01 |
| 58 | |
| 59 | Scenario: |
| 60 | 1. Prepare salt on hosts |
| 61 | 2. Setup controller nodes |
| 62 | 3. Setup compute nodes |
| 63 | 4. Restart ctl01 |
| 64 | 5. Run tempest smoke after failover |
| 65 | |
| 66 | |
| 67 | """ |
| 68 | # STEP #1,2,3 |
| 69 | show_step(1) |
| 70 | show_step(2) |
| 71 | show_step(3) |
| 72 | |
| 73 | # STEP #4 |
| 74 | show_step(4) |
Vladimir Jigulin | ee1faa5 | 2018-06-25 13:00:51 +0400 | [diff] [blame] | 75 | hardware.warm_restart_nodes(underlay, 'ctl01') |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 76 | # STEP #5 |
| 77 | show_step(5) |
| 78 | openstack_actions.run_tempest(pattern='smoke') |
| 79 | |
| 80 | LOG.info("*************** DONE **************") |
| 81 | |
| 82 | @pytest.mark.grab_versions |
| 83 | @pytest.mark.fail_snapshot |
| 84 | def test_warm_shutdown_cmp01_node(self, underlay, openstack_deployed, |
Vladimir Jigulin | ee1faa5 | 2018-06-25 13:00:51 +0400 | [diff] [blame] | 85 | hardware, openstack_actions, show_step): |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 86 | """Test warm shutdown cmp01 |
| 87 | |
| 88 | Scenario: |
| 89 | 1. Prepare salt on hosts |
| 90 | 2. Setup controller nodes |
| 91 | 3. Setup compute nodes |
| 92 | 4. Shutdown cmp01 |
| 93 | 5. Run tempest smoke after failover |
| 94 | |
| 95 | |
| 96 | """ |
| 97 | # STEP #1,2,3 |
| 98 | show_step(1) |
| 99 | show_step(2) |
| 100 | show_step(3) |
| 101 | |
| 102 | # STEP #4 |
| 103 | show_step(4) |
Vladimir Jigulin | ee1faa5 | 2018-06-25 13:00:51 +0400 | [diff] [blame] | 104 | hardware.warm_shutdown_nodes(underlay, 'cmp01') |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 105 | # STEP #5 |
| 106 | show_step(5) |
| 107 | openstack_actions.run_tempest(pattern='smoke') |
| 108 | |
| 109 | LOG.info("*************** DONE **************") |
| 110 | |
| 111 | @pytest.mark.grab_versions |
| 112 | @pytest.mark.fail_snapshot |
| 113 | def test_restart_cmp01_node(self, underlay, openstack_deployed, |
Vladimir Jigulin | ee1faa5 | 2018-06-25 13:00:51 +0400 | [diff] [blame] | 114 | openstack_actions, show_step, hardware): |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 115 | """Test restart cmp01 |
| 116 | |
| 117 | Scenario: |
| 118 | 1. Prepare salt on hosts |
| 119 | 2. Setup controller nodes |
| 120 | 3. Setup compute nodes |
| 121 | 4. Restart cmp01 |
| 122 | 5. Run tempest smoke after failover |
| 123 | |
| 124 | |
| 125 | """ |
| 126 | # STEP #1,2,3 |
| 127 | show_step(1) |
| 128 | show_step(2) |
| 129 | show_step(3) |
| 130 | |
| 131 | # STEP #4 |
| 132 | show_step(4) |
Vladimir Jigulin | ee1faa5 | 2018-06-25 13:00:51 +0400 | [diff] [blame] | 133 | hardware.warm_restart_nodes(underlay, 'cmp01') |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 134 | # STEP #5 |
| 135 | show_step(5) |
| 136 | openstack_actions.run_tempest(pattern='smoke') |
| 137 | |
| 138 | LOG.info("*************** DONE **************") |
| 139 | |
| 140 | @pytest.mark.grab_versions |
| 141 | @pytest.mark.fail_snapshot |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 142 | @pytest.mark.revert_snapshot(ext.SNAPSHOT.stacklight_deployed) |
Vladimir Jigulin | ee1faa5 | 2018-06-25 13:00:51 +0400 | [diff] [blame] | 143 | def test_restart_mon01_node(self, openstack_actions, hardware, underlay, |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 144 | sl_os_deployed, show_step): |
| 145 | """Test restart mon01 |
| 146 | |
| 147 | Scenario: |
| 148 | 1. Prepare salt on hosts |
| 149 | 2. Setup controller nodes |
| 150 | 3. Setup compute, monitoring nodes |
| 151 | 4. Check targets before restart |
| 152 | 5. Restart mon01 |
| 153 | 6. Check targets after restart |
| 154 | 7. Run LMA smoke after failover |
| 155 | |
| 156 | |
| 157 | """ |
| 158 | # STEP #1,2,3 |
| 159 | show_step(1) |
| 160 | show_step(2) |
| 161 | show_step(3) |
| 162 | |
| 163 | # STEP #4 |
| 164 | show_step(4) |
| 165 | mon_nodes = sl_os_deployed.get_monitoring_nodes() |
| 166 | LOG.debug('Mon nodes list {0}'.format(mon_nodes)) |
| 167 | sl_os_deployed.check_prometheus_targets(mon_nodes) |
| 168 | before_result = sl_os_deployed.run_sl_tests_json( |
| 169 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
vitalygusev | 0e57ef6 | 2018-11-30 12:13:56 +0400 | [diff] [blame] | 170 | 'tests/', 'test_alerts.py') |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 171 | failed_tests = [test['name'] for test in |
| 172 | before_result if 'passed' not in test['outcome']] |
| 173 | # STEP #5 |
| 174 | show_step(5) |
Vladimir Jigulin | ee1faa5 | 2018-06-25 13:00:51 +0400 | [diff] [blame] | 175 | hardware.warm_restart_nodes(underlay, 'mon01') |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 176 | # STEP #6 |
| 177 | show_step(6) |
| 178 | sl_os_deployed.check_prometheus_targets(mon_nodes) |
| 179 | # STEP #7 |
| 180 | show_step(7) |
| 181 | # Run SL component tetsts |
| 182 | after_result = sl_os_deployed.run_sl_tests_json( |
| 183 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
vitalygusev | 0e57ef6 | 2018-11-30 12:13:56 +0400 | [diff] [blame] | 184 | 'tests/', 'test_alerts.py') |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 185 | for test in after_result: |
| 186 | if test['name'] not in failed_tests: |
| 187 | assert 'passed' in test['outcome'], \ |
| 188 | 'Failed test {}'.format(test) |
| 189 | LOG.info("*************** DONE **************") |
| 190 | |
| 191 | @pytest.mark.grab_versions |
| 192 | @pytest.mark.fail_snapshot |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 193 | @pytest.mark.revert_snapshot(ext.SNAPSHOT.stacklight_deployed) |
Vladimir Jigulin | ee1faa5 | 2018-06-25 13:00:51 +0400 | [diff] [blame] | 194 | def test_warm_shutdown_mon01_node(self, underlay, hardware, sl_os_deployed, |
| 195 | openstack_actions, show_step): |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 196 | """Test warm shutdown mon01 |
| 197 | |
| 198 | Scenario: |
| 199 | 1. Prepare salt on hosts |
| 200 | 2. Setup controller nodes |
| 201 | 3. Setup compute, monitoring nodes |
| 202 | 4. Check LMA before mon node shutdown |
| 203 | 5. Shutdown mon01 node |
| 204 | 6. Run LMA tests after failover |
| 205 | |
| 206 | |
| 207 | """ |
| 208 | # STEP #1,2,3 |
| 209 | show_step(1) |
| 210 | show_step(2) |
| 211 | show_step(3) |
| 212 | |
| 213 | # STEP #4 |
| 214 | show_step(4) |
| 215 | mon_nodes = sl_os_deployed.get_monitoring_nodes() |
| 216 | LOG.debug('Mon nodes list {0}'.format(mon_nodes)) |
| 217 | sl_os_deployed.check_prometheus_targets(mon_nodes) |
| 218 | before_result = sl_os_deployed.run_sl_tests_json( |
| 219 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
vitalygusev | 0e57ef6 | 2018-11-30 12:13:56 +0400 | [diff] [blame] | 220 | 'tests/', 'test_alerts.py') |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 221 | failed_tests = [test['name'] for test in |
| 222 | before_result if 'passed' not in test['outcome']] |
| 223 | # STEP #5 |
| 224 | show_step(5) |
Vladimir Jigulin | ee1faa5 | 2018-06-25 13:00:51 +0400 | [diff] [blame] | 225 | hardware.warm_shutdown_nodes(underlay, 'mon01') |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 226 | # STEP #6 |
| 227 | show_step(6) |
| 228 | # Run SL component tetsts |
| 229 | after_result = sl_os_deployed.run_sl_tests_json( |
| 230 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
vitalygusev | 0e57ef6 | 2018-11-30 12:13:56 +0400 | [diff] [blame] | 231 | 'tests/', 'test_alerts.py') |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 232 | for test in after_result: |
| 233 | if test['name'] not in failed_tests: |
| 234 | assert 'passed' in test['outcome'], \ |
| 235 | 'Failed test {}'.format(test) |
| 236 | LOG.info("*************** DONE **************") |
| 237 | |
| 238 | @pytest.mark.grab_versions |
| 239 | @pytest.mark.fail_snapshot |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 240 | @pytest.mark.revert_snapshot(ext.SNAPSHOT.stacklight_deployed) |
Vladimir Jigulin | ee1faa5 | 2018-06-25 13:00:51 +0400 | [diff] [blame] | 241 | def test_restart_mon_with_vip(self, underlay, hardware, sl_os_deployed, |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 242 | openstack_actions, salt_actions, |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 243 | core_actions, show_step): |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 244 | """Test restart mon with VIP |
| 245 | |
| 246 | Scenario: |
| 247 | 1. Prepare salt on hosts |
| 248 | 2. Setup controller nodes |
| 249 | 3. Setup compute and monitoring nodes |
| 250 | 4. Check LMA before mon node restart |
| 251 | 5. Find mon minion id with VIP |
| 252 | 6. Restart mon minion id with VIP |
| 253 | 7. Check that VIP was actually migrated on a new node |
| 254 | 8. Run tempest smoke after failover |
| 255 | |
| 256 | |
| 257 | """ |
| 258 | # TR case #4753939 |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 259 | core_actions.check_keepalived_pillar() |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 260 | salt = salt_actions |
| 261 | |
| 262 | # STEP #1,2,3 |
| 263 | show_step(1) |
| 264 | show_step(2) |
| 265 | show_step(3) |
| 266 | |
| 267 | # STEP #4 |
| 268 | show_step(4) |
| 269 | mon_nodes = sl_os_deployed.get_monitoring_nodes() |
| 270 | LOG.debug('Mon nodes list {0}'.format(mon_nodes)) |
| 271 | before_result = sl_os_deployed.run_sl_tests_json( |
| 272 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
vitalygusev | 0e57ef6 | 2018-11-30 12:13:56 +0400 | [diff] [blame] | 273 | 'tests/', 'test_alerts.py') |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 274 | failed_tests = [test['name'] for test in |
| 275 | before_result if 'passed' not in test['outcome']] |
| 276 | |
| 277 | # STEP #5 |
| 278 | show_step(5) |
| 279 | mon_vip_pillar = salt.get_pillar( |
| 280 | tgt="mon0*", |
| 281 | pillar="_param:cluster_vip_address")[0] |
| 282 | vip = [vip for minion_id, vip in mon_vip_pillar.items()][0] |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 283 | minion_vip = core_actions.get_keepalived_vip_minion_id(vip) |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 284 | LOG.info("VIP {0} is on {1}".format(vip, minion_vip)) |
| 285 | |
| 286 | # STEP #6 |
| 287 | show_step(6) |
Vladimir Jigulin | ee1faa5 | 2018-06-25 13:00:51 +0400 | [diff] [blame] | 288 | hardware.warm_restart_nodes(underlay, minion_vip) |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 289 | |
| 290 | # STEP #7 |
| 291 | show_step(7) |
| 292 | # Check that VIP has been actually migrated to a new node |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 293 | new_minion_vip = core_actions.get_keepalived_vip_minion_id( |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 294 | vip) |
| 295 | LOG.info("Migrated VIP {0} is on {1}".format(vip, new_minion_vip)) |
| 296 | assert new_minion_vip != minion_vip, ( |
| 297 | "VIP {0} wasn't migrated from {1} after node reboot!" |
| 298 | .format(vip, new_minion_vip)) |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 299 | core_actions.check_keepalived_pillar() |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 300 | |
| 301 | # STEP #8 |
| 302 | show_step(8) |
| 303 | # Run SL component tetsts |
| 304 | after_result = sl_os_deployed.run_sl_tests_json( |
| 305 | 'cfg01', '/root/stacklight-pytest/stacklight_tests/', |
vitalygusev | 0e57ef6 | 2018-11-30 12:13:56 +0400 | [diff] [blame] | 306 | 'tests/', 'test_alerts.py') |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 307 | for test in after_result: |
| 308 | if test['name'] not in failed_tests: |
| 309 | assert 'passed' in test['outcome'], \ |
| 310 | 'Failed test {}'.format(test) |
| 311 | LOG.info("*************** DONE **************") |
| 312 | |
| 313 | @pytest.mark.grab_versions |
| 314 | @pytest.mark.fail_snapshot |
| 315 | @pytest.mark.revert_snapshot(ext.SNAPSHOT.openstack_deployed) |
Vladimir Jigulin | ee1faa5 | 2018-06-25 13:00:51 +0400 | [diff] [blame] | 316 | def test_restart_ctl_with_vip(self, underlay, hardware, openstack_deployed, |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 317 | openstack_actions, salt_actions, |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 318 | core_actions, show_step): |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 319 | """Test restart clt with VIP |
| 320 | |
| 321 | Scenario: |
| 322 | 1. Prepare salt on hosts |
| 323 | 2. Setup controller nodes |
| 324 | 3. Setup compute nodes |
| 325 | 4. Find controller minion id with VIP |
| 326 | 5. Restart controller minion id with VIP |
| 327 | 6. Check that VIP was actually migrated on a new node |
| 328 | 7. Run tempest smoke after failover |
| 329 | |
| 330 | |
| 331 | """ |
| 332 | # TR case #3385671 |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 333 | core_actions.check_keepalived_pillar() |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 334 | salt = salt_actions |
| 335 | |
| 336 | # STEP #1,2,3 |
| 337 | show_step(1) |
| 338 | show_step(2) |
| 339 | show_step(3) |
| 340 | |
| 341 | # STEP #4 |
| 342 | show_step(4) |
| 343 | ctl_vip_pillar = salt.get_pillar( |
| 344 | tgt="I@nova:controller:enabled:True", |
| 345 | pillar="_param:cluster_vip_address")[0] |
| 346 | vip = [vip for minion_id, vip in ctl_vip_pillar.items()][0] |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 347 | minion_vip = core_actions.get_keepalived_vip_minion_id(vip) |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 348 | LOG.info("VIP {0} is on {1}".format(vip, minion_vip)) |
| 349 | |
| 350 | # STEP #5 |
| 351 | show_step(5) |
Vladimir Jigulin | ee1faa5 | 2018-06-25 13:00:51 +0400 | [diff] [blame] | 352 | hardware.warm_restart_nodes(underlay, minion_vip) |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 353 | |
| 354 | # STEP #6 |
| 355 | show_step(6) |
| 356 | # Check that VIP has been actually migrated to a new node |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 357 | new_minion_vip = core_actions.get_keepalived_vip_minion_id( |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 358 | vip) |
| 359 | LOG.info("Migrated VIP {0} is on {1}".format(vip, new_minion_vip)) |
| 360 | assert new_minion_vip != minion_vip, ( |
| 361 | "VIP {0} wasn't migrated from {1} after node reboot!" |
| 362 | .format(vip, new_minion_vip)) |
Dennis Dmitriev | ea48cf5 | 2018-07-18 18:04:39 +0300 | [diff] [blame] | 363 | core_actions.check_keepalived_pillar() |
Dennis Dmitriev | 759baa1 | 2018-03-14 01:50:53 +0200 | [diff] [blame] | 364 | |
| 365 | # STEP #7 |
| 366 | show_step(7) |
| 367 | openstack_actions.run_tempest(pattern='smoke') |
| 368 | |
| 369 | LOG.info("*************** DONE **************") |