Merge "Tempest: Edited bash commands to work with multiple OSes."
diff --git a/neutron/tests/tempest/api/admin/test_l3_agent_scheduler.py b/neutron/tests/tempest/api/admin/test_l3_agent_scheduler.py
index 25cdb99..32fccab 100644
--- a/neutron/tests/tempest/api/admin/test_l3_agent_scheduler.py
+++ b/neutron/tests/tempest/api/admin/test_l3_agent_scheduler.py
@@ -64,21 +64,6 @@
             msg = "L3 Agent Scheduler enabled in conf, but L3 Agent not found"
             raise exceptions.InvalidConfiguration(msg)
         cls.router = cls.create_router(data_utils.rand_name('router'))
-        # NOTE(armax): If DVR is an available extension, and the created router
-        # is indeed a distributed one, more resources need to be provisioned
-        # in order to bind the router to the L3 agent.
-        # That said, let's preserve the existing test logic, where the extra
-        # query and setup steps are only required if the extension is available
-        # and only if the router's default type is distributed.
-        if test.is_extension_enabled('dvr', 'network'):
-            is_dvr_router = cls.admin_client.show_router(
-                cls.router['id'])['router'].get('distributed', False)
-            if is_dvr_router:
-                cls.network = cls.create_network()
-                cls.create_subnet(cls.network)
-                cls.port = cls.create_port(cls.network)
-                cls.client.add_router_interface_with_port_id(
-                    cls.router['id'], cls.port['id'])
 
     @decorators.idempotent_id('b7ce6e89-e837-4ded-9b78-9ed3c9c6a45a')
     def test_list_routers_on_l3_agent(self):
diff --git a/neutron/tests/tempest/api/admin/test_networks.py b/neutron/tests/tempest/api/admin/test_networks.py
index 0cf83a3..c7ea008 100644
--- a/neutron/tests/tempest/api/admin/test_networks.py
+++ b/neutron/tests/tempest/api/admin/test_networks.py
@@ -9,6 +9,7 @@
 #    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 #    License for the specific language governing permissions and limitations
 #    under the License.
+import testtools
 
 from oslo_utils import uuidutils
 from tempest.lib import decorators
@@ -16,6 +17,7 @@
 from tempest import test
 
 from neutron.tests.tempest.api import base
+from neutron.tests.tempest import config
 
 
 class NetworksTestAdmin(base.BaseAdminNetworkTest):
@@ -69,3 +71,17 @@
                               client=self.admin_client)
         expected_message = "'project_id' and 'tenant_id' do not match"
         self.assertEqual(expected_message, e.resp_body['message'])
+
+    @decorators.idempotent_id('571d0dde-0f84-11e7-b565-fa163e4fa634')
+    @testtools.skipUnless("vxlan" in config.CONF.neutron_plugin_options.
+                          available_type_drivers,
+                          'VXLAN type_driver is not enabled')
+    @test.requires_ext(extension="provider", service="network")
+    def test_create_tenant_network_vxlan(self):
+        network = self.admin_client.create_network(
+            **{"provider:network_type": "vxlan"})['network']
+        self.addCleanup(self.admin_client.delete_network,
+                        network['id'])
+        network = self.admin_client.show_network(
+            network['id'])['network']
+        self.assertEqual('vxlan', network['provider:network_type'])
diff --git a/neutron/tests/tempest/api/admin/test_quotas.py b/neutron/tests/tempest/api/admin/test_quotas.py
index 9736d7f..99ef2c3 100644
--- a/neutron/tests/tempest/api/admin/test_quotas.py
+++ b/neutron/tests/tempest/api/admin/test_quotas.py
@@ -13,7 +13,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import six
 from tempest.lib.common.utils import data_utils
 from tempest.lib import decorators
 from tempest.lib import exceptions as lib_exc
@@ -83,7 +82,7 @@
 
         # Change quotas for tenant
         quota_set = self._setup_quotas(tenant_id, **new_quotas)
-        for key, value in six.iteritems(new_quotas):
+        for key, value in new_quotas.items():
             self.assertEqual(value, quota_set[key])
 
         # Confirm our tenant is listed among tenants with non default quotas
@@ -91,13 +90,14 @@
         found = False
         for qs in non_default_quotas['quotas']:
             if qs['tenant_id'] == tenant_id:
+                self.assertEqual(tenant_id, qs['project_id'])
                 found = True
         self.assertTrue(found)
 
         # Confirm from API quotas were changed as requested for tenant
         quota_set = self.admin_client.show_quotas(tenant_id)
         quota_set = quota_set['quota']
-        for key, value in six.iteritems(new_quotas):
+        for key, value in new_quotas.items():
             self.assertEqual(value, quota_set[key])
 
         # Reset quotas to default and confirm
diff --git a/neutron/tests/tempest/api/admin/test_shared_network_extension.py b/neutron/tests/tempest/api/admin/test_shared_network_extension.py
index 6f3e391..042a73e 100644
--- a/neutron/tests/tempest/api/admin/test_shared_network_extension.py
+++ b/neutron/tests/tempest/api/admin/test_shared_network_extension.py
@@ -279,6 +279,17 @@
         # anchor is gone, delete should pass
         self.admin_client.delete_rbac_policy(wild['id'])
 
+    @decorators.idempotent_id('34d627da-a732-68c0-2e1a-bc4a19246698')
+    def test_delete_self_share_rule(self):
+        net = self.create_network()
+        self_share = self.client.create_rbac_policy(
+                         object_type='network', object_id=net['id'],
+                         action='access_as_shared',
+                         target_tenant=net['tenant_id'])['rbac_policy']
+        port = self.client.create_port(network_id=net['id'])['port']
+        self.client.delete_rbac_policy(self_share['id'])
+        self.client.delete_port(port['id'])
+
     @decorators.idempotent_id('86c3529b-1231-40de-803c-beefbeefbeef')
     def test_tenant_can_delete_port_on_own_network(self):
         net = self.create_network()  # owned by self.client
@@ -399,6 +410,18 @@
             self.client.update_rbac_policy(pol['rbac_policy']['id'],
                                            target_tenant='*')
 
+    @decorators.idempotent_id('34d627da-869f-68c0-2e1a-bc4a19246698')
+    def test_update_self_share_rule(self):
+        net = self.create_network()
+        self_share = self.client.create_rbac_policy(
+                         object_type='network', object_id=net['id'],
+                         action='access_as_shared',
+                         target_tenant=net['tenant_id'])['rbac_policy']
+        port = self.client.create_port(network_id=net['id'])['port']
+        self.client.update_rbac_policy(self_share['id'],
+                                       target_tenant=self.client2.tenant_id)
+        self.client.delete_port(port['id'])
+
     @decorators.idempotent_id('86c3529b-1231-40de-803c-aeeeeeee7fff')
     def test_filtering_works_with_rbac_records_present(self):
         resp = self._make_admin_net_and_subnet_shared_to_tenant_id(
diff --git a/neutron/tests/tempest/api/test_extension_driver_port_security.py b/neutron/tests/tempest/api/test_extension_driver_port_security.py
index 8e3ec07..381252a 100644
--- a/neutron/tests/tempest/api/test_extension_driver_port_security.py
+++ b/neutron/tests/tempest/api/test_extension_driver_port_security.py
@@ -76,7 +76,7 @@
         network = self.create_network()
         self.create_subnet(network)
 
-        sec_group_body, sec_group_name = self._create_security_group()
+        sec_group_body, _ = self._create_security_group()
         port = self.create_port(network)
 
         # Exception when set port-sec to False with sec-group defined
diff --git a/neutron/tests/tempest/api/test_qos.py b/neutron/tests/tempest/api/test_qos.py
index 4f03557..104fb9b 100644
--- a/neutron/tests/tempest/api/test_qos.py
+++ b/neutron/tests/tempest/api/test_qos.py
@@ -177,8 +177,8 @@
             self.assertIn(rule, actual_rule_types)
 
     def _disassociate_network(self, client, network_id):
-        client.update_network(network_id, qos_policy_id=None)
-        updated_network = self.admin_client.show_network(network_id)
+        updated_network = client.update_network(network_id,
+                                                qos_policy_id=None)
         self.assertIsNone(updated_network['network']['qos_policy_id'])
 
     @decorators.idempotent_id('65b9ef75-1911-406a-bbdb-ca1d68d528b0')
@@ -473,7 +473,7 @@
                                                     max_kbps=1,
                                                     max_burst_kbps=1)
         self.assertRaises(
-            exceptions.NotFound,
+            exceptions.Forbidden,
             self.client.update_bandwidth_limit_rule,
             policy['id'], rule['id'], max_kbps=2, max_burst_kbps=4)
 
diff --git a/neutron/tests/tempest/api/test_routers.py b/neutron/tests/tempest/api/test_routers.py
index d6beb77..7a1e458 100644
--- a/neutron/tests/tempest/api/test_routers.py
+++ b/neutron/tests/tempest/api/test_routers.py
@@ -14,7 +14,6 @@
 #    under the License.
 
 import netaddr
-import six
 from tempest.lib.common.utils import data_utils
 from tempest.lib import decorators
 from tempest import test
@@ -91,7 +90,7 @@
             self.assertIsNone(actual_ext_gw_info)
             return
         # Verify only keys passed in exp_ext_gw_info
-        for k, v in six.iteritems(exp_ext_gw_info):
+        for k, v in exp_ext_gw_info.items():
             self.assertEqual(v, actual_ext_gw_info[k])
 
     def _verify_gateway_port(self, router_id):
diff --git a/neutron/tests/tempest/api/test_security_groups_negative.py b/neutron/tests/tempest/api/test_security_groups_negative.py
index 9202060..1d841b1 100644
--- a/neutron/tests/tempest/api/test_security_groups_negative.py
+++ b/neutron/tests/tempest/api/test_security_groups_negative.py
@@ -13,12 +13,15 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+from neutron_lib.db import constants as db_const
 from tempest.lib import decorators
 from tempest.lib import exceptions as lib_exc
 from tempest import test
 
 from neutron.tests.tempest.api import base_security_groups as base
 
+LONG_NAME_NG = 'x' * (db_const.NAME_FIELD_SIZE + 1)
+
 
 class NegativeSecGroupTest(base.BaseSecGroupTest):
 
@@ -28,6 +31,20 @@
         super(NegativeSecGroupTest, cls).resource_setup()
 
     @test.attr(type='negative')
+    @decorators.idempotent_id('594edfa8-9a5b-438e-9344-49aece337d49')
+    def test_create_security_group_with_too_long_name(self):
+        self.assertRaises(lib_exc.BadRequest,
+                          self.client.create_security_group,
+                          name=LONG_NAME_NG)
+
+    @test.attr(type='negative')
+    @decorators.idempotent_id('b6b79838-7430-4d3f-8e07-51dfb61802c2')
+    def test_create_security_group_with_boolean_type_name(self):
+        self.assertRaises(lib_exc.BadRequest,
+                          self.client.create_security_group,
+                          name=True)
+
+    @test.attr(type='negative')
     @decorators.idempotent_id('55100aa8-b24f-333c-0bef-64eefd85f15c')
     def test_update_default_security_group_name(self):
         sg_list = self.client.list_security_groups(name='default')
@@ -35,6 +52,24 @@
         self.assertRaises(lib_exc.Conflict, self.client.update_security_group,
                           sg['id'], name='test')
 
+    @test.attr(type='negative')
+    @decorators.idempotent_id('c8510dd8-c3a8-4df9-ae44-24354db50960')
+    def test_update_security_group_with_too_long_name(self):
+        sg_list = self.client.list_security_groups(name='default')
+        sg = sg_list['security_groups'][0]
+        self.assertRaises(lib_exc.BadRequest,
+                          self.client.update_security_group,
+                          sg['id'], name=LONG_NAME_NG)
+
+    @test.attr(type='negative')
+    @decorators.idempotent_id('d9a14917-f66f-4eca-ab72-018563917f1b')
+    def test_update_security_group_with_boolean_type_name(self):
+        sg_list = self.client.list_security_groups(name='default')
+        sg = sg_list['security_groups'][0]
+        self.assertRaises(lib_exc.BadRequest,
+                          self.client.update_security_group,
+                          sg['id'], name=True)
+
 
 class NegativeSecGroupIPv6Test(NegativeSecGroupTest):
     _ip_version = 6
diff --git a/neutron/tests/tempest/api/test_timestamp.py b/neutron/tests/tempest/api/test_timestamp.py
index 2abef94..8b57b2d 100644
--- a/neutron/tests/tempest/api/test_timestamp.py
+++ b/neutron/tests/tempest/api/test_timestamp.py
@@ -223,8 +223,10 @@
         # verify the timestamp from creation and showed is same
         self.assertEqual(router['created_at'],
                          show_router['created_at'])
-        self.assertEqual(router['updated_at'],
-                         show_router['updated_at'])
+        # 'updated_at' timestamp can change immediately after creation
+        # if environment is HA or DVR, so just make sure it's >=
+        self.assertGreaterEqual(show_router['updated_at'],
+                                router['updated_at'])
 
     @decorators.idempotent_id('8ae55186-464f-4b87-1c9f-eb2765ee81ac')
     def test_create_floatingip_with_timestamp(self):
diff --git a/neutron/tests/tempest/api/test_trunk.py b/neutron/tests/tempest/api/test_trunk.py
index 62290c9..2617eba 100644
--- a/neutron/tests/tempest/api/test_trunk.py
+++ b/neutron/tests/tempest/api/test_trunk.py
@@ -220,6 +220,56 @@
         self.assertEqual(1, len(observed_subports))
 
 
+class TrunkTestInheritJSONBase(TrunkTestJSONBase):
+
+    required_extensions = ['provider', 'trunk']
+
+    @classmethod
+    def skip_checks(cls):
+        super(TrunkTestInheritJSONBase, cls).skip_checks()
+        for ext in cls.required_extensions:
+            if not test.is_extension_enabled(ext, 'network'):
+                msg = "%s extension not enabled." % ext
+                raise cls.skipException(msg)
+        if ("vlan" not in
+                config.CONF.neutron_plugin_options.available_type_drivers):
+            raise cls.skipException("VLAN type_driver is not enabled")
+        if not config.CONF.neutron_plugin_options.provider_vlans:
+            raise cls.skipException("No provider VLAN networks available")
+
+    def create_provider_network(self):
+        foo_net = config.CONF.neutron_plugin_options.provider_vlans[0]
+        post_body = {'network_name': data_utils.rand_name('vlan-net-'),
+                     'provider:network_type': 'vlan',
+                     'provider:physical_network': foo_net}
+        return self.create_shared_network(**post_body)
+
+    @decorators.idempotent_id('0f05d98e-41f5-4629-dada-9aee269c9602')
+    def test_add_subport(self):
+        trunk_network = self.create_provider_network()
+        trunk_port = self.create_port(trunk_network)
+        subport_networks = [
+            self.create_provider_network(),
+            self.create_provider_network(),
+        ]
+        subport1 = self.create_port(subport_networks[0])
+        subport2 = self.create_port(subport_networks[1])
+        subports = [{'port_id': subport1['id'],
+                     'segmentation_type': 'inherit',
+                     'segmentation_id': subport1['id']},
+                    {'port_id': subport2['id'],
+                     'segmentation_type': 'inherit',
+                     'segmentation_id': subport2['id']}]
+        trunk = self.client.create_trunk(trunk_port['id'], subports)['trunk']
+        self.trunks.append(trunk)
+        # Validate that subport got segmentation details from the network
+        for i in range(2):
+            self.assertEqual(subport_networks[i]['provider:network_type'],
+                             trunk['sub_ports'][i]['segmentation_type'])
+            self.assertEqual(subport_networks[i]['provider:segmentation_id'],
+                             trunk['sub_ports'][i]['segmentation_id'])
+
+
 class TrunkTestMtusJSONBase(TrunkTestJSONBase):
 
     required_extensions = ['provider', 'trunk']
diff --git a/neutron/tests/tempest/api/test_trunk_negative.py b/neutron/tests/tempest/api/test_trunk_negative.py
index 585ef52..f3497bb 100644
--- a/neutron/tests/tempest/api/test_trunk_negative.py
+++ b/neutron/tests/tempest/api/test_trunk_negative.py
@@ -103,6 +103,18 @@
                             'segmentation_id': 3}])
 
     @test.attr(type='negative')
+    @decorators.idempotent_id('40aed9be-e976-47d0-dada-bde2c7e74e57')
+    def test_create_subport_invalid_inherit_network_segmentation_type(self):
+        trunk = self._create_trunk_with_network_and_parent([])
+        subport_network = self.create_network()
+        parent_port = self.create_port(subport_network)
+        self.assertRaises(lib_exc.BadRequest, self.client.add_subports,
+                          trunk['trunk']['id'],
+                          [{'port_id': parent_port['id'],
+                            'segmentation_type': 'inherit',
+                            'segmentation_id': -1}])
+
+    @test.attr(type='negative')
     @decorators.idempotent_id('40aed9be-e976-47d0-a555-bde2c7e74e57')
     def test_create_trunk_duplicate_subport_segmentation_ids(self):
         trunk = self._create_trunk_with_network_and_parent([])
diff --git a/neutron/tests/tempest/config.py b/neutron/tests/tempest/config.py
index 479d909..5a9ac77 100644
--- a/neutron/tests/tempest/config.py
+++ b/neutron/tests/tempest/config.py
@@ -19,6 +19,9 @@
 
 
 NeutronPluginOptions = [
+    cfg.ListOpt('provider_vlans',
+                default=[],
+                help='List of provider networks available in the deployment.'),
     cfg.BoolOpt('specify_floating_ip_address_available',
                 default=True,
                 help='Allow passing an IP Address of the floating ip when '
diff --git a/neutron/tests/tempest/scenario/test_dvr.py b/neutron/tests/tempest/scenario/test_dvr.py
index 727bb5c..049aa8f 100644
--- a/neutron/tests/tempest/scenario/test_dvr.py
+++ b/neutron/tests/tempest/scenario/test_dvr.py
@@ -22,15 +22,7 @@
 CONF = config.CONF
 
 
-class NetworkDvrTest(base.BaseTempestTestCase):
-    credentials = ['primary', 'admin']
-    force_tenant_isolation = False
-
-    @classmethod
-    @test.requires_ext(extension="dvr", service="network")
-    def skip_checks(cls):
-        super(NetworkDvrTest, cls).skip_checks()
-
+class NetworkTestMixin(object):
     def _check_connectivity(self):
         self.check_connectivity(self.fip['floating_ip_address'],
                                 CONF.validation.image_ssh_user,
@@ -51,6 +43,16 @@
         self.admin_manager.network_client.update_port(
             port_id, admin_state_up=False)
 
+
+class NetworkDvrTest(base.BaseTempestTestCase, NetworkTestMixin):
+    credentials = ['primary', 'admin']
+    force_tenant_isolation = False
+
+    @classmethod
+    @test.requires_ext(extension="dvr", service="network")
+    def skip_checks(cls):
+        super(NetworkDvrTest, cls).skip_checks()
+
     @decorators.idempotent_id('3d73ec1a-2ec6-45a9-b0f8-04a283d9d344')
     def test_vm_reachable_through_compute(self):
         """Check that the VM is reachable through compute node.
@@ -58,25 +60,7 @@
         The test is done by putting the SNAT port down on controller node.
         """
         router = self.create_router_by_client(
-            distributed=True, tenant_id=self.client.tenant_id, is_admin=True)
+            distributed=True, tenant_id=self.client.tenant_id, is_admin=True,
+            ha=False)
         self.setup_network_and_server(router=router)
         self._check_snat_port_connectivity()
-
-    @decorators.idempotent_id('23724222-483a-4129-bc15-7a9278f3828b')
-    def test_update_centralized_router_to_dvr(self):
-        """Check that updating centralized router to be distributed works.
-        """
-        # Created a centralized router on a DVR setup
-        router = self.create_router_by_client(
-            distributed=False, tenant_id=self.client.tenant_id, is_admin=True)
-        self.setup_network_and_server(router=router)
-        self._check_connectivity()
-
-        # Update router to be distributed
-        self.admin_manager.network_client.update_router(
-            router_id=router['id'], admin_state_up=False)
-        self.admin_manager.network_client.update_router(
-            router_id=router['id'], distributed=True)
-        self.admin_manager.network_client.update_router(
-            router_id=router['id'], admin_state_up=True)
-        self._check_snat_port_connectivity()
diff --git a/neutron/tests/tempest/scenario/test_migration.py b/neutron/tests/tempest/scenario/test_migration.py
new file mode 100644
index 0000000..db89716
--- /dev/null
+++ b/neutron/tests/tempest/scenario/test_migration.py
@@ -0,0 +1,127 @@
+# Copyright 2017 Red Hat, Inc.
+# All Rights Reserved.
+#
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
+#    not use this file except in compliance with the License. You may obtain
+#    a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+#    License for the specific language governing permissions and limitations
+#    under the License.
+
+from tempest.lib import decorators
+from tempest import test
+
+from neutron.tests.tempest.scenario import base
+from neutron.tests.tempest.scenario import test_dvr
+
+
+class NetworkMigrationTestBase(base.BaseTempestTestCase,
+                               test_dvr.NetworkTestMixin):
+    credentials = ['primary', 'admin']
+    force_tenant_isolation = False
+
+    @classmethod
+    @test.requires_ext(extension="dvr", service="network")
+    @test.requires_ext(extension="l3-ha", service="network")
+    def skip_checks(cls):
+        super(NetworkMigrationTestBase, cls).skip_checks()
+
+    def _check_update(self, router, is_dvr, is_ha):
+        router = self.admin_manager.network_client.show_router(router['id'])
+        self.assertEqual(is_dvr, router['router']['distributed'])
+        self.assertEqual(is_ha, router['router']['ha'])
+
+    def _test_migration(self, before_dvr, before_ha, after_dvr, after_ha):
+        router = self.create_router_by_client(
+            distributed=before_dvr, ha=before_ha,
+            tenant_id=self.client.tenant_id, is_admin=True)
+
+        self.setup_network_and_server(router=router)
+        self._check_connectivity()
+
+        self.admin_manager.network_client.update_router(
+            router_id=router['id'], admin_state_up=False)
+        self.admin_manager.network_client.update_router(
+            router_id=router['id'], distributed=after_dvr, ha=after_ha)
+        self._check_update(router, after_dvr, after_ha)
+
+        self.admin_manager.network_client.update_router(
+            router_id=router['id'], admin_state_up=True)
+        self._check_connectivity()
+
+
+class NetworkMigrationFromLegacy(NetworkMigrationTestBase):
+
+    @decorators.idempotent_id('23724222-483a-4129-bc15-7a9278f3828b')
+    def test_from_legacy_to_dvr(self):
+        self._test_migration(before_dvr=False, before_ha=False,
+                             after_dvr=True, after_ha=False)
+
+    @decorators.idempotent_id('09d85102-994f-4ff9-bf3e-17051145ca12')
+    def test_from_legacy_to_ha(self):
+        self._test_migration(before_dvr=False, before_ha=False,
+                             after_dvr=False, after_ha=True)
+
+    @decorators.idempotent_id('fe169f2c-6ed3-4eb0-8afe-2d540c4b49e2')
+    def test_from_legacy_to_dvr_ha(self):
+        self._test_migration(before_dvr=False, before_ha=False,
+                             after_dvr=True, after_ha=True)
+
+
+class NetworkMigrationFromHA(NetworkMigrationTestBase):
+
+    @decorators.idempotent_id('b4e68ac0-3b76-4306-ae8a-51cf4d363b22')
+    def test_from_ha_to_legacy(self):
+        self._test_migration(before_dvr=False, before_ha=True,
+                             after_dvr=False, after_ha=False)
+
+    @decorators.idempotent_id('42260eea-5d56-4d30-b62a-a62694dfe4d5')
+    def test_from_ha_to_dvr(self):
+        self._test_migration(before_dvr=False, before_ha=True,
+                             after_dvr=True, after_ha=False)
+
+    @decorators.idempotent_id('e4149576-248b-43fa-9d0b-a5c2f51967ce')
+    def test_from_ha_to_dvr_ha(self):
+        self._test_migration(before_dvr=False, before_ha=True,
+                             after_dvr=True, after_ha=True)
+
+
+class NetworkMigrationFromDVR(NetworkMigrationTestBase):
+
+    @decorators.idempotent_id('e5cac02c-248d-4aac-bd5e-9d47c5197307')
+    def test_from_dvr_to_legacy(self):
+        self._test_migration(before_dvr=True, before_ha=False,
+                             after_dvr=False, after_ha=False)
+
+    @decorators.idempotent_id('a00d5ad7-8509-4bb0-bdd2-7f1ee052d1cd')
+    def test_from_dvr_to_ha(self):
+        self._test_migration(before_dvr=True, before_ha=False,
+                             after_dvr=False, after_ha=True)
+
+    @decorators.idempotent_id('25304a51-93a8-4cf3-9523-bce8b4eaecf8')
+    def test_from_dvr_to_dvr_ha(self):
+        self._test_migration(before_dvr=True, before_ha=False,
+                             after_dvr=True, after_ha=True)
+
+
+class NetworkMigrationFromDVRHA(NetworkMigrationTestBase):
+
+    @decorators.idempotent_id('1be9b2e2-379c-40a4-a269-6687b81df691')
+    def test_from_dvr_ha_to_legacy(self):
+        self._test_migration(before_dvr=True, before_ha=True,
+                             after_dvr=False, after_ha=False)
+
+    @decorators.idempotent_id('55957267-4e84-4314-a2f7-7cd36a2df04b')
+    def test_from_dvr_ha_to_ha(self):
+        self._test_migration(before_dvr=True, before_ha=True,
+                             after_dvr=False, after_ha=True)
+
+    @decorators.idempotent_id('d6bedff1-72be-4a9a-8ea2-dc037cd838e0')
+    def test_from_dvr_ha_to_dvr(self):
+        self._test_migration(before_dvr=True, before_ha=True,
+                             after_dvr=True, after_ha=False)
diff --git a/neutron/tests/tempest/scenario/test_trunk.py b/neutron/tests/tempest/scenario/test_trunk.py
index f687b59..112c17b 100644
--- a/neutron/tests/tempest/scenario/test_trunk.py
+++ b/neutron/tests/tempest/scenario/test_trunk.py
@@ -13,6 +13,7 @@
 #    under the License.
 
 import netaddr
+from oslo_log import log as logging
 from tempest.common import waiters
 from tempest.lib.common import ssh
 from tempest.lib.common.utils import data_utils
@@ -24,6 +25,7 @@
 from neutron.tests.tempest.scenario import base
 from neutron.tests.tempest.scenario import constants
 
+LOG = logging.getLogger(__name__)
 CONF = config.CONF
 
 CONFIGURE_VLAN_INTERFACE_COMMANDS = (
@@ -226,7 +228,7 @@
         vlan_network = self.create_network()
         new_subnet_cidr = get_next_subnet(
             config.safe_get_config_value('network', 'project_network_cidr'))
-        self.create_subnet(vlan_network, cidr=new_subnet_cidr)
+        self.create_subnet(vlan_network, gateway=None, cidr=new_subnet_cidr)
 
         servers = [
             self._create_server_with_port_and_subport(vlan_network, vlan_tag)
@@ -237,6 +239,8 @@
             # Configure VLAN interfaces on server
             command = CONFIGURE_VLAN_INTERFACE_COMMANDS % {'tag': vlan_tag}
             server['ssh_client'].exec_command(command)
+            out = server['ssh_client'].exec_command('ip addr list')
+            LOG.debug("Interfaces on server %s: %s", server, out)
 
         # Ping from server1 to server2 via VLAN interface should fail because
         # we haven't allowed ICMP
diff --git a/neutron/tests/tempest/services/network/json/network_client.py b/neutron/tests/tempest/services/network/json/network_client.py
index 671c040..83c4570 100644
--- a/neutron/tests/tempest/services/network/json/network_client.py
+++ b/neutron/tests/tempest/services/network/json/network_client.py
@@ -366,6 +366,8 @@
             'external_gateway_info', body['router']['external_gateway_info'])
         if 'distributed' in kwargs:
             update_body['distributed'] = kwargs['distributed']
+        if 'ha' in kwargs:
+            update_body['ha'] = kwargs['ha']
         update_body = dict(router=update_body)
         update_body = jsonutils.dumps(update_body)
         resp, body = self.put(uri, update_body)