Merge "Test timestamp with segment resource"
diff --git a/.zuul.yaml b/.zuul.yaml
index 32e565c..a002690 100644
--- a/.zuul.yaml
+++ b/.zuul.yaml
@@ -108,7 +108,7 @@
     timeout: 10000
     vars:
       devstack_localrc:
-          NETWORK_API_EXTENSIONS: "address-scope,agent,allowed-address-pairs,auto-allocated-topology,availability_zone,binding,default-subnetpools,dhcp_agent_scheduler,dns-integration,ext-gw-mode,external-net,extra_dhcp_opt,extraroute,flavors,ip-substring-filtering,l3-flavors,l3-ha,l3_agent_scheduler,logging,metering,multi-provider,net-mtu,net-mtu-writable,network-ip-availability,network_availability_zone,pagination,port-security,project-id,provider,qos,quotas,quota_details,rbac-policies,router,router_availability_zone,security-group,port-security-groups-filtering,segment,service-type,sorting,standard-attr-description,standard-attr-revisions,standard-attr-timestamp,standard-attr-tag,subnet_allocation,tag,tag-ext,trunk,trunk-details"
+          NETWORK_API_EXTENSIONS: "address-scope,agent,allowed-address-pairs,auto-allocated-topology,availability_zone,binding,default-subnetpools,dhcp_agent_scheduler,dns-integration,ext-gw-mode,external-net,extra_dhcp_opt,extraroute,flavors,ip-substring-filtering,l3-flavors,l3-ha,l3_agent_scheduler,logging,metering,multi-provider,net-mtu,net-mtu-writable,network-ip-availability,network_availability_zone,pagination,port-security,project-id,provider,qos,qos-fip,quotas,quota_details,rbac-policies,router,router_availability_zone,security-group,port-security-groups-filtering,segment,service-type,sorting,standard-attr-description,standard-attr-revisions,standard-attr-timestamp,standard-attr-tag,subnet_allocation,tag,tag-ext,trunk,trunk-details"
           Q_AGENT: linuxbridge
       devstack_local_conf:
         post-config:
diff --git a/neutron_tempest_plugin/api/admin/test_quotas_negative.py b/neutron_tempest_plugin/api/admin/test_quotas_negative.py
index 2267313..7d699d1 100644
--- a/neutron_tempest_plugin/api/admin/test_quotas_negative.py
+++ b/neutron_tempest_plugin/api/admin/test_quotas_negative.py
@@ -63,9 +63,6 @@
     @decorators.idempotent_id('fe20d9f9-346c-4a20-bbfa-d9ca390f4dc6')
     def test_create_port_when_quotas_is_full(self):
         tenant_id = self.create_project()['id']
-        new_quotas = {'port': 1}
-        self._setup_quotas(tenant_id, **new_quotas)
-
         net_args = {'tenant_id': tenant_id}
         net = self.admin_client.create_network(**net_args)['network']
         self.addCleanup(self.admin_client.delete_network, net['id'])
@@ -78,6 +75,11 @@
         subnet = self.admin_client.create_subnet(**subnet_args)['subnet']
         self.addCleanup(self.admin_client.delete_subnet, subnet['id'])
 
+        ports = self.admin_client.list_ports(tenant_id=tenant_id)
+        quota_limit = len(ports['ports']) + 1
+        new_quotas = {'port': quota_limit}
+        self._setup_quotas(tenant_id, **new_quotas)
+
         port_args = {'tenant_id': tenant_id,
                      'network_id': net['id']}
         port = self.admin_client.create_port(**port_args)['port']
diff --git a/neutron_tempest_plugin/api/test_dhcp_ipv6.py b/neutron_tempest_plugin/api/test_dhcp_ipv6.py
index 3a7db96..69b4ea0 100644
--- a/neutron_tempest_plugin/api/test_dhcp_ipv6.py
+++ b/neutron_tempest_plugin/api/test_dhcp_ipv6.py
@@ -50,8 +50,8 @@
     def _remove_from_list_by_index(self, things_list, elem):
         for index, i in enumerate(things_list):
             if i['id'] == elem['id']:
-                break
-        del things_list[index]
+                del things_list[index]
+                return
 
     def _clean_network(self):
         body = self.client.list_ports()
diff --git a/neutron_tempest_plugin/api/test_qos.py b/neutron_tempest_plugin/api/test_qos.py
index ba7aad8..d31eab8 100644
--- a/neutron_tempest_plugin/api/test_qos.py
+++ b/neutron_tempest_plugin/api/test_qos.py
@@ -585,7 +585,7 @@
 
 
 class QosBandwidthLimitRuleWithDirectionTestJSON(
-    QosBandwidthLimitRuleTestJSON):
+        QosBandwidthLimitRuleTestJSON):
 
     required_extensions = (
         QosBandwidthLimitRuleTestJSON.required_extensions +
diff --git a/neutron_tempest_plugin/api/test_subnetpools.py b/neutron_tempest_plugin/api/test_subnetpools.py
index dc822e3..ec3753a 100644
--- a/neutron_tempest_plugin/api/test_subnetpools.py
+++ b/neutron_tempest_plugin/api/test_subnetpools.py
@@ -52,9 +52,9 @@
 class SubnetPoolsTest(SubnetPoolsTestBase):
 
     min_prefixlen = '28'
-    max_prefixlen = '31'
+    max_prefixlen = '30'
     _ip_version = 4
-    subnet_cidr = u'10.11.12.0/31'
+    subnet_cidr = u'10.11.12.0/29'
     new_prefix = u'10.11.15.0/24'
     larger_prefix = u'10.11.0.0/16'
 
diff --git a/neutron_tempest_plugin/api/test_timestamp.py b/neutron_tempest_plugin/api/test_timestamp.py
index d65fff3..0e49776 100644
--- a/neutron_tempest_plugin/api/test_timestamp.py
+++ b/neutron_tempest_plugin/api/test_timestamp.py
@@ -27,7 +27,7 @@
 
     required_extensions = ["standard-attr-timestamp"]
 
-    ## attributes for subnetpool
+    # attributes for subnetpool
     min_prefixlen = '28'
     max_prefixlen = '31'
     _ip_version = 4
diff --git a/neutron_tempest_plugin/config.py b/neutron_tempest_plugin/config.py
index d6db315..65282cf 100644
--- a/neutron_tempest_plugin/config.py
+++ b/neutron_tempest_plugin/config.py
@@ -43,6 +43,10 @@
                help='Max number of networks per project. '
                     'Configure this only when project is limited with real '
                     'vlans in deployment.'),
+    cfg.StrOpt('l3_agent_mode',
+               help='The agent mode for L3 agents in the deployment. '
+                    'Configure this only when the single value is used by '
+                    'all agents in the deployment.'),
 ]
 
 # TODO(amuller): Redo configuration options registration as part of the planned
diff --git a/neutron_tempest_plugin/scenario/test_dvr.py b/neutron_tempest_plugin/scenario/test_dvr.py
index b1cba5a..fa2e9d4 100644
--- a/neutron_tempest_plugin/scenario/test_dvr.py
+++ b/neutron_tempest_plugin/scenario/test_dvr.py
@@ -14,6 +14,7 @@
 #    under the License.
 from tempest.common import utils
 from tempest.lib import decorators
+import testtools
 
 from neutron_lib import constants
 from neutron_tempest_plugin import config
@@ -54,6 +55,9 @@
         super(NetworkDvrTest, cls).skip_checks()
 
     @decorators.idempotent_id('3d73ec1a-2ec6-45a9-b0f8-04a283d9d344')
+    @testtools.skipUnless(
+        CONF.neutron_plugin_options.l3_agent_mode == 'dvr_snat',
+        "Need dvr_snat agent mode assumption.")
     def test_vm_reachable_through_compute(self):
         """Check that the VM is reachable through compute node.
 
diff --git a/neutron_tempest_plugin/scenario/test_migration.py b/neutron_tempest_plugin/scenario/test_migration.py
index 62c3642..5e081f1 100644
--- a/neutron_tempest_plugin/scenario/test_migration.py
+++ b/neutron_tempest_plugin/scenario/test_migration.py
@@ -19,11 +19,15 @@
 from neutron_lib import constants as const
 from tempest.common import utils
 from tempest.lib import decorators
+import testtools
 
 from neutron_tempest_plugin.common import utils as common_utils
+from neutron_tempest_plugin import config
 from neutron_tempest_plugin.scenario import base
 from neutron_tempest_plugin.scenario import test_dvr
 
+CONF = config.CONF
+
 
 class NetworkMigrationTestBase(base.BaseTempestTestCase,
                                test_dvr.NetworkTestMixin):
@@ -131,6 +135,9 @@
 class NetworkMigrationFromLegacy(NetworkMigrationTestBase):
 
     @decorators.idempotent_id('23724222-483a-4129-bc15-7a9278f3828b')
+    @testtools.skipUnless(
+        CONF.neutron_plugin_options.l3_agent_mode == 'dvr_snat',
+        "Need dvr_snat agent mode assumption.")
     def test_from_legacy_to_dvr(self):
         self._test_migration(before_dvr=False, before_ha=False,
                              after_dvr=True, after_ha=False)
@@ -141,6 +148,9 @@
                              after_dvr=False, after_ha=True)
 
     @decorators.idempotent_id('fe169f2c-6ed3-4eb0-8afe-2d540c4b49e2')
+    @testtools.skipUnless(
+        CONF.neutron_plugin_options.l3_agent_mode == 'dvr_snat',
+        "Need dvr_snat agent mode assumption.")
     def test_from_legacy_to_dvr_ha(self):
         self._test_migration(before_dvr=False, before_ha=False,
                              after_dvr=True, after_ha=True)
@@ -154,11 +164,17 @@
                              after_dvr=False, after_ha=False)
 
     @decorators.idempotent_id('42260eea-5d56-4d30-b62a-a62694dfe4d5')
+    @testtools.skipUnless(
+        CONF.neutron_plugin_options.l3_agent_mode == 'dvr_snat',
+        "Need dvr_snat agent mode assumption.")
     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')
+    @testtools.skipUnless(
+        CONF.neutron_plugin_options.l3_agent_mode == 'dvr_snat',
+        "Need dvr_snat agent mode assumption.")
     def test_from_ha_to_dvr_ha(self):
         self._test_migration(before_dvr=False, before_ha=True,
                              after_dvr=True, after_ha=True)
@@ -167,16 +183,25 @@
 class NetworkMigrationFromDVR(NetworkMigrationTestBase):
 
     @decorators.idempotent_id('e5cac02c-248d-4aac-bd5e-9d47c5197307')
+    @testtools.skipUnless(
+        CONF.neutron_plugin_options.l3_agent_mode == 'dvr_snat',
+        "Need dvr_snat agent mode assumption.")
     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')
+    @testtools.skipUnless(
+        CONF.neutron_plugin_options.l3_agent_mode == 'dvr_snat',
+        "Need dvr_snat agent mode assumption.")
     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')
+    @testtools.skipUnless(
+        CONF.neutron_plugin_options.l3_agent_mode == 'dvr_snat',
+        "Need dvr_snat agent mode assumption.")
     def test_from_dvr_to_dvr_ha(self):
         self._test_migration(before_dvr=True, before_ha=False,
                              after_dvr=True, after_ha=True)
@@ -184,17 +209,29 @@
 
 class NetworkMigrationFromDVRHA(NetworkMigrationTestBase):
 
+    @common_utils.unstable_test("bug 1756301")
     @decorators.idempotent_id('1be9b2e2-379c-40a4-a269-6687b81df691')
+    @testtools.skipUnless(
+        CONF.neutron_plugin_options.l3_agent_mode == 'dvr_snat',
+        "Need dvr_snat agent mode assumption.")
     def test_from_dvr_ha_to_legacy(self):
         self._test_migration(before_dvr=True, before_ha=True,
                              after_dvr=False, after_ha=False)
 
+    @common_utils.unstable_test("bug 1756301")
     @decorators.idempotent_id('55957267-4e84-4314-a2f7-7cd36a2df04b')
+    @testtools.skipUnless(
+        CONF.neutron_plugin_options.l3_agent_mode == 'dvr_snat',
+        "Need dvr_snat agent mode assumption.")
     def test_from_dvr_ha_to_ha(self):
         self._test_migration(before_dvr=True, before_ha=True,
                              after_dvr=False, after_ha=True)
 
+    @common_utils.unstable_test("bug 1756301")
     @decorators.idempotent_id('d6bedff1-72be-4a9a-8ea2-dc037cd838e0')
+    @testtools.skipUnless(
+        CONF.neutron_plugin_options.l3_agent_mode == 'dvr_snat',
+        "Need dvr_snat agent mode assumption.")
     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/requirements.txt b/requirements.txt
index 63cb933..2ecce4e 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -15,4 +15,4 @@
 ddt>=1.0.1 # MIT
 testtools>=2.2.0 # MIT
 testscenarios>=0.4 # Apache-2.0/BSD
-eventlet!=0.18.3,!=0.20.1,<0.21.0,>=0.18.2 # MIT
+eventlet!=0.18.3,!=0.20.1,>=0.18.2 # MIT
diff --git a/tox.ini b/tox.ini
index c16664d..06eda94 100644
--- a/tox.ini
+++ b/tox.ini
@@ -44,14 +44,11 @@
 # H404 multi line docstring should start with a summary
 # H405 multi line docstring summary not separated with an empty line
 # N530 direct neutron imports not allowed
-# TODO(ihrachys) figure out what to do with N534 and N536
-# N534 Untranslated exception message
-# N536 Use assertIsNone rather than assertEqual to check for None values
-ignore = E125,E126,E128,E129,E265,H404,H405,N530,N534,N536
+ignore = E125,E126,E128,E129,E265,H404,H405,N530
 # H106: Don't put vim configuration in source files
 # H203: Use assertIs(Not)None to check for None
 # H904: Delay string interpolations at logging calls
-enable-extensions=H106,H203,H904
+enable-extensions = H106,H203,H904
 show-source = true
-exclude = ./.*,build,dist,doc
+exclude = ./.*,build,dist,doc,*egg*,releasenotes
 import-order-style = pep8