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. |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 15 | from tempest.common import utils |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 16 | from tempest.lib import decorators |
Dongcan Ye | 91017ca | 2018-02-11 10:46:03 +0000 | [diff] [blame] | 17 | import testtools |
Genadi Chereshnya | c0411e9 | 2016-07-11 16:59:42 +0300 | [diff] [blame] | 18 | |
Genadi Chereshnya | c0411e9 | 2016-07-11 16:59:42 +0300 | [diff] [blame] | 19 | from neutron_lib import constants |
Chandan Kumar | 667d3d3 | 2017-09-22 12:24:06 +0530 | [diff] [blame] | 20 | from neutron_tempest_plugin import config |
| 21 | from neutron_tempest_plugin.scenario import base |
Genadi Chereshnya | c0411e9 | 2016-07-11 16:59:42 +0300 | [diff] [blame] | 22 | |
| 23 | CONF = config.CONF |
| 24 | |
| 25 | |
Genadi Chereshnya | 57173bd | 2017-01-10 11:17:07 +0200 | [diff] [blame] | 26 | class NetworkTestMixin(object): |
Genadi Chereshnya | c0411e9 | 2016-07-11 16:59:42 +0300 | [diff] [blame] | 27 | def _check_connectivity(self): |
| 28 | self.check_connectivity(self.fip['floating_ip_address'], |
| 29 | CONF.validation.image_ssh_user, |
| 30 | self.keypair['private_key']) |
| 31 | |
| 32 | def _check_snat_port_connectivity(self): |
| 33 | self._check_connectivity() |
| 34 | |
| 35 | # Put the Router_SNAT port down to make sure the traffic flows through |
| 36 | # Compute node. |
| 37 | self._put_snat_port_down(self.network['id']) |
| 38 | self._check_connectivity() |
| 39 | |
| 40 | def _put_snat_port_down(self, network_id): |
| 41 | port_id = self.client.list_ports( |
| 42 | network_id=network_id, |
| 43 | device_owner=constants.DEVICE_OWNER_ROUTER_SNAT)['ports'][0]['id'] |
rajat29 | 4495c04 | 2017-06-28 15:37:16 +0530 | [diff] [blame] | 44 | self.os_admin.network_client.update_port( |
Genadi Chereshnya | c0411e9 | 2016-07-11 16:59:42 +0300 | [diff] [blame] | 45 | port_id, admin_state_up=False) |
| 46 | |
Genadi Chereshnya | 57173bd | 2017-01-10 11:17:07 +0200 | [diff] [blame] | 47 | |
| 48 | class NetworkDvrTest(base.BaseTempestTestCase, NetworkTestMixin): |
| 49 | credentials = ['primary', 'admin'] |
| 50 | force_tenant_isolation = False |
| 51 | |
| 52 | @classmethod |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 53 | @utils.requires_ext(extension="dvr", service="network") |
Genadi Chereshnya | 57173bd | 2017-01-10 11:17:07 +0200 | [diff] [blame] | 54 | def skip_checks(cls): |
| 55 | super(NetworkDvrTest, cls).skip_checks() |
| 56 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 57 | @decorators.idempotent_id('3d73ec1a-2ec6-45a9-b0f8-04a283d9d344') |
Dongcan Ye | 91017ca | 2018-02-11 10:46:03 +0000 | [diff] [blame] | 58 | @testtools.skipUnless( |
| 59 | CONF.neutron_plugin_options.l3_agent_mode == 'dvr_snat', |
| 60 | "Need dvr_snat agent mode assumption.") |
Genadi Chereshnya | c0411e9 | 2016-07-11 16:59:42 +0300 | [diff] [blame] | 61 | def test_vm_reachable_through_compute(self): |
| 62 | """Check that the VM is reachable through compute node. |
| 63 | |
| 64 | The test is done by putting the SNAT port down on controller node. |
| 65 | """ |
| 66 | router = self.create_router_by_client( |
Takashi Kajinami | da45177 | 2023-03-22 00:19:39 +0900 | [diff] [blame] | 67 | distributed=True, tenant_id=self.client.project_id, is_admin=True, |
Genadi Chereshnya | 8f979dc | 2017-02-16 17:41:58 +0200 | [diff] [blame] | 68 | ha=False) |
Genadi Chereshnya | c0411e9 | 2016-07-11 16:59:42 +0300 | [diff] [blame] | 69 | self.setup_network_and_server(router=router) |
| 70 | self._check_snat_port_connectivity() |