Merge "Allow to configure max vlans for trunk port tests"
diff --git a/neutron_tempest_plugin/config.py b/neutron_tempest_plugin/config.py
index 804fece..d6db315 100644
--- a/neutron_tempest_plugin/config.py
+++ b/neutron_tempest_plugin/config.py
@@ -38,6 +38,11 @@
                help='The availability zone for all agents in the deployment. '
                     'Configure this only when the single value is used by '
                     'all agents in the deployment.'),
+    cfg.IntOpt('max_networks_per_project',
+               default=4,
+               help='Max number of networks per project. '
+                    'Configure this only when project is limited with real '
+                    'vlans in deployment.'),
 ]
 
 # TODO(amuller): Redo configuration options registration as part of the planned
diff --git a/neutron_tempest_plugin/scenario/test_trunk.py b/neutron_tempest_plugin/scenario/test_trunk.py
index 0008b0a..44f5ba7 100644
--- a/neutron_tempest_plugin/scenario/test_trunk.py
+++ b/neutron_tempest_plugin/scenario/test_trunk.py
@@ -173,9 +173,12 @@
             exception=RuntimeError("Timed out waiting for trunk %s to "
                                    "transition to ACTIVE." % trunk2_id))
         # create a few more networks and ports for subports
+        # check limit of networks per project
+        max_vlan = 3 + CONF.neutron_plugin_options.max_networks_per_project
+        allowed_vlans = range(3, max_vlan)
         subports = [{'port_id': self.create_port(self.create_network())['id'],
                      'segmentation_type': 'vlan', 'segmentation_id': seg_id}
-                    for seg_id in range(3, 7)]
+                    for seg_id in allowed_vlans]
         # add all subports to server1
         self.client.add_subports(trunk1_id, subports)
         # ensure trunk transitions to ACTIVE