Genadi Chereshnya | 57173bd | 2017-01-10 11:17:07 +0200 | [diff] [blame^] | 1 | # Copyright 2017 Red Hat, Inc. |
| 2 | # All Rights Reserved. |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 5 | # not use this file except in compliance with the License. You may obtain |
| 6 | # a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 12 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 13 | # License for the specific language governing permissions and limitations |
| 14 | # under the License. |
| 15 | |
| 16 | from tempest.lib import decorators |
| 17 | from tempest import test |
| 18 | |
| 19 | from neutron.tests.tempest.scenario import base |
| 20 | from neutron.tests.tempest.scenario import test_dvr |
| 21 | |
| 22 | |
| 23 | class NetworkMigrationTestBase(base.BaseTempestTestCase, |
| 24 | test_dvr.NetworkTestMixin): |
| 25 | credentials = ['primary', 'admin'] |
| 26 | force_tenant_isolation = False |
| 27 | |
| 28 | @classmethod |
| 29 | @test.requires_ext(extension="dvr", service="network") |
| 30 | @test.requires_ext(extension="l3-ha", service="network") |
| 31 | def skip_checks(cls): |
| 32 | super(NetworkMigrationTestBase, cls).skip_checks() |
| 33 | |
| 34 | def _check_update(self, router, is_dvr, is_ha): |
| 35 | router = self.admin_manager.network_client.show_router(router['id']) |
| 36 | self.assertEqual(is_dvr, router['router']['distributed']) |
| 37 | self.assertEqual(is_ha, router['router']['ha']) |
| 38 | |
| 39 | def _test_migration(self, before_dvr, before_ha, after_dvr, after_ha): |
| 40 | router = self.create_router_by_client( |
| 41 | distributed=before_dvr, ha=before_ha, |
| 42 | tenant_id=self.client.tenant_id, is_admin=True) |
| 43 | |
| 44 | self.setup_network_and_server(router=router) |
| 45 | self._check_connectivity() |
| 46 | |
| 47 | self.admin_manager.network_client.update_router( |
| 48 | router_id=router['id'], admin_state_up=False) |
| 49 | self.admin_manager.network_client.update_router( |
| 50 | router_id=router['id'], distributed=after_dvr, ha=after_ha) |
| 51 | self._check_update(router, after_dvr, after_ha) |
| 52 | |
| 53 | self.admin_manager.network_client.update_router( |
| 54 | router_id=router['id'], admin_state_up=True) |
| 55 | self._check_connectivity() |
| 56 | |
| 57 | |
| 58 | class NetworkMigrationFromLegacy(NetworkMigrationTestBase): |
| 59 | |
| 60 | @decorators.idempotent_id('23724222-483a-4129-bc15-7a9278f3828b') |
| 61 | def test_from_legacy_to_dvr(self): |
| 62 | self._test_migration(before_dvr=False, before_ha=False, |
| 63 | after_dvr=True, after_ha=False) |
| 64 | |
| 65 | @decorators.idempotent_id('09d85102-994f-4ff9-bf3e-17051145ca12') |
| 66 | def test_from_legacy_to_ha(self): |
| 67 | self._test_migration(before_dvr=False, before_ha=False, |
| 68 | after_dvr=False, after_ha=True) |
| 69 | |
| 70 | @decorators.idempotent_id('fe169f2c-6ed3-4eb0-8afe-2d540c4b49e2') |
| 71 | def test_from_legacy_to_dvr_ha(self): |
| 72 | self._test_migration(before_dvr=False, before_ha=False, |
| 73 | after_dvr=True, after_ha=True) |
| 74 | |
| 75 | |
| 76 | class NetworkMigrationFromHA(NetworkMigrationTestBase): |
| 77 | |
| 78 | @decorators.idempotent_id('b4e68ac0-3b76-4306-ae8a-51cf4d363b22') |
| 79 | def test_from_ha_to_legacy(self): |
| 80 | self._test_migration(before_dvr=False, before_ha=True, |
| 81 | after_dvr=False, after_ha=False) |
| 82 | |
| 83 | @decorators.idempotent_id('42260eea-5d56-4d30-b62a-a62694dfe4d5') |
| 84 | def test_from_ha_to_dvr(self): |
| 85 | self._test_migration(before_dvr=False, before_ha=True, |
| 86 | after_dvr=True, after_ha=False) |
| 87 | |
| 88 | @decorators.idempotent_id('e4149576-248b-43fa-9d0b-a5c2f51967ce') |
| 89 | def test_from_ha_to_dvr_ha(self): |
| 90 | self._test_migration(before_dvr=False, before_ha=True, |
| 91 | after_dvr=True, after_ha=True) |
| 92 | |
| 93 | |
| 94 | class NetworkMigrationFromDVR(NetworkMigrationTestBase): |
| 95 | |
| 96 | @decorators.idempotent_id('e5cac02c-248d-4aac-bd5e-9d47c5197307') |
| 97 | def test_from_dvr_to_legacy(self): |
| 98 | self._test_migration(before_dvr=True, before_ha=False, |
| 99 | after_dvr=False, after_ha=False) |
| 100 | |
| 101 | @decorators.idempotent_id('a00d5ad7-8509-4bb0-bdd2-7f1ee052d1cd') |
| 102 | def test_from_dvr_to_ha(self): |
| 103 | self._test_migration(before_dvr=True, before_ha=False, |
| 104 | after_dvr=False, after_ha=True) |
| 105 | |
| 106 | @decorators.idempotent_id('25304a51-93a8-4cf3-9523-bce8b4eaecf8') |
| 107 | def test_from_dvr_to_dvr_ha(self): |
| 108 | self._test_migration(before_dvr=True, before_ha=False, |
| 109 | after_dvr=True, after_ha=True) |
| 110 | |
| 111 | |
| 112 | class NetworkMigrationFromDVRHA(NetworkMigrationTestBase): |
| 113 | |
| 114 | @decorators.idempotent_id('1be9b2e2-379c-40a4-a269-6687b81df691') |
| 115 | def test_from_dvr_ha_to_legacy(self): |
| 116 | self._test_migration(before_dvr=True, before_ha=True, |
| 117 | after_dvr=False, after_ha=False) |
| 118 | |
| 119 | @decorators.idempotent_id('55957267-4e84-4314-a2f7-7cd36a2df04b') |
| 120 | def test_from_dvr_ha_to_ha(self): |
| 121 | self._test_migration(before_dvr=True, before_ha=True, |
| 122 | after_dvr=False, after_ha=True) |
| 123 | |
| 124 | @decorators.idempotent_id('d6bedff1-72be-4a9a-8ea2-dc037cd838e0') |
| 125 | def test_from_dvr_ha_to_dvr(self): |
| 126 | self._test_migration(before_dvr=True, before_ha=True, |
| 127 | after_dvr=True, after_ha=False) |