Add share_size config option

All tempest tests create shares with fixed size, 1GB. This patch add
a config option in order to allow configurable share sizes as cinder
does (Cinder change-ID reference:
I2897f6d6bd970f73867f56d9d23a768cafcbfd80).

TrivialFix

Change-Id: Ifd09519b63c6c1a0ec8449e5dae1ffe0caa1b879
This commit is contained in:
marcusvrn 2016-06-24 12:27:55 -03:00
parent 76251ee893
commit cad4854114
11 changed files with 33 additions and 43 deletions

View File

@ -197,4 +197,7 @@ ShareGroup = [
default='none', default='none',
choices=['none', 'writable', 'readable', 'dr'], choices=['none', 'writable', 'readable', 'dr'],
help="Specify the replication type supported by the backend."), help="Specify the replication type supported by the backend."),
cfg.IntOpt("share_size",
default=1,
help="Default size in GB for shares created by share tests."),
] ]

View File

@ -47,8 +47,9 @@ class SharesClient(rest_client.RestClient):
self.share_network_id = CONF.share.share_network_id self.share_network_id = CONF.share.share_network_id
self.build_interval = CONF.share.build_interval self.build_interval = CONF.share.build_interval
self.build_timeout = CONF.share.build_timeout self.build_timeout = CONF.share.build_timeout
self.share_size = CONF.share.share_size
def create_share(self, share_protocol=None, size=1, def create_share(self, share_protocol=None, size=None,
name=None, snapshot_id=None, description=None, name=None, snapshot_id=None, description=None,
metadata=None, share_network_id=None, metadata=None, share_network_id=None,
share_type_id=None, is_public=False): share_type_id=None, is_public=False):
@ -57,6 +58,8 @@ class SharesClient(rest_client.RestClient):
name = data_utils.rand_name("tempest-created-share") name = data_utils.rand_name("tempest-created-share")
if description is None: if description is None:
description = data_utils.rand_name("tempest-created-share-desc") description = data_utils.rand_name("tempest-created-share-desc")
if size is None:
size = self.share_size
if share_protocol is None: if share_protocol is None:
share_protocol = self.share_protocol share_protocol = self.share_protocol
if share_protocol is None: if share_protocol is None:

View File

@ -187,7 +187,7 @@ class SharesV2Client(shares_client.SharesClient):
############### ###############
def create_share(self, share_protocol=None, size=1, def create_share(self, share_protocol=None, size=None,
name=None, snapshot_id=None, description=None, name=None, snapshot_id=None, description=None,
metadata=None, share_network_id=None, metadata=None, share_network_id=None,
share_type_id=None, is_public=False, share_type_id=None, is_public=False,
@ -198,6 +198,8 @@ class SharesV2Client(shares_client.SharesClient):
name = data_utils.rand_name("tempest-created-share") name = data_utils.rand_name("tempest-created-share")
if description is None: if description is None:
description = data_utils.rand_name("tempest-created-share-desc") description = data_utils.rand_name("tempest-created-share-desc")
if size is None:
size = self.share_size
if share_protocol is None: if share_protocol is None:
share_protocol = self.share_protocol share_protocol = self.share_protocol
if share_protocol is None: if share_protocol is None:

View File

@ -44,11 +44,9 @@ class ConsistencyGroupsNegativeTest(base.BaseSharesAdminTest):
# Create share inside consistency group # Create share inside consistency group
cls.share_name = data_utils.rand_name("tempest-share-name") cls.share_name = data_utils.rand_name("tempest-share-name")
cls.share_desc = data_utils.rand_name("tempest-share-description") cls.share_desc = data_utils.rand_name("tempest-share-description")
cls.share_size = 1
cls.share = cls.create_share( cls.share = cls.create_share(
name=cls.share_name, name=cls.share_name,
description=cls.share_desc, description=cls.share_desc,
size=cls.share_size,
consistency_group_id=cls.consistency_group['id'], consistency_group_id=cls.consistency_group['id'],
share_type_id=cls.share_type['id'], share_type_id=cls.share_type['id'],
) )
@ -93,7 +91,6 @@ class ConsistencyGroupsNegativeTest(base.BaseSharesAdminTest):
self.assertRaises(exceptions.BadRequest, self.create_share, self.assertRaises(exceptions.BadRequest, self.create_share,
name=self.share_name, name=self.share_name,
description=self.share_desc, description=self.share_desc,
size=self.share_size,
consistency_group_id=consistency_group['id'], consistency_group_id=consistency_group['id'],
cleanup_in_class=False, cleanup_in_class=False,
version='2.4') version='2.4')
@ -105,7 +102,6 @@ class ConsistencyGroupsNegativeTest(base.BaseSharesAdminTest):
self.assertRaises(exceptions.BadRequest, self.create_share, self.assertRaises(exceptions.BadRequest, self.create_share,
name=self.share_name, name=self.share_name,
description=self.share_desc, description=self.share_desc,
size=self.share_size,
consistency_group_id=consistency_group['id'], consistency_group_id=consistency_group['id'],
cleanup_in_class=False, cleanup_in_class=False,
version='2.4') version='2.4')
@ -117,7 +113,6 @@ class ConsistencyGroupsNegativeTest(base.BaseSharesAdminTest):
self.assertRaises(exceptions.BadRequest, self.create_share, self.assertRaises(exceptions.BadRequest, self.create_share,
name=self.share_name, name=self.share_name,
description=self.share_desc, description=self.share_desc,
size=self.share_size,
consistency_group_id=consistency_group['id'], consistency_group_id=consistency_group['id'],
cleanup_in_class=False, cleanup_in_class=False,
version='2.4') version='2.4')
@ -166,11 +161,9 @@ class ConsistencyGroupsNegativeTest(base.BaseSharesAdminTest):
consistency_group = self.create_consistency_group(version='2.4') consistency_group = self.create_consistency_group(version='2.4')
share_name = data_utils.rand_name("tempest-share-name") share_name = data_utils.rand_name("tempest-share-name")
share_desc = data_utils.rand_name("tempest-share-description") share_desc = data_utils.rand_name("tempest-share-description")
share_size = 1
share = self.create_share( share = self.create_share(
name=share_name, name=share_name,
description=share_desc, description=share_desc,
size=share_size,
consistency_group_id=consistency_group['id'], consistency_group_id=consistency_group['id'],
cleanup_in_class=False, cleanup_in_class=False,
version='2.4', version='2.4',

View File

@ -49,11 +49,9 @@ class SharesActionsAdminTest(base.BaseSharesAdminTest):
'foo_key_share_1': 'foo_value_share_1', 'foo_key_share_1': 'foo_value_share_1',
'bar_key_share_1': 'foo_value_share_1', 'bar_key_share_1': 'foo_value_share_1',
} }
cls.share_size = 1
cls.shares.append(cls.create_share( cls.shares.append(cls.create_share(
name=cls.share_name, name=cls.share_name,
description=cls.share_desc, description=cls.share_desc,
size=cls.share_size,
metadata=cls.metadata, metadata=cls.metadata,
share_type_id=cls.st['share_type']['id'], share_type_id=cls.st['share_type']['id'],
)) ))
@ -77,7 +75,6 @@ class SharesActionsAdminTest(base.BaseSharesAdminTest):
cls.shares.append(cls.create_share( cls.shares.append(cls.create_share(
name=cls.share_name2, name=cls.share_name2,
description=cls.share_desc2, description=cls.share_desc2,
size=cls.share_size,
metadata=cls.metadata2, metadata=cls.metadata2,
snapshot_id=cls.snap['id'], snapshot_id=cls.snap['id'],
)) ))
@ -105,9 +102,9 @@ class SharesActionsAdminTest(base.BaseSharesAdminTest):
share["description"]) share["description"])
self.assertEqual(self.share_desc, str(share["description"]), msg) self.assertEqual(self.share_desc, str(share["description"]), msg)
msg = "Expected size: '%s', actual size: '%s'" % (self.share_size, msg = "Expected size: '%s', actual size: '%s'" % (
share["size"]) CONF.share.share_size, share["size"])
self.assertEqual(self.share_size, int(share["size"]), msg) self.assertEqual(CONF.share.share_size, int(share["size"]), msg)
@test.attr(type=[base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND]) @test.attr(type=[base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND])
def test_list_shares(self): def test_list_shares(self):

View File

@ -349,7 +349,7 @@ class BaseSharesTest(test.BaseTestCase):
return share_network_id return share_network_id
@classmethod @classmethod
def _create_share(cls, share_protocol=None, size=1, name=None, def _create_share(cls, share_protocol=None, size=None, name=None,
snapshot_id=None, description=None, metadata=None, snapshot_id=None, description=None, metadata=None,
share_network_id=None, share_type_id=None, share_network_id=None, share_type_id=None,
consistency_group_id=None, client=None, consistency_group_id=None, client=None,
@ -358,6 +358,7 @@ class BaseSharesTest(test.BaseTestCase):
description = description or "Tempest's share" description = description or "Tempest's share"
share_network_id = share_network_id or client.share_network_id or None share_network_id = share_network_id or client.share_network_id or None
metadata = metadata or {} metadata = metadata or {}
size = size or CONF.share.share_size
kwargs.update({ kwargs.update({
'share_protocol': share_protocol, 'share_protocol': share_protocol,
'size': size, 'size': size,

View File

@ -54,8 +54,8 @@ class ConsistencyGroupActionsTest(base.BaseSharesTest):
# Create 2 shares inside first CG and 1 inside second CG # Create 2 shares inside first CG and 1 inside second CG
cls.share_name = data_utils.rand_name("tempest-share-name") cls.share_name = data_utils.rand_name("tempest-share-name")
cls.share_desc = data_utils.rand_name("tempest-share-description") cls.share_desc = data_utils.rand_name("tempest-share-description")
cls.share_size = 1 cls.share_size = CONF.share.share_size
cls.share_size2 = 2 cls.share_size2 = cls.share_size + 1
cls.shares = cls.create_shares([ cls.shares = cls.create_shares([
{'kwargs': { {'kwargs': {
'name': cls.share_name, 'name': cls.share_name,

View File

@ -121,11 +121,9 @@ class ConsistencyGroupsNegativeTest(base.BaseSharesTest):
# Create a share in the consistency group # Create a share in the consistency group
cls.share_name = data_utils.rand_name("tempest-share-name") cls.share_name = data_utils.rand_name("tempest-share-name")
cls.share_desc = data_utils.rand_name("tempest-share-description") cls.share_desc = data_utils.rand_name("tempest-share-description")
cls.share_size = 1
cls.share = cls.create_share( cls.share = cls.create_share(
name=cls.share_name, name=cls.share_name,
description=cls.share_desc, description=cls.share_desc,
size=cls.share_size,
consistency_group_id=cls.consistency_group['id'], consistency_group_id=cls.consistency_group['id'],
) )
# Create a cgsnapshot of the consistency group # Create a cgsnapshot of the consistency group

View File

@ -44,11 +44,9 @@ class SharesActionsTest(base.BaseSharesTest):
'foo_key_share_1': 'foo_value_share_1', 'foo_key_share_1': 'foo_value_share_1',
'bar_key_share_1': 'foo_value_share_1', 'bar_key_share_1': 'foo_value_share_1',
} }
cls.share_size = 1
cls.shares.append(cls.create_share( cls.shares.append(cls.create_share(
name=cls.share_name, name=cls.share_name,
description=cls.share_desc, description=cls.share_desc,
size=cls.share_size,
metadata=cls.metadata, metadata=cls.metadata,
)) ))
@ -71,7 +69,6 @@ class SharesActionsTest(base.BaseSharesTest):
cls.shares.append(cls.create_share( cls.shares.append(cls.create_share(
name=cls.share_name2, name=cls.share_name2,
description=cls.share_desc2, description=cls.share_desc2,
size=cls.share_size,
metadata=cls.metadata2, metadata=cls.metadata2,
snapshot_id=cls.snap['id'], snapshot_id=cls.snap['id'],
)) ))
@ -118,9 +115,9 @@ class SharesActionsTest(base.BaseSharesTest):
self.assertEqual( self.assertEqual(
self.share_desc, six.text_type(share["description"]), msg) self.share_desc, six.text_type(share["description"]), msg)
msg = "Expected size: '%s', actual size: '%s'" % (self.share_size, msg = "Expected size: '%s', actual size: '%s'" % (
share["size"]) CONF.share.share_size, share["size"])
self.assertEqual(self.share_size, int(share["size"]), msg) self.assertEqual(CONF.share.share_size, int(share["size"]), msg)
@test.attr(type=[base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND]) @test.attr(type=[base.TAG_POSITIVE, base.TAG_API_WITH_BACKEND])
def test_get_share_v2_1(self): def test_get_share_v2_1(self):
@ -369,14 +366,12 @@ class SharesActionsTest(base.BaseSharesTest):
public_share = self.create_share( public_share = self.create_share(
name='public_share', name='public_share',
description='public_share_desc', description='public_share_desc',
size=1,
is_public=True, is_public=True,
cleanup_in_class=False cleanup_in_class=False
) )
private_share = self.create_share( private_share = self.create_share(
name='private_share', name='private_share',
description='private_share_desc', description='private_share_desc',
size=1,
is_public=False, is_public=False,
cleanup_in_class=False cleanup_in_class=False
) )
@ -563,8 +558,8 @@ class SharesActionsTest(base.BaseSharesTest):
CONF.share.run_extend_tests, CONF.share.run_extend_tests,
"Share extend tests are disabled.") "Share extend tests are disabled.")
def test_extend_share(self): def test_extend_share(self):
share = self.create_share(size=1, cleanup_in_class=False) share = self.create_share(cleanup_in_class=False)
new_size = 2 new_size = int(share['size']) + 1
# extend share and wait for active status # extend share and wait for active status
self.shares_v2_client.extend_share(share['id'], new_size) self.shares_v2_client.extend_share(share['id'], new_size)
@ -586,8 +581,9 @@ class SharesActionsTest(base.BaseSharesTest):
CONF.share.run_shrink_tests, CONF.share.run_shrink_tests,
"Share shrink tests are disabled.") "Share shrink tests are disabled.")
def test_shrink_share(self): def test_shrink_share(self):
share = self.create_share(size=2, cleanup_in_class=False) size = CONF.share.share_size + 1
new_size = 1 share = self.create_share(size=size, cleanup_in_class=False)
new_size = int(share['size']) - 1
# shrink share and wait for active status # shrink share and wait for active status
self.shares_v2_client.shrink_share(share['id'], new_size) self.shares_v2_client.shrink_share(share['id'], new_size)
@ -614,10 +610,8 @@ class SharesRenameTest(base.BaseSharesTest):
# create share # create share
cls.share_name = data_utils.rand_name("tempest-share-name") cls.share_name = data_utils.rand_name("tempest-share-name")
cls.share_desc = data_utils.rand_name("tempest-share-description") cls.share_desc = data_utils.rand_name("tempest-share-description")
cls.share_size = 1
cls.share = cls.create_share( cls.share = cls.create_share(
name=cls.share_name, description=cls.share_desc, name=cls.share_name, description=cls.share_desc)
size=cls.share_size)
if CONF.share.run_snapshot_tests: if CONF.share.run_snapshot_tests:
# create snapshot # create snapshot

View File

@ -28,9 +28,7 @@ class SharesActionsNegativeTest(base.BaseSharesMixedTest):
def resource_setup(cls): def resource_setup(cls):
super(SharesActionsNegativeTest, cls).resource_setup() super(SharesActionsNegativeTest, cls).resource_setup()
cls.admin_client = cls.admin_shares_v2_client cls.admin_client = cls.admin_shares_v2_client
cls.share = cls.create_share( cls.share = cls.create_share()
size=1,
)
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND]) @test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
@testtools.skipUnless( @testtools.skipUnless(
@ -81,7 +79,7 @@ class SharesActionsNegativeTest(base.BaseSharesMixedTest):
CONF.share.run_extend_tests, CONF.share.run_extend_tests,
"Share extend tests are disabled.") "Share extend tests are disabled.")
def test_share_extend_with_invalid_share_state(self): def test_share_extend_with_invalid_share_state(self):
share = self.create_share(size=1, cleanup_in_class=False) share = self.create_share(cleanup_in_class=False)
new_size = int(share['size']) + 1 new_size = int(share['size']) + 1
# set "error" state # set "error" state
@ -124,7 +122,8 @@ class SharesActionsNegativeTest(base.BaseSharesMixedTest):
CONF.share.run_shrink_tests, CONF.share.run_shrink_tests,
"Share shrink tests are disabled.") "Share shrink tests are disabled.")
def test_share_shrink_with_invalid_share_state(self): def test_share_shrink_with_invalid_share_state(self):
share = self.create_share(size=2, cleanup_in_class=False) size = CONF.share.share_size + 1
share = self.create_share(size=size, cleanup_in_class=False)
new_size = int(share['size']) - 1 new_size = int(share['size']) - 1
# set "error" state # set "error" state

View File

@ -31,7 +31,6 @@ class SharesNegativeTest(base.BaseSharesTest):
cls.share = cls.create_share( cls.share = cls.create_share(
name='public_share', name='public_share',
description='public_share_desc', description='public_share_desc',
size=1,
is_public=True, is_public=True,
metadata={'key': 'value'} metadata={'key': 'value'}
) )
@ -67,7 +66,8 @@ class SharesNegativeTest(base.BaseSharesTest):
skip_msg = "Check disc space for this test" skip_msg = "Check disc space for this test"
try: # create share try: # create share
share = self.create_share(size=2, cleanup_in_class=False) size = CONF.share.share_size + 1
share = self.create_share(size=size, cleanup_in_class=False)
except share_exceptions.ShareBuildErrorException: except share_exceptions.ShareBuildErrorException:
self.skip(skip_msg) self.skip(skip_msg)
@ -80,7 +80,7 @@ class SharesNegativeTest(base.BaseSharesTest):
# try create share from snapshot with less size # try create share from snapshot with less size
self.assertRaises(lib_exc.BadRequest, self.assertRaises(lib_exc.BadRequest,
self.create_share, self.create_share,
size=1, snapshot_id=snap["id"], snapshot_id=snap["id"],
cleanup_in_class=False) cleanup_in_class=False)
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND]) @test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])