Merge "Improve Tempest tests for consistency groups"
This commit is contained in:
commit
bb5ea3a12c
@ -70,31 +70,16 @@ class ConsistencyGroupActionsTest(base.BaseSharesAdminTest):
|
||||
def test_create_cg_from_multi_typed_populated_cgsnapshot_v2_4(self):
|
||||
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(
|
||||
cleanup_in_class=False,
|
||||
name=share_name,
|
||||
description=share_desc,
|
||||
size=share_size,
|
||||
consistency_group_id=self.consistency_group['id'],
|
||||
share_type_id=self.share_type['id'],
|
||||
client=self.shares_v2_client,
|
||||
version='2.4',
|
||||
)
|
||||
|
||||
share_name2 = data_utils.rand_name("tempest-share-name")
|
||||
share_desc2 = data_utils.rand_name("tempest-share-description")
|
||||
share_size2 = 1
|
||||
share2 = self.create_share(
|
||||
cleanup_in_class=False,
|
||||
name=share_name2,
|
||||
description=share_desc2,
|
||||
size=share_size2,
|
||||
consistency_group_id=self.consistency_group['id'],
|
||||
share_type_id=self.share_type2['id'],
|
||||
client=self.shares_v2_client,
|
||||
version='2.4',
|
||||
)
|
||||
shares = self.create_shares([
|
||||
{'kwargs': {
|
||||
'cleanup_in_class': False,
|
||||
'name': share_name,
|
||||
'description': share_desc,
|
||||
'consistency_group_id': self.consistency_group['id'],
|
||||
'share_type_id': st_id,
|
||||
}} for st_id in (self.share_type['id'], self.share_type2['id'])
|
||||
])
|
||||
|
||||
cg_shares = self.shares_v2_client.list_shares(
|
||||
detailed=True,
|
||||
@ -103,7 +88,7 @@ class ConsistencyGroupActionsTest(base.BaseSharesAdminTest):
|
||||
)
|
||||
|
||||
cg_share_ids = [s['id'] for s in cg_shares]
|
||||
for share_id in [share['id'], share2['id']]:
|
||||
for share_id in (shares[0]['id'], shares[1]['id']):
|
||||
self.assertIn(share_id, cg_share_ids, 'Share %s not in '
|
||||
'consistency group %s.' %
|
||||
(share_id, self.consistency_group['id']))
|
||||
|
@ -39,78 +39,52 @@ class ConsistencyGroupActionsTest(base.BaseSharesTest):
|
||||
@classmethod
|
||||
def resource_setup(cls):
|
||||
super(ConsistencyGroupActionsTest, cls).resource_setup()
|
||||
# Create consistency group
|
||||
|
||||
# Create first consistency group
|
||||
cls.cg_name = data_utils.rand_name("tempest-cg-name")
|
||||
cls.cg_desc = data_utils.rand_name("tempest-cg-description")
|
||||
cls.consistency_group = cls.create_consistency_group(
|
||||
name=cls.cg_name,
|
||||
description=cls.cg_desc,
|
||||
)
|
||||
|
||||
# Create 2 shares 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'],
|
||||
metadata={'key': 'value'},
|
||||
client=cls.shares_v2_client,
|
||||
)
|
||||
|
||||
cls.share_name2 = data_utils.rand_name("tempest-share-name")
|
||||
cls.share_desc2 = data_utils.rand_name("tempest-share-description")
|
||||
cls.share_size2 = 2
|
||||
cls.share2 = cls.create_share(
|
||||
name=cls.share_name2,
|
||||
description=cls.share_desc2,
|
||||
size=cls.share_size2,
|
||||
consistency_group_id=cls.consistency_group['id'],
|
||||
client=cls.shares_v2_client,
|
||||
)
|
||||
|
||||
cls.cgsnap_name = data_utils.rand_name("tempest-cgsnap-name")
|
||||
cls.cgsnap_desc = data_utils.rand_name("tempest-cgsnap-description")
|
||||
cls.cgsnapshot = cls.create_cgsnapshot_wait_for_active(
|
||||
cls.consistency_group["id"],
|
||||
name=cls.cgsnap_name,
|
||||
description=cls.cgsnap_desc)
|
||||
cls.cg = cls.create_consistency_group(
|
||||
name=cls.cg_name, description=cls.cg_desc)
|
||||
|
||||
# Create second consistency group for purposes of sorting and snapshot
|
||||
# filtering
|
||||
cls.cg_name2 = data_utils.rand_name("tempest-cg-name")
|
||||
cls.cg_desc2 = data_utils.rand_name("tempest-cg-description")
|
||||
cls.consistency_group2 = cls.create_consistency_group(
|
||||
name=cls.cg_name2,
|
||||
description=cls.cg_desc2,
|
||||
)
|
||||
cls.cg2 = cls.create_consistency_group(
|
||||
name=cls.cg_name, description=cls.cg_desc)
|
||||
|
||||
# Create 1 share in second consistency group
|
||||
cls.share_name3 = data_utils.rand_name("tempest-share-name")
|
||||
cls.share_desc3 = data_utils.rand_name("tempest-share-description")
|
||||
cls.share3 = cls.create_share(
|
||||
name=cls.share_name3,
|
||||
description=cls.share_desc3,
|
||||
size=cls.share_size,
|
||||
consistency_group_id=cls.consistency_group2['id'],
|
||||
client=cls.shares_v2_client,
|
||||
)
|
||||
# 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.shares = cls.create_shares([
|
||||
{'kwargs': {
|
||||
'name': cls.share_name,
|
||||
'description': cls.share_desc,
|
||||
'size': size,
|
||||
'consistency_group_id': cg_id,
|
||||
}} for size, cg_id in ((cls.share_size, cls.cg['id']),
|
||||
(cls.share_size2, cls.cg['id']),
|
||||
(cls.share_size, cls.cg2['id']))
|
||||
])
|
||||
|
||||
# Create CG snapshots
|
||||
cls.cgsnap_name = data_utils.rand_name("tempest-cgsnap-name")
|
||||
cls.cgsnap_desc = data_utils.rand_name("tempest-cgsnap-description")
|
||||
|
||||
cls.cgsnapshot = cls.create_cgsnapshot_wait_for_active(
|
||||
cls.cg["id"],
|
||||
name=cls.cgsnap_name,
|
||||
description=cls.cgsnap_desc)
|
||||
|
||||
cls.cgsnap_name2 = data_utils.rand_name("tempest-cgsnap-name")
|
||||
cls.cgsnap_desc2 = data_utils.rand_name("tempest-cgsnap-description")
|
||||
cls.cgsnapshot2 = cls.create_cgsnapshot_wait_for_active(
|
||||
cls.consistency_group2['id'],
|
||||
name=cls.cgsnap_name2,
|
||||
description=cls.cgsnap_desc2)
|
||||
cls.cg2['id'], name=cls.cgsnap_name, description=cls.cgsnap_desc)
|
||||
|
||||
@test.attr(type=["gate", ])
|
||||
def test_get_consistency_group_v2_4(self):
|
||||
|
||||
# Get consistency group
|
||||
consistency_group = self.shares_v2_client.get_consistency_group(
|
||||
self.consistency_group['id'], version='2.4')
|
||||
self.cg['id'], version='2.4')
|
||||
|
||||
# Verify keys
|
||||
actual_keys = set(consistency_group.keys())
|
||||
@ -135,7 +109,7 @@ class ConsistencyGroupActionsTest(base.BaseSharesTest):
|
||||
def test_get_share_v2_4(self):
|
||||
|
||||
# Get share
|
||||
share = self.shares_v2_client.get_share(self.share['id'],
|
||||
share = self.shares_v2_client.get_share(self.shares[0]['id'],
|
||||
version='2.4')
|
||||
|
||||
# Verify keys
|
||||
@ -164,9 +138,8 @@ class ConsistencyGroupActionsTest(base.BaseSharesTest):
|
||||
self.assertEqual(self.share_size, int(share["size"]), msg)
|
||||
|
||||
msg = "Expected consistency_group_id: '%s', actual value: '%s'" % (
|
||||
self.consistency_group["id"], share["consistency_group_id"])
|
||||
self.assertEqual(
|
||||
self.consistency_group["id"], share["consistency_group_id"], msg)
|
||||
self.cg["id"], share["consistency_group_id"])
|
||||
self.assertEqual(self.cg["id"], share["consistency_group_id"], msg)
|
||||
|
||||
@test.attr(type=["gate", ])
|
||||
def test_list_consistency_groups_v2_4(self):
|
||||
@ -180,8 +153,7 @@ class ConsistencyGroupActionsTest(base.BaseSharesTest):
|
||||
consistency_groups]
|
||||
|
||||
# Consistency group ids are in list exactly once
|
||||
for cg_id in [self.consistency_group["id"],
|
||||
self.consistency_group2["id"]]:
|
||||
for cg_id in (self.cg["id"], self.cg2["id"]):
|
||||
gen = [cgid["id"] for cgid in consistency_groups
|
||||
if cgid["id"] == cg_id]
|
||||
msg = ("Expected id %s exactly once in consistency group list" %
|
||||
@ -200,8 +172,7 @@ class ConsistencyGroupActionsTest(base.BaseSharesTest):
|
||||
for cg in consistency_groups]
|
||||
|
||||
# Consistency group ids are in list exactly once
|
||||
for cg_id in [self.consistency_group["id"],
|
||||
self.consistency_group2["id"]]:
|
||||
for cg_id in (self.cg["id"], self.cg2["id"]):
|
||||
gen = [cgid["id"] for cgid in consistency_groups
|
||||
if cgid["id"] == cg_id]
|
||||
msg = ("Expected id %s exactly once in consistency group list" %
|
||||
@ -213,7 +184,7 @@ class ConsistencyGroupActionsTest(base.BaseSharesTest):
|
||||
|
||||
shares = self.shares_v2_client.list_shares(
|
||||
detailed=True,
|
||||
params={'consistency_group_id': self.consistency_group['id']},
|
||||
params={'consistency_group_id': self.cg['id']},
|
||||
version='2.4'
|
||||
)
|
||||
|
||||
@ -222,18 +193,19 @@ class ConsistencyGroupActionsTest(base.BaseSharesTest):
|
||||
self.assertEqual(2, len(shares),
|
||||
'Incorrect number of shares returned. Expected 2, '
|
||||
'got %s' % len(shares))
|
||||
self.assertIn(self.share['id'], share_ids,
|
||||
self.assertIn(self.shares[0]['id'], share_ids,
|
||||
'Share %s expected in returned list, but got %s'
|
||||
% (self.share['id'], share_ids))
|
||||
self.assertIn(self.share2['id'], share_ids,
|
||||
% (self.shares[0]['id'], share_ids))
|
||||
self.assertIn(self.shares[1]['id'], share_ids,
|
||||
'Share %s expected in returned list, but got %s'
|
||||
% (self.share['id'], share_ids))
|
||||
% (self.shares[0]['id'], share_ids))
|
||||
|
||||
@test.attr(type=["gate", ])
|
||||
def test_get_cgsnapshot_v2_4(self):
|
||||
|
||||
# Get consistency group
|
||||
consistency_group = self.shares_v2_client.get_consistency_group(
|
||||
self.consistency_group['id'], version='2.4')
|
||||
self.cg['id'], version='2.4')
|
||||
|
||||
# Verify keys
|
||||
actual_keys = set(consistency_group.keys())
|
||||
@ -265,11 +237,11 @@ class ConsistencyGroupActionsTest(base.BaseSharesTest):
|
||||
'Unexpected number of cgsnapshot members. Expected '
|
||||
'2, got %s.' % len(cgsnapshot_members))
|
||||
# Verify each share is represented in the cgsnapshot appropriately
|
||||
for share_id in [self.share['id'], self.share2['id']]:
|
||||
for share_id in (self.shares[0]['id'], self.shares[1]['id']):
|
||||
self.assertIn(share_id, member_share_ids,
|
||||
'Share missing %s missing from cgsnapshot. Found %s.'
|
||||
% (share_id, member_share_ids))
|
||||
for share in [self.share, self.share2]:
|
||||
for share in (self.shares[0], self.shares[1]):
|
||||
for member in cgsnapshot_members:
|
||||
if share['id'] == member['share_id']:
|
||||
self.assertEqual(share['size'], member['size'])
|
||||
|
Loading…
x
Reference in New Issue
Block a user