Merge "Replace assertEqual(None, *) with assertIsNone in tests"
diff --git a/neutron/tests/tempest/api/admin/test_routers_flavors.py b/neutron/tests/tempest/api/admin/test_routers_flavors.py
index 300c956..4988ba8 100644
--- a/neutron/tests/tempest/api/admin/test_routers_flavors.py
+++ b/neutron/tests/tempest/api/admin/test_routers_flavors.py
@@ -23,6 +23,7 @@
     @classmethod
     @test.requires_ext(extension="router", service="network")
     @test.requires_ext(extension="flavors", service="network")
+    @test.requires_ext(extension="l3-flavors", service="network")
     def skip_checks(cls):
         super(RoutersFlavorTestCase, cls).skip_checks()
 
@@ -34,7 +35,12 @@
         # make a flavor based on legacy router for regular tenant to use
         driver = ('neutron.services.l3_router.service_providers.'
                   'single_node.SingleNodeDriver')
-        sp = cls.admin_client.create_service_profile(driver=driver)
+        try:
+            sp = cls.admin_client.create_service_profile(driver=driver)
+        except lib_exc.NotFound as e:
+            if e.resp_body['type'] == 'ServiceProfileDriverNotFound':
+                raise cls.skipException("%s is not available" % driver)
+            raise
         cls.service_profiles.append(sp['service_profile'])
         cls.flavor = cls.create_flavor(
                 name='special_flavor',
@@ -47,7 +53,12 @@
         # make another with a different driver
         driver = ('neutron.services.l3_router.service_providers.'
                   'dvr.DvrDriver')
-        sp = cls.admin_client.create_service_profile(driver=driver)
+        try:
+            sp = cls.admin_client.create_service_profile(driver=driver)
+        except lib_exc.NotFound as e:
+            if e.resp_body['type'] == 'ServiceProfileDriverNotFound':
+                raise cls.skipException("%s is not available" % driver)
+            raise
         cls.service_profiles.append(sp['service_profile'])
         cls.prem_flavor = cls.create_flavor(
                 name='better_special_flavor',
diff --git a/neutron/tests/tempest/api/base.py b/neutron/tests/tempest/api/base.py
index 39c714c..b308a31 100644
--- a/neutron/tests/tempest/api/base.py
+++ b/neutron/tests/tempest/api/base.py
@@ -594,7 +594,7 @@
         }
         body = self.list_method(**pagination_args)
         resources = self._extract_resources(body)
-        self.assertTrue(len(resources) >= len(self.resource_names))
+        self.assertGreaterEqual(len(resources), len(self.resource_names))
 
     def _test_list_pagination_iteratively(self, lister):
         # first, collect all resources for later comparison
@@ -709,7 +709,7 @@
                 self.plural_name, uri
             )
             resources_ = self._extract_resources(body)
-            self.assertTrue(page_size >= len(resources_))
+            self.assertGreaterEqual(page_size, len(resources_))
             resources.extend(reversed(resources_))
 
         self.assertSameOrder(expected_resources, reversed(resources))
diff --git a/neutron/tests/tempest/api/test_address_scopes.py b/neutron/tests/tempest/api/test_address_scopes.py
index 8290784..5cecb77 100644
--- a/neutron/tests/tempest/api/test_address_scopes.py
+++ b/neutron/tests/tempest/api/test_address_scopes.py
@@ -79,6 +79,17 @@
                          returned_address_scope['name'])
         self.assertFalse(returned_address_scope['shared'])
 
+    @test.idempotent_id('bbd57364-6d57-48e4-b0f1-8b9a998f5e06')
+    @test.requires_ext(extension="project-id", service="network")
+    def test_show_address_scope_project_id(self):
+        address_scope = self._create_address_scope(ip_version=4)
+        body = self.client.show_address_scope(address_scope['id'])
+        show_addr_scope = body['address_scope']
+        self.assertIn('project_id', show_addr_scope)
+        self.assertIn('tenant_id', show_addr_scope)
+        self.assertEqual(self.client.tenant_id, show_addr_scope['project_id'])
+        self.assertEqual(self.client.tenant_id, show_addr_scope['tenant_id'])
+
     @test.idempotent_id('85a259b2-ace6-4e32-9657-a9a392b452aa')
     def test_tenant_update_address_scope(self):
         self._test_update_address_scope_helper()
diff --git a/neutron/tests/tempest/api/test_allowed_address_pair.py b/neutron/tests/tempest/api/test_allowed_address_pair.py
index e4c499c..5313785 100644
--- a/neutron/tests/tempest/api/test_allowed_address_pair.py
+++ b/neutron/tests/tempest/api/test_allowed_address_pair.py
@@ -83,7 +83,7 @@
         body = self.client.update_port(
             port_id, allowed_address_pairs=allowed_address_pairs)
         allowed_address_pair = body['port']['allowed_address_pairs']
-        self.assertEqual(allowed_address_pair, allowed_address_pairs)
+        self.assertItemsEqual(allowed_address_pair, allowed_address_pairs)
 
     @test.idempotent_id('9599b337-272c-47fd-b3cf-509414414ac4')
     def test_update_port_with_address_pair(self):
diff --git a/neutron/tests/tempest/api/test_dhcp_ipv6.py b/neutron/tests/tempest/api/test_dhcp_ipv6.py
index e136efa..bf45825 100644
--- a/neutron/tests/tempest/api/test_dhcp_ipv6.py
+++ b/neutron/tests/tempest/api/test_dhcp_ipv6.py
@@ -14,10 +14,10 @@
 #    under the License.
 
 import netaddr
+from neutron_lib import constants
 from tempest.lib import exceptions as lib_exc
 from tempest import test
 
-from neutron.common import constants
 from neutron.tests.tempest.api import base
 from neutron.tests.tempest import config
 
diff --git a/neutron/tests/tempest/api/test_metering_extensions.py b/neutron/tests/tempest/api/test_metering_extensions.py
index 756cd5a..7b03386 100644
--- a/neutron/tests/tempest/api/test_metering_extensions.py
+++ b/neutron/tests/tempest/api/test_metering_extensions.py
@@ -15,8 +15,11 @@
 from tempest.lib.common.utils import data_utils
 from tempest import test
 
+from neutron.api.v2 import attributes as attr
 from neutron.tests.tempest.api import base
 
+LONG_NAME_OK = 'x' * (attr.NAME_MAX_LEN)
+
 
 class MeteringTestJSON(base.BaseAdminNetworkTest):
 
@@ -81,6 +84,17 @@
                   id=metering_label['id']))
         self.assertEqual(len(labels['metering_labels']), 1)
 
+    @test.idempotent_id('46608f8d-2e27-4eb6-a0b4-dbe405144c4d')
+    def test_create_delete_metering_label_with_name_max_length(self):
+        name = LONG_NAME_OK
+        body = self.admin_client.create_metering_label(name=name)
+        metering_label = body['metering_label']
+        self.addCleanup(self._delete_metering_label,
+                        metering_label['id'])
+        labels = (self.admin_client.list_metering_labels(
+                  id=metering_label['id']))
+        self.assertEqual(len(labels['metering_labels']), 1)
+
     @test.idempotent_id('cfc500d9-9de6-4847-8803-62889c097d45')
     def test_show_metering_label(self):
         # Verifies the details of a label
diff --git a/neutron/tests/tempest/api/test_metering_negative.py b/neutron/tests/tempest/api/test_metering_negative.py
new file mode 100644
index 0000000..39fdae8
--- /dev/null
+++ b/neutron/tests/tempest/api/test_metering_negative.py
@@ -0,0 +1,36 @@
+# Copyright 2016 FUJITSU LIMITED
+#
+#    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 exceptions as lib_exc
+from tempest import test
+
+from neutron.api.v2 import attributes as attr
+from neutron.tests.tempest.api import base
+
+LONG_NAME_NG = 'x' * (attr.NAME_MAX_LEN + 1)
+
+
+class MeteringNegativeTestJSON(base.BaseAdminNetworkTest):
+
+    @classmethod
+    @test.requires_ext(extension="metering", service="network")
+    def resource_setup(cls):
+        super(MeteringNegativeTestJSON, cls).resource_setup()
+
+    @test.attr(type='negative')
+    @test.idempotent_id('8b3f7c84-9d37-4771-8681-bfd2c07f3c2d')
+    def test_create_metering_label_with_too_long_name(self):
+        self.assertRaises(lib_exc.BadRequest,
+                          self.admin_client.create_metering_label,
+                          name=LONG_NAME_NG)
diff --git a/neutron/tests/tempest/api/test_networks.py b/neutron/tests/tempest/api/test_networks.py
index 279964a..8c00c86 100644
--- a/neutron/tests/tempest/api/test_networks.py
+++ b/neutron/tests/tempest/api/test_networks.py
@@ -121,6 +121,22 @@
         self.assertEqual(project_id, new_net['project_id'])
         self.assertEqual(project_id, new_net['tenant_id'])
 
+    @test.idempotent_id('94e2a44c-3367-4253-8c2a-22deaf59e96c')
+    @test.requires_ext(extension="dns-integration",
+                       service="network")
+    def test_create_update_network_dns_domain(self):
+        domain1 = 'test.org.'
+        body = self.create_network(dns_domain=domain1)
+        self.assertEqual(domain1, body['dns_domain'])
+        net_id = body['id']
+        body = self.client.list_networks(id=net_id)['networks'][0]
+        self.assertEqual(domain1, body['dns_domain'])
+        domain2 = 'd.org.'
+        body = self.client.update_network(net_id, dns_domain=domain2)
+        self.assertEqual(domain2, body['network']['dns_domain'])
+        body = self.client.show_network(net_id)['network']
+        self.assertEqual(domain2, body['dns_domain'])
+
     @test.idempotent_id('6ae6d24f-9194-4869-9c85-c313cb20e080')
     def test_list_networks_fields(self):
         # Verify specific fields of the networks
diff --git a/neutron/tests/tempest/api/test_ports.py b/neutron/tests/tempest/api/test_ports.py
index 093de07..034f07e 100644
--- a/neutron/tests/tempest/api/test_ports.py
+++ b/neutron/tests/tempest/api/test_ports.py
@@ -25,6 +25,23 @@
         super(PortsTestJSON, cls).resource_setup()
         cls.network = cls.create_network()
 
+    def _confirm_dns_assignment(self, port):
+        # NOTE(manjeets) port created with single subnet
+        # would have only one dns_assignment
+        dns_assignment = port['dns_assignment'][0]
+        ip = port['fixed_ips'][0]['ip_address']
+        if port['dns_name']:
+            hostname = port['dns_name']
+        else:
+            hostname = 'host-%s' % ip.replace('.', '-')
+        self.assertEqual(hostname, dns_assignment['hostname'])
+
+        # To avoid hard coding the expected dns_domain value
+        # in neutron.conf we just check that the fqdn starts
+        # with correct hostname
+        self.assertTrue(dns_assignment['fqdn'].startswith(hostname))
+        self.assertEqual(ip, dns_assignment['ip_address'])
+
     @test.idempotent_id('c72c1c0c-2193-4aca-bbb4-b1442640bbbb')
     @test.requires_ext(extension="standard-attr-description",
                        service="network")
@@ -40,6 +57,39 @@
         body = self.client.list_ports(id=body['port']['id'])['ports'][0]
         self.assertEqual('d2', body['description'])
 
+    @test.idempotent_id('539fbefe-fb36-48aa-9a53-8c5fbd44e492')
+    @test.requires_ext(extension="dns-integration",
+                       service="network")
+    def test_create_update_port_with_dns_name(self):
+        # NOTE(manjeets) dns_domain is set to openstackgate.local
+        # so dns_name for port can be set
+        self.create_subnet(self.network)
+        body = self.create_port(self.network, dns_name='d1')
+        self.assertEqual('d1', body['dns_name'])
+        self._confirm_dns_assignment(body)
+        body = self.client.list_ports(id=body['id'])['ports'][0]
+        self._confirm_dns_assignment(body)
+        self.assertEqual('d1', body['dns_name'])
+        body = self.client.update_port(body['id'],
+                                       dns_name='d2')
+        self.assertEqual('d2', body['port']['dns_name'])
+        self._confirm_dns_assignment(body['port'])
+        body = self.client.show_port(body['port']['id'])['port']
+        self.assertEqual('d2', body['dns_name'])
+        self._confirm_dns_assignment(body)
+
+    @test.idempotent_id('435e89df-a8bb-4b41-801a-9f20d362d777')
+    @test.requires_ext(extension="dns-integration",
+                       service="network")
+    def test_create_update_port_with_no_dns_name(self):
+        self.create_subnet(self.network)
+        body = self.create_port(self.network)
+        self.assertFalse(body['dns_name'])
+        self._confirm_dns_assignment(body)
+        port_body = self.client.show_port(body['id'])
+        self.assertFalse(port_body['port']['dns_name'])
+        self._confirm_dns_assignment(port_body['port'])
+
     @test.idempotent_id('c72c1c0c-2193-4aca-bbb4-b1442640c123')
     def test_change_dhcp_flag_then_create_port(self):
         s = self.create_subnet(self.network, enable_dhcp=False)
diff --git a/neutron/tests/tempest/api/test_qos.py b/neutron/tests/tempest/api/test_qos.py
index b9572ca..2f1c75a 100644
--- a/neutron/tests/tempest/api/test_qos.py
+++ b/neutron/tests/tempest/api/test_qos.py
@@ -46,6 +46,19 @@
         policies_ids = [p['id'] for p in policies]
         self.assertIn(policy['id'], policies_ids)
 
+    @test.idempotent_id('606a48e2-5403-4052-b40f-4d54b855af76')
+    @test.requires_ext(extension="project-id", service="network")
+    def test_show_policy_has_project_id(self):
+        policy = self.create_qos_policy(name='test-policy', shared=False)
+        body = self.admin_client.show_qos_policy(policy['id'])
+        show_policy = body['policy']
+        self.assertIn('project_id', show_policy)
+        self.assertIn('tenant_id', show_policy)
+        self.assertEqual(self.admin_client.tenant_id,
+                         show_policy['project_id'])
+        self.assertEqual(self.admin_client.tenant_id,
+                         show_policy['tenant_id'])
+
     @test.idempotent_id('f8d20e92-f06d-4805-b54f-230f77715815')
     def test_list_policy_filter_by_name(self):
         self.create_qos_policy(name='test', description='test policy',
diff --git a/neutron/tests/tempest/api/test_qos_negative.py b/neutron/tests/tempest/api/test_qos_negative.py
new file mode 100644
index 0000000..bc3222a
--- /dev/null
+++ b/neutron/tests/tempest/api/test_qos_negative.py
@@ -0,0 +1,50 @@
+#    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 exceptions as lib_exc
+from tempest import test
+
+from neutron.api.v2 import attributes as attr
+from neutron.tests.tempest.api import base
+
+LONG_NAME_NG = 'z' * (attr.NAME_MAX_LEN + 1)
+LONG_DESCRIPTION_NG = 'z' * (attr.LONG_DESCRIPTION_MAX_LEN + 1)
+LONG_TENANT_ID_NG = 'z' * (attr.TENANT_ID_MAX_LEN + 1)
+
+
+class QosNegativeTestJSON(base.BaseAdminNetworkTest):
+    @classmethod
+    @test.requires_ext(extension="qos", service="network")
+    def resource_setup(cls):
+        super(QosNegativeTestJSON, cls).resource_setup()
+
+    @test.attr(type='negative')
+    @test.idempotent_id('b9dce555-d3b3-11e5-950a-54ee757c77da')
+    def test_add_policy_with_too_long_name(self):
+        self.assertRaises(lib_exc.BadRequest,
+                          self.client.create_qos_policy,
+                          LONG_NAME_NG, 'test policy desc1', False)
+
+    @test.attr(type='negative')
+    @test.idempotent_id('b9dce444-d3b3-11e5-950a-54ee747c99db')
+    def test_add_policy_with_too_long_description(self):
+        self.assertRaises(lib_exc.BadRequest,
+                          self.client.create_qos_policy,
+                          'test-policy', LONG_DESCRIPTION_NG, False)
+
+    @test.attr(type='negative')
+    @test.idempotent_id('b9dce444-d3b3-11e5-950a-54ee757c77dc')
+    def test_add_policy_with_too_long_tenant_id(self):
+        self.assertRaises(lib_exc.BadRequest,
+                          self.client.create_qos_policy,
+                          'test-policy', 'test policy desc1',
+                          False, LONG_TENANT_ID_NG)
diff --git a/neutron/tests/tempest/api/test_revisions.py b/neutron/tests/tempest/api/test_revisions.py
index 10438b7..6a2ff88 100644
--- a/neutron/tests/tempest/api/test_revisions.py
+++ b/neutron/tests/tempest/api/test_revisions.py
@@ -10,6 +10,8 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+import netaddr
+
 from tempest import test
 
 from neutron.tests.tempest.api import base
@@ -90,12 +92,7 @@
         self.client.update_port(
             port['id'], security_groups=[sg['security_group']['id']])
         updated = self.client.show_port(port['id'])
-        self.client.update_port(port['id'], security_groups=[])
-        # TODO(kevinbenton): these extra shows after after the update are
-        # to work around the fact that ML2 creates the result dict before
-        # commit happens if the port is unbound. The update response should
-        # be usable directly once that is fixed.
-        updated2 = self.client.show_port(port['id'])
+        updated2 = self.client.update_port(port['id'], security_groups=[])
         self.assertGreater(updated['port']['revision_number'],
                            port['revision_number'])
         self.assertGreater(updated2['port']['revision_number'],
@@ -118,6 +115,115 @@
         self.assertGreater(updated2['security_group']['revision_number'],
                            updated['security_group']['revision_number'])
 
+    @test.idempotent_id('db70c285-0365-4fac-9f55-2a0ad8cf55a8')
+    @test.requires_ext(extension="allowed-address-pairs", service="network")
+    def test_update_allowed_address_pairs_bumps_revision(self):
+        net = self.create_network()
+        port = self.create_port(net)
+        updated = self.client.update_port(
+            port['id'], allowed_address_pairs=[{'ip_address': '1.1.1.1/32'}])
+        self.assertGreater(updated['port']['revision_number'],
+                           port['revision_number'])
+        updated2 = self.client.update_port(
+            port['id'], allowed_address_pairs=[])
+        self.assertGreater(updated2['port']['revision_number'],
+                           updated['port']['revision_number'])
+
+    @test.idempotent_id('a21ec3b4-3569-4b77-bf29-4177edaa2df5')
+    @test.requires_ext(extension="extra_dhcp_opt", service="network")
+    def test_update_extra_dhcp_opt_bumps_revision(self):
+        net = self.create_network()
+        port = self.create_port(net)
+        opts = [{'opt_value': 'pxelinux.0', 'opt_name': 'bootfile-name'}]
+        updated = self.client.update_port(port['id'], extra_dhcp_opts=opts)
+        self.assertGreater(updated['port']['revision_number'],
+                           port['revision_number'])
+        opts[0]['opt_value'] = 'pxelinux.77'
+        updated2 = self.client.update_port(
+            port['id'], extra_dhcp_opts=opts)
+        self.assertGreater(updated2['port']['revision_number'],
+                           updated['port']['revision_number'])
+
+    @test.idempotent_id('40ba648f-f374-4c29-a5b7-489dd5a38a4e')
+    @test.requires_ext(extension="dns-integration", service="network")
+    def test_update_dns_domain_bumps_revision(self):
+        net = self.create_network(dns_domain='example.test.')
+        updated = self.client.update_network(net['id'], dns_domain='exa.test.')
+        self.assertGreater(updated['network']['revision_number'],
+                           net['revision_number'])
+        port = self.create_port(net)
+        updated = self.client.update_port(port['id'], dns_name='port1')
+        if not updated['port']['dns_name']:
+            self.skipTest("Server does not have DNS domain configured.")
+        self.assertGreater(updated['port']['revision_number'],
+                           port['revision_number'])
+        updated2 = self.client.update_port(port['id'], dns_name='')
+        self.assertGreater(updated2['port']['revision_number'],
+                           updated['port']['revision_number'])
+
+    @test.idempotent_id('8482324f-cf59-4d73-b98e-d37119255300')
+    @test.requires_ext(extension="router", service="network")
+    @test.requires_ext(extension="extraroute", service="network")
+    def test_update_router_extra_routes_bumps_revision(self):
+        subnet = self.create_subnet(self.create_network())
+        subgateway = netaddr.IPAddress(subnet['gateway_ip'])
+        router = self.create_router(router_name='test')
+        self.create_router_interface(router['id'], subnet['id'])
+        router = self.client.show_router(router['id'])['router']
+        updated = self.client.update_extra_routes(
+            router['id'], str(subgateway + 1), '2.0.0.0/24')
+        self.assertGreater(updated['router']['revision_number'],
+                           router['revision_number'])
+        updated2 = self.client.delete_extra_routes(router['id'])
+        self.assertGreater(updated2['router']['revision_number'],
+                           updated['router']['revision_number'])
+
+    @test.idempotent_id('6bd18702-e25a-4b4b-8c0c-680113533511')
+    @test.requires_ext(extension="subnet-service-types", service="network")
+    def test_update_subnet_service_types_bumps_revisions(self):
+        subnet = self.create_subnet(self.create_network())
+        updated = self.client.update_subnet(
+            subnet['id'], service_types=['compute:'])
+        self.assertGreater(updated['subnet']['revision_number'],
+                           subnet['revision_number'])
+        updated2 = self.client.update_subnet(
+            subnet['id'], service_types=[])
+        self.assertGreater(updated2['subnet']['revision_number'],
+                           updated['subnet']['revision_number'])
+
+    @test.idempotent_id('9c83105c-9973-45ff-9ca2-e66d64700abe')
+    @test.requires_ext(extension="port-security", service="network")
+    def test_update_port_security_bumps_revisions(self):
+        net = self.create_network(port_security_enabled=False)
+        updated = self.client.update_network(net['id'],
+                                             port_security_enabled=True)
+        self.assertGreater(updated['network']['revision_number'],
+                           net['revision_number'])
+        updated2 = self.client.update_network(net['id'],
+                                              port_security_enabled=False)
+        self.assertGreater(updated2['network']['revision_number'],
+                           updated['network']['revision_number'])
+        port = self.create_port(net, port_security_enabled=False)
+        updated = self.client.update_port(port['id'],
+                                          port_security_enabled=True)
+        self.assertGreater(updated['port']['revision_number'],
+                           port['revision_number'])
+        updated2 = self.client.update_port(port['id'],
+                                           port_security_enabled=False)
+        self.assertGreater(updated2['port']['revision_number'],
+                           updated['port']['revision_number'])
+
+    @test.idempotent_id('68d5ac3a-11a1-4847-8e2e-5843c043d89b')
+    @test.requires_ext(extension="binding", service="network")
+    def test_portbinding_bumps_revision(self):
+        port = self.create_port(self.create_network())
+        port = self.admin_client.update_port(
+            port['id'], **{'binding:host_id': 'badhost1'})['port']
+        updated = self.admin_client.update_port(
+            port['id'], **{'binding:host_id': 'badhost2'})['port']
+        self.assertGreater(updated['revision_number'],
+                           port['revision_number'])
+
     @test.idempotent_id('4a37bde9-1975-47e0-9b8c-2c9ca36415b0')
     @test.requires_ext(extension="router", service="network")
     def test_update_router_bumps_revision(self):
diff --git a/neutron/tests/tempest/api/test_subnetpools.py b/neutron/tests/tempest/api/test_subnetpools.py
index e8ec954..763d06c 100644
--- a/neutron/tests/tempest/api/test_subnetpools.py
+++ b/neutron/tests/tempest/api/test_subnetpools.py
@@ -133,6 +133,17 @@
         self.assertEqual(prefixlen, subnetpool['default_prefixlen'])
         self.assertFalse(subnetpool['shared'])
 
+    @test.idempotent_id('5bf9f1e2-efc8-4195-acf3-d12b2bd68dd3')
+    @test.requires_ext(extension="project-id", service="network")
+    def test_show_subnetpool_has_project_id(self):
+        subnetpool = self._create_subnetpool()
+        body = self.client.show_subnetpool(subnetpool['id'])
+        show_subnetpool = body['subnetpool']
+        self.assertIn('project_id', show_subnetpool)
+        self.assertIn('tenant_id', show_subnetpool)
+        self.assertEqual(self.client.tenant_id, show_subnetpool['project_id'])
+        self.assertEqual(self.client.tenant_id, show_subnetpool['tenant_id'])
+
     @test.idempotent_id('764f1b93-1c4a-4513-9e7b-6c2fc5e9270c')
     def test_tenant_update_subnetpool(self):
         created_subnetpool = self._create_subnetpool()
diff --git a/neutron/tests/tempest/api/test_trunk.py b/neutron/tests/tempest/api/test_trunk.py
index d5aa7db..6763517 100644
--- a/neutron/tests/tempest/api/test_trunk.py
+++ b/neutron/tests/tempest/api/test_trunk.py
@@ -12,11 +12,13 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+from tempest.lib.common.utils import data_utils
 from tempest.lib.common.utils import test_utils
 from tempest.lib import exceptions as lib_exc
 from tempest import test
 
 from neutron.tests.tempest.api import base
+from neutron.tests.tempest import config
 
 
 def trunks_cleanup(client, trunks):
@@ -98,6 +100,17 @@
         self.client.delete_trunk(trunk_id)
         self.assertRaises(lib_exc.NotFound, self._show_trunk, trunk_id)
 
+    @test.idempotent_id('8d83a6ca-662d-45b8-8062-d513077296aa')
+    @test.requires_ext(extension="project-id", service="network")
+    def test_show_trunk_has_project_id(self):
+        trunk = self._create_trunk_with_network_and_parent(None)
+        body = self._show_trunk(trunk['trunk']['id'])
+        show_trunk = body['trunk']
+        self.assertIn('project_id', show_trunk)
+        self.assertIn('tenant_id', show_trunk)
+        self.assertEqual(self.client.tenant_id, show_trunk['project_id'])
+        self.assertEqual(self.client.tenant_id, show_trunk['tenant_id'])
+
     @test.idempotent_id('4ce46c22-a2b6-4659-bc5a-0ef2463cab32')
     def test_create_update_trunk(self):
         trunk = self._create_trunk_with_network_and_parent(None)
@@ -206,6 +219,85 @@
         self.assertEqual(1, len(observed_subports))
 
 
+class TrunkTestMtusJSONBase(TrunkTestJSONBase):
+
+    required_extensions = ['provider', 'trunk']
+
+    @classmethod
+    def skip_checks(cls):
+        super(TrunkTestMtusJSONBase, 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 any(t
+               not in config.CONF.neutron_plugin_options.available_type_drivers
+               for t in ['gre', 'vxlan']):
+            msg = "Either vxlan or gre type driver not enabled."
+            raise cls.skipException(msg)
+
+    def setUp(self):
+        super(TrunkTestMtusJSONBase, self).setUp()
+
+        # VXLAN autocomputed MTU (1450) is smaller than that of GRE (1458)
+        vxlan_kwargs = {'network_name': data_utils.rand_name('vxlan-net-'),
+                        'provider:network_type': 'vxlan'}
+        self.smaller_mtu_net = self.create_shared_network(**vxlan_kwargs)
+
+        gre_kwargs = {'network_name': data_utils.rand_name('gre-net-'),
+                      'provider:network_type': 'gre'}
+        self.larger_mtu_net = self.create_shared_network(**gre_kwargs)
+
+        self.smaller_mtu_port = self.create_port(self.smaller_mtu_net)
+        self.smaller_mtu_port_2 = self.create_port(self.smaller_mtu_net)
+        self.larger_mtu_port = self.create_port(self.larger_mtu_net)
+
+
+class TrunkTestMtusJSON(TrunkTestMtusJSONBase):
+
+    @test.idempotent_id('0f05d98e-41f5-4629-ac29-9aee269c9602')
+    def test_create_trunk_with_mtu_greater_than_subport(self):
+        subports = [{'port_id': self.smaller_mtu_port['id'],
+                     'segmentation_type': 'vlan',
+                     'segmentation_id': 2}]
+
+        trunk = self.client.create_trunk(self.larger_mtu_port['id'], subports)
+        self.trunks.append(trunk['trunk'])
+
+    @test.idempotent_id('2004c5c6-e557-4c43-8100-c820ad4953e8')
+    def test_add_subport_with_mtu_smaller_than_trunk(self):
+        subports = [{'port_id': self.smaller_mtu_port['id'],
+                     'segmentation_type': 'vlan',
+                     'segmentation_id': 2}]
+
+        trunk = self.client.create_trunk(self.larger_mtu_port['id'], None)
+        self.trunks.append(trunk['trunk'])
+
+        self.client.add_subports(trunk['trunk']['id'], subports)
+
+    @test.idempotent_id('22725101-f4bc-4e00-84ec-4e02cd7e0500')
+    def test_create_trunk_with_mtu_equal_to_subport(self):
+        subports = [{'port_id': self.smaller_mtu_port['id'],
+                     'segmentation_type': 'vlan',
+                     'segmentation_id': 2}]
+
+        trunk = self.client.create_trunk(self.smaller_mtu_port_2['id'],
+                                         subports)
+        self.trunks.append(trunk['trunk'])
+
+    @test.idempotent_id('175b05ae-66ad-44c7-857a-a12d16f1058f')
+    def test_add_subport_with_mtu_equal_to_trunk(self):
+        subports = [{'port_id': self.smaller_mtu_port['id'],
+                     'segmentation_type': 'vlan',
+                     'segmentation_id': 2}]
+
+        trunk = self.client.create_trunk(self.smaller_mtu_port_2['id'], None)
+        self.trunks.append(trunk['trunk'])
+
+        self.client.add_subports(trunk['trunk']['id'], subports)
+
+
 class TrunksSearchCriteriaTest(base.BaseSearchCriteriaTest):
 
     resource = 'trunk'
diff --git a/neutron/tests/tempest/api/test_trunk_details.py b/neutron/tests/tempest/api/test_trunk_details.py
index 4b7ec28..0c91c45 100644
--- a/neutron/tests/tempest/api/test_trunk_details.py
+++ b/neutron/tests/tempest/api/test_trunk_details.py
@@ -35,15 +35,16 @@
     @test.idempotent_id('544bcaf2-86fb-4930-93ab-ece1c3cc33df')
     def test_port_resource_trunk_details_with_subport(self):
         subport_network = self.create_network()
-        parent_port = self.create_port(subport_network)
-        subport_data = {'port_id': parent_port['id'],
+        subport = self.create_port(subport_network)
+        subport_data = {'port_id': subport['id'],
                         'segmentation_type': 'vlan',
                         'segmentation_id': 2}
         trunk = self._create_trunk_with_network_and_parent([subport_data])
-        port = self.client.show_port(trunk['trunk']['port_id'])
+        subport_data['mac_address'] = subport['mac_address']
+        parent_port = self.client.show_port(trunk['trunk']['port_id'])
         expected_trunk_details = {'sub_ports': [subport_data],
                                   'trunk_id': trunk['trunk']['id']}
-        observed_trunk_details = port['port'].get('trunk_details')
+        observed_trunk_details = parent_port['port'].get('trunk_details')
         self.assertIsNotNone(observed_trunk_details)
         self.assertEqual(expected_trunk_details,
                          observed_trunk_details)
diff --git a/neutron/tests/tempest/api/test_trunk_negative.py b/neutron/tests/tempest/api/test_trunk_negative.py
index 654b497..b26dd75 100644
--- a/neutron/tests/tempest/api/test_trunk_negative.py
+++ b/neutron/tests/tempest/api/test_trunk_negative.py
@@ -15,6 +15,7 @@
 from oslo_utils import uuidutils
 from tempest.lib import exceptions as lib_exc
 from tempest import test
+import testtools
 
 from neutron.tests.tempest.api import test_trunk
 
@@ -235,3 +236,35 @@
         self._create_trunk_with_network_and_parent(subports)
         self.assertRaises(lib_exc.Conflict, self.client.delete_port,
                           port['id'])
+
+
+class TrunkTestMtusJSON(test_trunk.TrunkTestMtusJSONBase):
+
+    required_extensions = (
+        ['net-mtu'] + test_trunk.TrunkTestMtusJSONBase.required_extensions)
+
+    @test.attr(type='negative')
+    @test.idempotent_id('228380ef-1b7a-495e-b759-5b1f08e3e858')
+    def test_create_trunk_with_mtu_smaller_than_subport(self):
+        subports = [{'port_id': self.larger_mtu_port['id'],
+                     'segmentation_type': 'vlan',
+                     'segmentation_id': 2}]
+
+        with testtools.ExpectedException(lib_exc.Conflict):
+            trunk = self.client.create_trunk(self.smaller_mtu_port['id'],
+                                             subports)
+            self.trunks.append(trunk['trunk'])
+
+    @test.attr(type='negative')
+    @test.idempotent_id('3b32bf77-8002-403e-ad01-6f4cf018daa5')
+    def test_add_subport_with_mtu_greater_than_trunk(self):
+        subports = [{'port_id': self.larger_mtu_port['id'],
+                     'segmentation_type': 'vlan',
+                     'segmentation_id': 2}]
+
+        trunk = self.client.create_trunk(self.smaller_mtu_port['id'], None)
+        self.trunks.append(trunk['trunk'])
+
+        self.assertRaises(lib_exc.Conflict,
+                          self.client.add_subports,
+                          trunk['trunk']['id'], subports)
diff --git a/neutron/tests/tempest/config.py b/neutron/tests/tempest/config.py
index f50fa39..479d909 100644
--- a/neutron/tests/tempest/config.py
+++ b/neutron/tests/tempest/config.py
@@ -22,7 +22,12 @@
     cfg.BoolOpt('specify_floating_ip_address_available',
                 default=True,
                 help='Allow passing an IP Address of the floating ip when '
-                     'creating the floating ip')]
+                     'creating the floating ip'),
+    cfg.ListOpt('available_type_drivers',
+                default=[],
+                help='List of network types available to neutron, '
+                     'e.g. vxlan,vlan,gre.'),
+]
 
 # TODO(amuller): Redo configuration options registration as part of the planned
 # transition to the Tempest plugin architecture