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