Fix update share network tests and skip exception issue

After fixing a bug that was allowing share network update when it
shouldn't, the test that validates the share network creation and
update started failing. An additional validation was introduced and
it caused the new bug. This patch fixes the test and make it work
properly.
In addition this patch fixes test classes that are raising a skip
exception inside the setUpClass function and failing due to testtool
issue #272.

Closes-Bug: #1849728
Closes-Bug: #1849377
Related-Bug: #1846836
Co-Author: Carlos Eduardo <ces.eduardo98@gmail.com>
Change-Id: I5b27ee4a9e844ea48dc9324bcf38f5767223717f
(cherry picked from commit 0ca91287ac)
This commit is contained in:
Douglas Viroel 2019-10-24 17:48:22 -03:00
parent 1f2440ee8b
commit 454ab51456
17 changed files with 196 additions and 212 deletions

View File

@ -202,7 +202,7 @@ class BaseTestCase(base.ClientTestBase):
snapshot_support=None, snapshot_support=None,
create_share_from_snapshot=None, create_share_from_snapshot=None,
revert_to_snapshot=None, mount_snapshot=None, revert_to_snapshot=None, mount_snapshot=None,
is_public=True, client=None, cleanup_in_class=True, is_public=True, client=None, cleanup_in_class=False,
microversion=None, extra_specs=None, microversion=None, extra_specs=None,
description=None): description=None):
if client is None: if client is None:
@ -257,7 +257,7 @@ class BaseTestCase(base.ClientTestBase):
neutron_net_id=None, neutron_net_id=None,
neutron_subnet_id=None, neutron_subnet_id=None,
availability_zone=None, client=None, availability_zone=None, client=None,
cleanup_in_class=True, microversion=None): cleanup_in_class=False, microversion=None):
if client is None: if client is None:
client = cls.get_admin_client() client = cls.get_admin_client()
share_network = client.create_share_network( share_network = client.create_share_network(
@ -284,7 +284,7 @@ class BaseTestCase(base.ClientTestBase):
def add_share_network_subnet(cls, share_network, def add_share_network_subnet(cls, share_network,
neutron_net_id=None, neutron_subnet_id=None, neutron_net_id=None, neutron_subnet_id=None,
availability_zone=None, client=None, availability_zone=None, client=None,
cleanup_in_class=True, microversion=None): cleanup_in_class=False, microversion=None):
if client is None: if client is None:
client = cls.get_admin_client() client = cls.get_admin_client()
share_network_subnet = client.add_share_network_subnet( share_network_subnet = client.add_share_network_subnet(

View File

@ -22,12 +22,10 @@ from manilaclient.tests.functional import base
@ddt.ddt @ddt.ddt
class ExportLocationReadWriteTest(base.BaseTestCase): class ExportLocationReadWriteTest(base.BaseTestCase):
@classmethod def setUp(self):
def setUpClass(cls): super(ExportLocationReadWriteTest, self).setUp()
super(ExportLocationReadWriteTest, cls).setUpClass() self.share = self.create_share(
cls.share = cls.create_share( client=self.get_user_client())
client=cls.get_user_client(),
cleanup_in_class=True)
@ddt.data('admin', 'user') @ddt.data('admin', 'user')
def test_list_share_export_locations(self, role): def test_list_share_export_locations(self, role):

View File

@ -31,10 +31,9 @@ class MessagesReadOnlyTest(base.BaseTestCase):
@ddt.ddt @ddt.ddt
class MessagesReadWriteTest(base.BaseTestCase): class MessagesReadWriteTest(base.BaseTestCase):
@classmethod def setUp(self):
def setUpClass(cls): super(MessagesReadWriteTest, self).setUp()
super(MessagesReadWriteTest, cls).setUpClass() self.message = self.create_message()
cls.message = cls.create_message(cleanup_in_class=True)
def test_list_messages(self): def test_list_messages(self):
self.skip_if_microversion_not_supported('2.37') self.skip_if_microversion_not_supported('2.37')

View File

@ -50,8 +50,7 @@ class QuotasReadWriteTest(base.BaseTestCase):
name=data_utils.rand_name("manilaclient_functional_test"), name=data_utils.rand_name("manilaclient_functional_test"),
driver_handles_share_servers=False, driver_handles_share_servers=False,
is_public=True, is_public=True,
microversion=self.microversion, microversion=self.microversion
cleanup_in_class=False,
) )
self.st_id = self.share_type["ID"] self.st_id = self.share_type["ID"]

View File

@ -22,17 +22,16 @@ from manilaclient.tests.functional import base
@ddt.ddt @ddt.ddt
class SecurityServiceReadWriteTest(base.BaseTestCase): class SecurityServiceReadWriteTest(base.BaseTestCase):
@classmethod def setUp(self):
def setUpClass(cls): super(SecurityServiceReadWriteTest, self).setUp()
super(SecurityServiceReadWriteTest, cls).setUpClass() self.name = data_utils.rand_name('autotest')
cls.name = data_utils.rand_name('autotest') self.description = 'fake_description'
cls.description = 'fake_description' self.user = 'fake_user'
cls.user = 'fake_user' self.password = 'fake_password'
cls.password = 'fake_password' self.server = 'fake_server'
cls.server = 'fake_server' self.domain = 'fake_domain'
cls.domain = 'fake_domain' self.dns_ip = '1.2.3.4'
cls.dns_ip = '1.2.3.4' self.ou = 'fake_ou'
cls.ou = 'fake_ou'
@ddt.data( @ddt.data(
{'name': 'test_name'}, {'name': 'test_name'},

View File

@ -30,34 +30,32 @@ class ShareAccessReadWriteBase(base.BaseTestCase):
protocol = None protocol = None
access_level = None access_level = None
@classmethod def setUp(self):
def setUpClass(cls): super(ShareAccessReadWriteBase, self).setUp()
super(ShareAccessReadWriteBase, cls).setUpClass() if self.protocol not in CONF.enable_protocols:
if cls.protocol not in CONF.enable_protocols: message = "%s tests are disabled." % self.protocol
message = "%s tests are disabled." % cls.protocol raise self.skipException(message)
raise cls.skipException(message) if self.access_level not in CONF.access_levels_mapping.get(
if cls.access_level not in CONF.access_levels_mapping.get( self.protocol, '').split(' '):
cls.protocol, '').split(' '): raise self.skipException("%(level)s tests for %(protocol)s share "
raise cls.skipException("%(level)s tests for %(protocol)s share " "access are disabled." % {
"access are disabled." % { 'level': self.access_level,
'level': cls.access_level, 'protocol': self.protocol
'protocol': cls.protocol })
}) self.access_types = CONF.access_types_mapping.get(
cls.access_types = CONF.access_types_mapping.get( self.protocol, '').split(' ')
cls.protocol, '').split(' ') if not self.access_types:
if not cls.access_types: raise self.skipException("No access levels were provided for %s "
raise cls.skipException("No access levels were provided for %s " "share access tests." % self.protocol)
"share access tests." % cls.protoco)
cls.share = cls.create_share(share_protocol=cls.protocol, self.share = self.create_share(share_protocol=self.protocol,
public=True, public=True)
cleanup_in_class=True) self.share_id = self.share['id']
cls.share_id = cls.share['id']
# NOTE(vponomaryov): increase following int range when significant # NOTE(vponomaryov): increase following int range when significant
# amount of new tests is added. # amount of new tests is added.
int_range = range(20, 50) int_range = range(20, 50)
cls.access_to = { self.access_to = {
# NOTE(vponomaryov): list of unique values is required for ability # NOTE(vponomaryov): list of unique values is required for ability
# to create lots of access rules for one share using different # to create lots of access rules for one share using different
# API microversions. # API microversions.

View File

@ -24,19 +24,18 @@ from tempest.lib import exceptions
@utils.skip_if_microversion_not_supported('2.51') @utils.skip_if_microversion_not_supported('2.51')
class ShareNetworkSubnetsReadWriteTest(base.BaseTestCase): class ShareNetworkSubnetsReadWriteTest(base.BaseTestCase):
@classmethod def setUp(self):
def setUpClass(cls): super(ShareNetworkSubnetsReadWriteTest, self).setUp()
super(ShareNetworkSubnetsReadWriteTest, cls).setUpClass() self.name = data_utils.rand_name('autotest')
cls.name = data_utils.rand_name('autotest') self.description = 'fake_description'
cls.description = 'fake_description' self.neutron_net_id = 'fake_neutron_net_id'
cls.neutron_net_id = 'fake_neutron_net_id' self.neutron_subnet_id = 'fake_neutron_subnet_id'
cls.neutron_subnet_id = 'fake_neutron_subnet_id'
cls.sn = cls.create_share_network( self.sn = self.create_share_network(
name=cls.name, name=self.name,
description=cls.description, description=self.description,
neutron_net_id=cls.neutron_net_id, neutron_net_id=self.neutron_net_id,
neutron_subnet_id=cls.neutron_subnet_id, neutron_subnet_id=self.neutron_subnet_id,
) )
def test_get_share_network_subnet(self): def test_get_share_network_subnet(self):

View File

@ -26,19 +26,18 @@ from manilaclient.tests.functional import utils
@ddt.ddt @ddt.ddt
class ShareNetworksReadWriteTest(base.BaseTestCase): class ShareNetworksReadWriteTest(base.BaseTestCase):
@classmethod def setUp(self):
def setUpClass(cls): super(ShareNetworksReadWriteTest, self).setUp()
super(ShareNetworksReadWriteTest, cls).setUpClass() self.name = data_utils.rand_name('autotest')
cls.name = data_utils.rand_name('autotest') self.description = 'fake_description'
cls.description = 'fake_description' self.neutron_net_id = 'fake_neutron_net_id'
cls.neutron_net_id = 'fake_neutron_net_id' self.neutron_subnet_id = 'fake_neutron_subnet_id'
cls.neutron_subnet_id = 'fake_neutron_subnet_id'
cls.sn = cls.create_share_network( self.sn = self.create_share_network(
name=cls.name, name=self.name,
description=cls.description, description=self.description,
neutron_net_id=cls.neutron_net_id, neutron_net_id=self.neutron_net_id,
neutron_subnet_id=cls.neutron_subnet_id, neutron_subnet_id=self.neutron_subnet_id,
) )
@ddt.data( @ddt.data(
@ -125,33 +124,56 @@ class ShareNetworksReadWriteTest(base.BaseTestCase):
self.assertEqual(self.neutron_net_id, get['neutron_net_id']) self.assertEqual(self.neutron_net_id, get['neutron_net_id'])
self.assertEqual(self.neutron_subnet_id, get['neutron_subnet_id']) self.assertEqual(self.neutron_subnet_id, get['neutron_subnet_id'])
def _get_expected_update_data(self, net_data, net_creation_data):
# NOTE(dviroel): When subnets are supported, the outputs are converted
# from string to literal structures in order to process the content of
# 'share_network_subnets' field.
default_return_value = (
None if utils.share_network_subnets_are_supported() else 'None')
expected_nn_id = (
default_return_value
if net_data.get('neutron_net_id')
else net_creation_data.get('neutron_net_id', default_return_value))
expected_nsn_id = (
default_return_value
if net_data.get('neutron_subnet_id')
else net_creation_data.get('neutron_subnet_id',
default_return_value))
return expected_nn_id, expected_nsn_id
@ddt.data( @ddt.data(
{'name': data_utils.rand_name('autotest_share_network_name')}, ({'name': data_utils.rand_name('autotest_share_network_name')}, {}),
{'description': 'fake_description'}, ({'description': 'fake_description'}, {}),
{'neutron_net_id': 'fake_neutron_net_id', ({'neutron_net_id': 'fake_neutron_net_id',
'neutron_subnet_id': 'fake_neutron_subnet_id'}, 'neutron_subnet_id': 'fake_neutron_subnet_id'}, {}),
{'name': '""'}, ({'name': '""'}, {}),
{'description': '""'}, ({'description': '""'}, {}),
{'neutron_net_id': '""'}, ({'neutron_net_id': '""'},
{'neutron_subnet_id': '""'}, {'neutron_net_id': 'fake_nn_id', 'neutron_subnet_id': 'fake_nsn_id'}),
({'neutron_subnet_id': '""'},
{'neutron_net_id': 'fake_nn_id', 'neutron_subnet_id': 'fake_nsn_id'})
) )
def test_create_update_share_network(self, net_data): @ddt.unpack
sn = self.create_share_network(cleanup_in_class=False) def test_create_update_share_network(self, net_data, net_creation_data):
sn = self.create_share_network(
cleanup_in_class=False, **net_creation_data)
update = self.admin_client.update_share_network(sn['id'], **net_data) update = self.admin_client.update_share_network(sn['id'], **net_data)
expected_nn_id, expected_nsn_id = self._get_expected_update_data(
net_data, net_creation_data)
expected_data = { expected_data = {
'name': 'None', 'name': 'None',
'description': 'None', 'description': 'None',
'neutron_net_id': 'None', 'neutron_net_id': expected_nn_id,
'neutron_subnet_id': 'None', 'neutron_subnet_id': expected_nsn_id,
} }
subnet_keys = [] subnet_keys = []
if utils.share_network_subnets_are_supported(): if utils.share_network_subnets_are_supported():
subnet_keys = ['neutron_net_id', 'neutron_subnet_id'] subnet_keys = ['neutron_net_id', 'neutron_subnet_id']
subnet = ast.literal_eval(update['share_network_subnets']) subnet = ast.literal_eval(update['share_network_subnets'])
expected_data['neutron_net_id'] = None
expected_data['neutron_subnet_id'] = None
update_values = dict([(k, v) for k, v in net_data.items() update_values = dict([(k, v) for k, v in net_data.items()
if v != '""']) if v != '""'])

View File

@ -29,16 +29,11 @@ CONF = config.CONF
@utils.skip_if_microversion_not_supported('2.47') @utils.skip_if_microversion_not_supported('2.47')
class ShareReplicaExportLocationsTest(base.BaseTestCase): class ShareReplicaExportLocationsTest(base.BaseTestCase):
@classmethod
def setUpClass(cls):
super(ShareReplicaExportLocationsTest, cls).setUpClass()
def _create_share_and_replica(self): def _create_share_and_replica(self):
replication_type = CONF.replication_type replication_type = CONF.replication_type
share_type = self.create_share_type( share_type = self.create_share_type(
driver_handles_share_servers=False, driver_handles_share_servers=False,
extra_specs={'replication_type': replication_type}, extra_specs={'replication_type': replication_type})
cleanup_in_class=False)
share = self.create_share(share_type=share_type['ID'], share = self.create_share(share_type=share_type['ID'],
client=self.get_user_client()) client=self.get_user_client())
share_replica = self.create_share_replica(share['id']) share_replica = self.create_share_replica(share['id'])

View File

@ -30,10 +30,9 @@ CONF = config.CONF
@ddt.ddt @ddt.ddt
class ShareServersReadOnlyTest(base.BaseTestCase): class ShareServersReadOnlyTest(base.BaseTestCase):
@classmethod def setUp(self):
def setUpClass(cls): super(ShareServersReadOnlyTest, self).setUp()
super(ShareServersReadOnlyTest, cls).setUpClass() self.client = self.get_admin_client()
cls.client = cls.get_admin_client()
def test_share_server_list(self): def test_share_server_list(self):
self.client.list_share_servers() self.client.list_share_servers()
@ -68,20 +67,19 @@ class ShareServersReadWriteBase(base.BaseTestCase):
protocol = None protocol = None
@classmethod def setUp(self):
def setUpClass(cls): super(ShareServersReadWriteBase, self).setUp()
super(ShareServersReadWriteBase, cls).setUpClass()
if not CONF.run_share_servers_tests: if not CONF.run_share_servers_tests:
message = "share-servers tests are disabled." message = "share-servers tests are disabled."
raise cls.skipException(message) raise self.skipException(message)
if cls.protocol not in CONF.enable_protocols: if self.protocol not in CONF.enable_protocols:
message = "%s tests are disabled." % cls.protocol message = "%s tests are disabled." % self.protocol
raise cls.skipException(message) raise self.skipException(message)
cls.client = cls.get_admin_client() self.client = self.get_admin_client()
if not cls.client.share_network: if not self.client.share_network:
message = "Can run only with DHSS=True mode" message = "Can run only with DHSS=True mode"
raise cls.skipException(message) raise self.skipException(message)
def _create_share_and_share_network(self): def _create_share_and_share_network(self):
name = data_utils.rand_name('autotest_share_name') name = data_utils.rand_name('autotest_share_name')

View File

@ -29,24 +29,22 @@ CONF = config.CONF
class SharesReadWriteBase(base.BaseTestCase): class SharesReadWriteBase(base.BaseTestCase):
protocol = None protocol = None
@classmethod def setUp(self):
def setUpClass(cls): super(SharesReadWriteBase, self).setUp()
super(SharesReadWriteBase, cls).setUpClass() if self.protocol not in CONF.enable_protocols:
if cls.protocol not in CONF.enable_protocols: message = "%s tests are disabled" % self.protocol
message = "%s tests are disabled" % cls.protocol raise self.skipException(message)
raise cls.skipException(message) self.name = data_utils.rand_name('autotest_share_name')
cls.name = data_utils.rand_name('autotest_share_name') self.description = data_utils.rand_name('autotest_share_description')
cls.description = data_utils.rand_name('autotest_share_description')
# NOTE(vponomaryov): following share is used only in one test # NOTE(vponomaryov): following share is used only in one test
# until tests for snapshots appear. # until tests for snapshots appear.
cls.share = cls.create_share( self.share = self.create_share(
share_protocol=cls.protocol, share_protocol=self.protocol,
size=1, size=1,
name=cls.name, name=self.name,
description=cls.description, description=self.description,
client=cls.get_user_client(), client=self.get_user_client())
cleanup_in_class=True)
def test_create_delete_share(self): def test_create_delete_share(self):
name = data_utils.rand_name('autotest_share_name') name = data_utils.rand_name('autotest_share_name')
@ -96,29 +94,28 @@ class SharesReadWriteBase(base.BaseTestCase):
@ddt.ddt @ddt.ddt
class SharesTestMigration(base.BaseTestCase): class SharesTestMigration(base.BaseTestCase):
@classmethod def setUp(self):
def setUpClass(cls): super(SharesTestMigration, self).setUp()
super(SharesTestMigration, cls).setUpClass()
cls.old_type = cls.create_share_type( self.old_type = self.create_share_type(
data_utils.rand_name('test_share_type'), data_utils.rand_name('test_share_type'),
driver_handles_share_servers=True) driver_handles_share_servers=True)
cls.new_type = cls.create_share_type( self.new_type = self.create_share_type(
data_utils.rand_name('test_share_type'), data_utils.rand_name('test_share_type'),
driver_handles_share_servers=True) driver_handles_share_servers=True)
cls.error_type = cls.create_share_type( self.error_type = self.create_share_type(
data_utils.rand_name('test_share_type'), data_utils.rand_name('test_share_type'),
driver_handles_share_servers=True, driver_handles_share_servers=True,
extra_specs={'cause_error': 'no_valid_host'}) extra_specs={'cause_error': 'no_valid_host'})
cls.old_share_net = cls.get_user_client().get_share_network( self.old_share_net = self.get_user_client().get_share_network(
cls.get_user_client().share_network) self.get_user_client().share_network)
share_net_info = ( share_net_info = (
utils.get_default_subnet(cls.get_user_client(), utils.get_default_subnet(self.get_user_client(),
cls.old_share_net['id']) self.old_share_net['id'])
if utils.share_network_subnets_are_supported() if utils.share_network_subnets_are_supported()
else cls.old_share_net) else self.old_share_net)
cls.new_share_net = cls.create_share_network( self.new_share_net = self.create_share_network(
neutron_net_id=share_net_info['neutron_net_id'], neutron_net_id=share_net_info['neutron_net_id'],
neutron_subnet_id=share_net_info['neutron_subnet_id']) neutron_subnet_id=share_net_info['neutron_subnet_id'])

View File

@ -112,47 +112,43 @@ class SharesListReadOnlyTest(base.BaseTestCase):
@ddt.ddt @ddt.ddt
class SharesListReadWriteTest(base.BaseTestCase): class SharesListReadWriteTest(base.BaseTestCase):
@classmethod def setUp(self):
def setUpClass(cls): super(SharesListReadWriteTest, self).setUp()
super(SharesListReadWriteTest, cls).setUpClass() self.private_name = data_utils.rand_name('autotest_share_name')
cls.private_name = data_utils.rand_name('autotest_share_name') self.private_description = data_utils.rand_name(
cls.private_description = data_utils.rand_name(
'autotest_share_description') 'autotest_share_description')
cls.public_name = data_utils.rand_name('autotest_public_share_name') self.public_name = data_utils.rand_name('autotest_public_share_name')
cls.public_description = data_utils.rand_name( self.public_description = data_utils.rand_name(
'autotest_public_share_description') 'autotest_public_share_description')
cls.admin_private_name = data_utils.rand_name( self.admin_private_name = data_utils.rand_name(
'autotest_admin_private_share_name') 'autotest_admin_private_share_name')
cls.admin_private_description = data_utils.rand_name( self.admin_private_description = data_utils.rand_name(
'autotest_admin_private_share_description') 'autotest_admin_private_share_description')
cls.admin_private_share = cls.create_share( self.admin_private_share = self.create_share(
name=cls.admin_private_name, name=self.admin_private_name,
description=cls.admin_private_description, description=self.admin_private_description,
public=False, public=False,
cleanup_in_class=True,
client=None, client=None,
wait_for_creation=False) wait_for_creation=False)
cls.private_share = cls.create_share( self.private_share = self.create_share(
name=cls.private_name, name=self.private_name,
description=cls.private_description, description=self.private_description,
public=False, public=False,
cleanup_in_class=True, client=self.get_user_client(),
client=cls.get_user_client(),
wait_for_creation=False) wait_for_creation=False)
cls.public_share = cls.create_share( self.public_share = self.create_share(
name=cls.public_name, name=self.public_name,
description=cls.public_description, description=self.public_description,
public=True, public=True,
client=cls.get_user_client(), client=self.get_user_client())
cleanup_in_class=True)
for share_id in (cls.private_share['id'], cls.public_share['id'], for share_id in (self.private_share['id'], self.public_share['id'],
cls.admin_private_share['id']): self.admin_private_share['id']):
cls.get_admin_client().wait_for_resource_status( self.get_admin_client().wait_for_resource_status(
share_id, constants.STATUS_AVAILABLE) share_id, constants.STATUS_AVAILABLE)
def _list_shares(self, filters=None): def _list_shares(self, filters=None):
@ -319,8 +315,7 @@ class SharesListReadWriteTest(base.BaseTestCase):
name=u'共享名称', name=u'共享名称',
description=u'共享描述', description=u'共享描述',
public=True, public=True,
client=self.get_user_client(), client=self.get_user_client())
cleanup_in_class=True)
filters = {'name~': u'名称'} filters = {'name~': u'名称'}
shares = self.user_client.list_shares(filters=filters) shares = self.user_client.list_shares(filters=filters)
self.assertGreater(len(shares), 0) self.assertGreater(len(shares), 0)

View File

@ -21,19 +21,15 @@ from manilaclient.tests.functional import base
@ddt.ddt @ddt.ddt
class SharesMetadataReadWriteTest(base.BaseTestCase): class SharesMetadataReadWriteTest(base.BaseTestCase):
@classmethod def setUp(self):
def setUpClass(cls): super(SharesMetadataReadWriteTest, self).setUp()
super(SharesMetadataReadWriteTest, cls).setUpClass() self.share = self.create_share(client=self.get_user_client())
cls.share = cls.create_share(
client=cls.get_user_client(),
cleanup_in_class=True)
def test_set_metadata_in_share_creation(self): def test_set_metadata_in_share_creation(self):
md = {"key1": "value1", "key2": "value2"} md = {"key1": "value1", "key2": "value2"}
# Create share with metadata # Create share with metadata
share = self.create_share( share = self.create_share(metadata=md, client=self.get_user_client())
metadata=md, cleanup_in_class=False, client=self.get_user_client())
# Read share metadata # Read share metadata
metadata = self.user_client.get_share_metadata(share["id"]) metadata = self.user_client.get_share_metadata(share["id"])

View File

@ -26,25 +26,23 @@ CONF = config.CONF
class SnapshotAccessReadBase(base.BaseTestCase): class SnapshotAccessReadBase(base.BaseTestCase):
protocol = None protocol = None
@classmethod def setUp(self):
def setUpClass(cls): super(SnapshotAccessReadBase, self).setUp()
super(SnapshotAccessReadBase, cls).setUpClass() if self.protocol not in CONF.enable_protocols:
if cls.protocol not in CONF.enable_protocols: message = "%s tests are disabled." % self.protocol
message = "%s tests are disabled." % cls.protocol raise self.skipException(message)
raise cls.skipException(message) self.access_types = CONF.access_types_mapping.get(
cls.access_types = CONF.access_types_mapping.get( self.protocol, '').split(' ')
cls.protocol, '').split(' ') if not self.access_types:
if not cls.access_types: raise self.skipException("No access types were provided for %s "
raise cls.skipException("No access types were provided for %s " "snapshot access tests." % self.protocol)
"snapshot access tests." % cls.protocol)
cls.share = cls.create_share(share_protocol=cls.protocol, self.share = self.create_share(share_protocol=self.protocol,
public=True, public=True,
cleanup_in_class=True, client=self.get_user_client())
client=cls.get_user_client())
int_range = range(0, 10) int_range = range(0, 10)
cls.access_to = { self.access_to = {
'ip': ['99.88.77.%d' % i for i in int_range], 'ip': ['99.88.77.%d' % i for i in int_range],
'user': ['foo_user_%d' % i for i in int_range], 'user': ['foo_user_%d' % i for i in int_range],
'cert': ['tenant_%d.example.com' % i for i in int_range], 'cert': ['tenant_%d.example.com' % i for i in int_range],

View File

@ -30,15 +30,12 @@ CONF = config.CONF
@utils.skip_if_microversion_not_supported('2.19') @utils.skip_if_microversion_not_supported('2.19')
class SnapshotInstancesTest(base.BaseTestCase): class SnapshotInstancesTest(base.BaseTestCase):
@classmethod def setUp(self):
def setUpClass(cls): super(SnapshotInstancesTest, self).setUp()
super(SnapshotInstancesTest, cls).setUpClass() self.share = self.create_share(
cls.share = cls.create_share( client=self.get_user_client())
client=cls.get_user_client(), self.snapshot = self.create_snapshot(share=self.share['id'],
cleanup_in_class=True) client=self.get_user_client())
cls.snapshot = cls.create_snapshot(share=cls.share['id'],
client=cls.get_user_client(),
cleanup_in_class=True)
def test_list_all_snapshot_instances(self): def test_list_all_snapshot_instances(self):
snapshot_instances = self.admin_client.list_snapshot_instances() snapshot_instances = self.admin_client.list_snapshot_instances()

View File

@ -31,15 +31,12 @@ CONF = config.CONF
@utils.skip_if_microversion_not_supported('2.32') @utils.skip_if_microversion_not_supported('2.32')
class SnapshotInstanceExportLocationReadWriteTest(base.BaseTestCase): class SnapshotInstanceExportLocationReadWriteTest(base.BaseTestCase):
@classmethod def setUp(self):
def setUpClass(cls): super(SnapshotInstanceExportLocationReadWriteTest, self).setUp()
super(SnapshotInstanceExportLocationReadWriteTest, cls).setUpClass() self.share = self.create_share(
cls.share = cls.create_share( client=self.get_user_client())
client=cls.get_user_client(), self.snapshot = self.create_snapshot(share=self.share['id'],
cleanup_in_class=True) client=self.get_user_client())
cls.snapshot = cls.create_snapshot(share=cls.share['id'],
client=cls.get_user_client(),
cleanup_in_class=True)
def test_get_snapshot_instance_export_location(self): def test_get_snapshot_instance_export_location(self):
client = self.admin_client client = self.admin_client

View File

@ -31,15 +31,12 @@ CONF = config.CONF
@utils.skip_if_microversion_not_supported('2.32') @utils.skip_if_microversion_not_supported('2.32')
class SnapshotExportLocationReadWriteTest(base.BaseTestCase): class SnapshotExportLocationReadWriteTest(base.BaseTestCase):
@classmethod def setUp(self):
def setUpClass(cls): super(SnapshotExportLocationReadWriteTest, self).setUp()
super(SnapshotExportLocationReadWriteTest, cls).setUpClass() self.share = self.create_share(
cls.share = cls.create_share( client=self.get_user_client())
client=cls.get_user_client(), self.snapshot = self.create_snapshot(share=self.share['id'],
cleanup_in_class=True) client=self.get_user_client())
cls.snapshot = cls.create_snapshot(share=cls.share['id'],
client=cls.get_user_client(),
cleanup_in_class=True)
@ddt.data('admin', 'user') @ddt.data('admin', 'user')
def test_get_snapshot_export_location(self, role): def test_get_snapshot_export_location(self, role):