Genadi Chereshnya | c0411e9 | 2016-07-11 16:59:42 +0300 | [diff] [blame] | 1 | # Copyright 2016 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. |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 15 | from tempest.lib import decorators |
Genadi Chereshnya | c0411e9 | 2016-07-11 16:59:42 +0300 | [diff] [blame] | 16 | from tempest import test |
| 17 | |
| 18 | from neutron.tests.tempest import config |
| 19 | from neutron.tests.tempest.scenario import base |
| 20 | from neutron_lib import constants |
| 21 | |
| 22 | CONF = config.CONF |
| 23 | |
| 24 | |
| 25 | class NetworkDvrTest(base.BaseTempestTestCase): |
| 26 | credentials = ['primary', 'admin'] |
| 27 | force_tenant_isolation = False |
| 28 | |
| 29 | @classmethod |
| 30 | @test.requires_ext(extension="dvr", service="network") |
| 31 | def skip_checks(cls): |
| 32 | super(NetworkDvrTest, cls).skip_checks() |
| 33 | |
| 34 | def _check_connectivity(self): |
| 35 | self.check_connectivity(self.fip['floating_ip_address'], |
| 36 | CONF.validation.image_ssh_user, |
| 37 | self.keypair['private_key']) |
| 38 | |
| 39 | def _check_snat_port_connectivity(self): |
| 40 | self._check_connectivity() |
| 41 | |
| 42 | # Put the Router_SNAT port down to make sure the traffic flows through |
| 43 | # Compute node. |
| 44 | self._put_snat_port_down(self.network['id']) |
| 45 | self._check_connectivity() |
| 46 | |
| 47 | def _put_snat_port_down(self, network_id): |
| 48 | port_id = self.client.list_ports( |
| 49 | network_id=network_id, |
| 50 | device_owner=constants.DEVICE_OWNER_ROUTER_SNAT)['ports'][0]['id'] |
| 51 | self.admin_manager.network_client.update_port( |
| 52 | port_id, admin_state_up=False) |
| 53 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 54 | @decorators.idempotent_id('3d73ec1a-2ec6-45a9-b0f8-04a283d9d344') |
Genadi Chereshnya | c0411e9 | 2016-07-11 16:59:42 +0300 | [diff] [blame] | 55 | def test_vm_reachable_through_compute(self): |
| 56 | """Check that the VM is reachable through compute node. |
| 57 | |
| 58 | The test is done by putting the SNAT port down on controller node. |
| 59 | """ |
| 60 | router = self.create_router_by_client( |
Genadi Chereshnya | 8f979dc | 2017-02-16 17:41:58 +0200 | [diff] [blame] | 61 | distributed=True, tenant_id=self.client.tenant_id, is_admin=True, |
| 62 | ha=False) |
Genadi Chereshnya | c0411e9 | 2016-07-11 16:59:42 +0300 | [diff] [blame] | 63 | self.setup_network_and_server(router=router) |
| 64 | self._check_snat_port_connectivity() |
| 65 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 66 | @decorators.idempotent_id('23724222-483a-4129-bc15-7a9278f3828b') |
Genadi Chereshnya | c0411e9 | 2016-07-11 16:59:42 +0300 | [diff] [blame] | 67 | def test_update_centralized_router_to_dvr(self): |
| 68 | """Check that updating centralized router to be distributed works. |
| 69 | """ |
| 70 | # Created a centralized router on a DVR setup |
| 71 | router = self.create_router_by_client( |
Genadi Chereshnya | 8f979dc | 2017-02-16 17:41:58 +0200 | [diff] [blame] | 72 | distributed=False, tenant_id=self.client.tenant_id, is_admin=True, |
| 73 | ha=False) |
Genadi Chereshnya | c0411e9 | 2016-07-11 16:59:42 +0300 | [diff] [blame] | 74 | self.setup_network_and_server(router=router) |
| 75 | self._check_connectivity() |
| 76 | |
| 77 | # Update router to be distributed |
| 78 | self.admin_manager.network_client.update_router( |
| 79 | router_id=router['id'], admin_state_up=False) |
| 80 | self.admin_manager.network_client.update_router( |
| 81 | router_id=router['id'], distributed=True) |
| 82 | self.admin_manager.network_client.update_router( |
| 83 | router_id=router['id'], admin_state_up=True) |
| 84 | self._check_snat_port_connectivity() |