blob: b1cba5a30131082475a1595c7e7fb7580d766b30 [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
Genadi Chereshnyac0411e92016-07-11 16:59:42 +030017
Genadi Chereshnyac0411e92016-07-11 16:59:42 +030018from neutron_lib import constants
Chandan Kumar667d3d32017-09-22 12:24:06 +053019from neutron_tempest_plugin import config
20from neutron_tempest_plugin.scenario import base
Genadi Chereshnyac0411e92016-07-11 16:59:42 +030021
22CONF = config.CONF
23
24
Genadi Chereshnya57173bd2017-01-10 11:17:07 +020025class NetworkTestMixin(object):
Genadi Chereshnyac0411e92016-07-11 16:59:42 +030026 def _check_connectivity(self):
27 self.check_connectivity(self.fip['floating_ip_address'],
28 CONF.validation.image_ssh_user,
29 self.keypair['private_key'])
30
31 def _check_snat_port_connectivity(self):
32 self._check_connectivity()
33
34 # Put the Router_SNAT port down to make sure the traffic flows through
35 # Compute node.
36 self._put_snat_port_down(self.network['id'])
37 self._check_connectivity()
38
39 def _put_snat_port_down(self, network_id):
40 port_id = self.client.list_ports(
41 network_id=network_id,
42 device_owner=constants.DEVICE_OWNER_ROUTER_SNAT)['ports'][0]['id']
rajat294495c042017-06-28 15:37:16 +053043 self.os_admin.network_client.update_port(
Genadi Chereshnyac0411e92016-07-11 16:59:42 +030044 port_id, admin_state_up=False)
45
Genadi Chereshnya57173bd2017-01-10 11:17:07 +020046
47class NetworkDvrTest(base.BaseTempestTestCase, NetworkTestMixin):
48 credentials = ['primary', 'admin']
49 force_tenant_isolation = False
50
51 @classmethod
Chandan Kumarc125fd12017-11-15 19:41:01 +053052 @utils.requires_ext(extension="dvr", service="network")
Genadi Chereshnya57173bd2017-01-10 11:17:07 +020053 def skip_checks(cls):
54 super(NetworkDvrTest, cls).skip_checks()
55
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000056 @decorators.idempotent_id('3d73ec1a-2ec6-45a9-b0f8-04a283d9d344')
Genadi Chereshnyac0411e92016-07-11 16:59:42 +030057 def test_vm_reachable_through_compute(self):
58 """Check that the VM is reachable through compute node.
59
60 The test is done by putting the SNAT port down on controller node.
61 """
62 router = self.create_router_by_client(
Genadi Chereshnya8f979dc2017-02-16 17:41:58 +020063 distributed=True, tenant_id=self.client.tenant_id, is_admin=True,
64 ha=False)
Genadi Chereshnyac0411e92016-07-11 16:59:42 +030065 self.setup_network_and_server(router=router)
66 self._check_snat_port_connectivity()