Merge "Add share_size config option"

This commit is contained in:
Jenkins 2016-06-29 22:47:45 +00:00 committed by Gerrit Code Review
commit 64b272b5ed
11 changed files with 33 additions and 43 deletions

View File

@ -195,4 +195,7 @@ ShareGroup = [
default='none',
choices=['none', 'writable', 'readable', 'dr'],
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.build_interval = CONF.share.build_interval
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,
metadata=None, share_network_id=None,
share_type_id=None, is_public=False):
@ -57,6 +58,8 @@ class SharesClient(rest_client.RestClient):
name = data_utils.rand_name("tempest-created-share")
if description is None:
description = data_utils.rand_name("tempest-created-share-desc")
if size is None:
size = self.share_size
if share_protocol is None:
share_protocol = self.share_protocol
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,
metadata=None, share_network_id=None,
share_type_id=None, is_public=False,
@ -198,6 +198,8 @@ class SharesV2Client(shares_client.SharesClient):
name = data_utils.rand_name("tempest-created-share")
if description is None:
description = data_utils.rand_name("tempest-created-share-desc")
if size is None:
size = self.share_size
if share_protocol is None:
share_protocol = self.share_protocol
if share_protocol is None:

View File

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

View File

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

View File

@ -349,7 +349,7 @@ class BaseSharesTest(test.BaseTestCase):
return share_network_id
@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,
share_network_id=None, share_type_id=None,
consistency_group_id=None, client=None,
@ -358,6 +358,7 @@ class BaseSharesTest(test.BaseTestCase):
description = description or "Tempest's share"
share_network_id = share_network_id or client.share_network_id or None
metadata = metadata or {}
size = size or CONF.share.share_size
kwargs.update({
'share_protocol': share_protocol,
'size': size,

View File

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

View File

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

View File

@ -28,9 +28,7 @@ class SharesActionsNegativeTest(base.BaseSharesMixedTest):
def resource_setup(cls):
super(SharesActionsNegativeTest, cls).resource_setup()
cls.admin_client = cls.admin_shares_v2_client
cls.share = cls.create_share(
size=1,
)
cls.share = cls.create_share()
@test.attr(type=[base.TAG_NEGATIVE, base.TAG_API_WITH_BACKEND])
@testtools.skipUnless(
@ -81,7 +79,7 @@ class SharesActionsNegativeTest(base.BaseSharesMixedTest):
CONF.share.run_extend_tests,
"Share extend tests are disabled.")
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
# set "error" state
@ -124,7 +122,8 @@ class SharesActionsNegativeTest(base.BaseSharesMixedTest):
CONF.share.run_shrink_tests,
"Share shrink tests are disabled.")
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
# set "error" state

View File

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