blob: a37abf4584e57914ff48be061623971bd59556a1 [file] [log] [blame]
Genadi Chereshnyac0411e92016-07-11 16:59:42 +03001# 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 Kumarc125fd12017-11-15 19:41:01 +053015from tempest.common import utils
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000016from tempest.lib import decorators
Dongcan Ye91017ca2018-02-11 10:46:03 +000017import testtools
Genadi Chereshnyac0411e92016-07-11 16:59:42 +030018
Genadi Chereshnyac0411e92016-07-11 16:59:42 +030019from neutron_lib import constants
Chandan Kumar667d3d32017-09-22 12:24:06 +053020from neutron_tempest_plugin import config
21from neutron_tempest_plugin.scenario import base
Genadi Chereshnyac0411e92016-07-11 16:59:42 +030022
23CONF = config.CONF
24
25
Genadi Chereshnya57173bd2017-01-10 11:17:07 +020026class NetworkTestMixin(object):
Genadi Chereshnyac0411e92016-07-11 16:59:42 +030027 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']
rajat294495c042017-06-28 15:37:16 +053044 self.os_admin.network_client.update_port(
Genadi Chereshnyac0411e92016-07-11 16:59:42 +030045 port_id, admin_state_up=False)
46
Genadi Chereshnya57173bd2017-01-10 11:17:07 +020047
48class NetworkDvrTest(base.BaseTempestTestCase, NetworkTestMixin):
49 credentials = ['primary', 'admin']
50 force_tenant_isolation = False
51
52 @classmethod
Chandan Kumarc125fd12017-11-15 19:41:01 +053053 @utils.requires_ext(extension="dvr", service="network")
Genadi Chereshnya57173bd2017-01-10 11:17:07 +020054 def skip_checks(cls):
55 super(NetworkDvrTest, cls).skip_checks()
56
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000057 @decorators.idempotent_id('3d73ec1a-2ec6-45a9-b0f8-04a283d9d344')
Dongcan Ye91017ca2018-02-11 10:46:03 +000058 @testtools.skipUnless(
59 CONF.neutron_plugin_options.l3_agent_mode == 'dvr_snat',
60 "Need dvr_snat agent mode assumption.")
Genadi Chereshnyac0411e92016-07-11 16:59:42 +030061 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 Kajinamida451772023-03-22 00:19:39 +090067 distributed=True, tenant_id=self.client.project_id, is_admin=True,
Genadi Chereshnya8f979dc2017-02-16 17:41:58 +020068 ha=False)
Genadi Chereshnyac0411e92016-07-11 16:59:42 +030069 self.setup_network_and_server(router=router)
70 self._check_snat_port_connectivity()