blob: 3c62f3ae9a7f1e7e4e2fd8c82de5a589f5a5dc99 [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.
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000015from tempest.lib import decorators
Genadi Chereshnyac0411e92016-07-11 16:59:42 +030016from tempest import test
17
18from neutron.tests.tempest import config
19from neutron.tests.tempest.scenario import base
20from neutron_lib import constants
21
22CONF = config.CONF
23
24
25class 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ńskic0caa2e2017-02-25 10:11:32 +000054 @decorators.idempotent_id('3d73ec1a-2ec6-45a9-b0f8-04a283d9d344')
Genadi Chereshnyac0411e92016-07-11 16:59:42 +030055 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 Chereshnya8f979dc2017-02-16 17:41:58 +020061 distributed=True, tenant_id=self.client.tenant_id, is_admin=True,
62 ha=False)
Genadi Chereshnyac0411e92016-07-11 16:59:42 +030063 self.setup_network_and_server(router=router)
64 self._check_snat_port_connectivity()
65
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000066 @decorators.idempotent_id('23724222-483a-4129-bc15-7a9278f3828b')
Genadi Chereshnyac0411e92016-07-11 16:59:42 +030067 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 Chereshnya8f979dc2017-02-16 17:41:58 +020072 distributed=False, tenant_id=self.client.tenant_id, is_admin=True,
73 ha=False)
Genadi Chereshnyac0411e92016-07-11 16:59:42 +030074 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()