diff --git a/neutron_tempest_plugin/api/test_trunk.py b/neutron_tempest_plugin/api/test_trunk.py index 6c781ab4..e02cf929 100644 --- a/neutron_tempest_plugin/api/test_trunk.py +++ b/neutron_tempest_plugin/api/test_trunk.py @@ -54,8 +54,20 @@ class TrunkTestJSONBase(base.BaseAdminNetworkTest): trunks_cleanup(cls.client, cls.trunks) super(TrunkTestJSONBase, cls).resource_cleanup() - def _create_trunk_with_network_and_parent(self, subports, **kwargs): - network = self.create_network() + @classmethod + def is_type_driver_enabled(cls, type_driver): + return (type_driver in + config.CONF.neutron_plugin_options.available_type_drivers) + + def _create_trunk_with_network_and_parent( + self, subports, parent_network_type=None, **kwargs): + client = None + network_kwargs = {} + if parent_network_type: + client = self.admin_client + network_kwargs = {"provider:network_type": parent_network_type, + "tenant_id": self.client.tenant_id} + network = self.create_network(client=client, **network_kwargs) parent_port = self.create_port(network) trunk = self.client.create_trunk(parent_port['id'], subports, **kwargs) self.trunks.append(trunk['trunk']) @@ -266,9 +278,7 @@ class TrunkTestMtusJSONBase(TrunkTestJSONBase): @classmethod def skip_checks(cls): super(TrunkTestMtusJSONBase, cls).skip_checks() - if any(t - not in config.CONF.neutron_plugin_options.available_type_drivers - for t in ['gre', 'vxlan']): + if not all(cls.is_type_driver_enabled(t) for t in ['gre', 'vxlan']): msg = "Either vxlan or gre type driver not enabled." raise cls.skipException(msg) diff --git a/neutron_tempest_plugin/api/test_trunk_negative.py b/neutron_tempest_plugin/api/test_trunk_negative.py index 699b26f5..4d7ead12 100644 --- a/neutron_tempest_plugin/api/test_trunk_negative.py +++ b/neutron_tempest_plugin/api/test_trunk_negative.py @@ -13,6 +13,7 @@ # under the License. from oslo_utils import uuidutils +from tempest.common import utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc import testtools @@ -103,8 +104,14 @@ class TrunkTestJSON(test_trunk.TrunkTestJSONBase): @decorators.attr(type='negative') @decorators.idempotent_id('40aed9be-e976-47d0-dada-bde2c7e74e57') + @utils.requires_ext(extension="provider", service="network") def test_create_subport_invalid_inherit_network_segmentation_type(self): - trunk = self._create_trunk_with_network_and_parent([]) + if not self.is_type_driver_enabled('vxlan'): + msg = "Vxlan type driver must be enabled for this test." + raise self.skipException(msg) + + trunk = self._create_trunk_with_network_and_parent( + subports=[], parent_network_type='vxlan') subport_network = self.create_network() parent_port = self.create_port(subport_network) self.assertRaises(lib_exc.BadRequest, self.client.add_subports,