Merge "Fix test failures for "test_list_shares_by_{filter}""
This commit is contained in:
@@ -146,8 +146,11 @@ class SharesListReadWriteTest(base.BaseTestCase):
|
|||||||
public=True,
|
public=True,
|
||||||
client=self.admin_client)
|
client=self.admin_client)
|
||||||
|
|
||||||
for share_id in (self.private_share['id'], self.public_share['id'],
|
self.shares_created = (self.private_share['id'],
|
||||||
self.admin_private_share['id']):
|
self.public_share['id'],
|
||||||
|
self.admin_private_share['id'])
|
||||||
|
|
||||||
|
for share_id in self.shares_created:
|
||||||
self.admin_client.wait_for_resource_status(
|
self.admin_client.wait_for_resource_status(
|
||||||
share_id, constants.STATUS_AVAILABLE)
|
share_id, constants.STATUS_AVAILABLE)
|
||||||
|
|
||||||
@@ -159,18 +162,34 @@ class SharesListReadWriteTest(base.BaseTestCase):
|
|||||||
if filters:
|
if filters:
|
||||||
for share in shares:
|
for share in shares:
|
||||||
try:
|
try:
|
||||||
get = self.user_client.get_share(share['ID'])
|
share_get = self.user_client.get_share(share['ID'])
|
||||||
except exceptions.NotFound:
|
except exceptions.NotFound:
|
||||||
# NOTE(vponomaryov): Case when some share was deleted
|
# NOTE(vponomaryov): Case when some share was deleted
|
||||||
# between our 'list' and 'get' requests. Skip such case.
|
# between our 'list' and 'get' requests. Skip such case.
|
||||||
# It occurs with concurrently running tests.
|
# It occurs with concurrently running tests.
|
||||||
continue
|
continue
|
||||||
for k, v in filters.items():
|
if share_get['status'] == 'migrating':
|
||||||
if k in ('share_network', 'share-network'):
|
# all bets are off, a fair chance share migration
|
||||||
k = 'share_network_id'
|
# started between the 'list' and 'get' requests. No need
|
||||||
if v != 'deleting' and get[k] == 'deleting':
|
# to verify these shares.
|
||||||
|
continue
|
||||||
|
for filter_key, expected_value in filters.items():
|
||||||
|
if filter_key in ('share_network', 'share-network'):
|
||||||
|
filter_key = 'share_network_id'
|
||||||
|
if share_get[filter_key] != expected_value:
|
||||||
|
# Possibly a mismatch because the share was
|
||||||
|
# migrated to a new network in the time that
|
||||||
|
# elapsed between the 'list' and 'get' requests.
|
||||||
|
# If this isn't one of the shares created in
|
||||||
|
# this class, don't worry about such mismatches
|
||||||
|
self.assertNotIn(share_get[id],
|
||||||
|
self.shares_created)
|
||||||
|
continue
|
||||||
|
|
||||||
|
if (expected_value != 'deleting' and
|
||||||
|
share_get[filter_key] == 'deleting'):
|
||||||
continue
|
continue
|
||||||
self.assertEqual(v, get[k])
|
self.assertEqual(expected_value, share_get[filter_key])
|
||||||
|
|
||||||
def test_list_shares(self):
|
def test_list_shares(self):
|
||||||
self._list_shares()
|
self._list_shares()
|
||||||
|
|||||||
Reference in New Issue
Block a user