Merge "Add waiter for object creation"

This commit is contained in:
Zuul 2022-08-10 11:44:24 +00:00 committed by Gerrit Code Review
commit 13036879e2
4 changed files with 25 additions and 0 deletions

View File

@ -16,6 +16,7 @@
import time
from tempest.common import custom_matchers
from tempest.common import waiters
from tempest import config
from tempest.lib.common.utils import data_utils
from tempest.lib import exceptions as lib_exc
@ -124,6 +125,9 @@ class BaseObjectTest(tempest.test.BaseTestCase):
object_name,
data,
metadata=metadata)
waiters.wait_for_object_create(cls.object_client,
container_name,
object_name)
return object_name, data
# after bucket creation we might see Conflict
except lib_exc.Conflict as e:

View File

@ -15,6 +15,7 @@
from tempest.api.object_storage import base
from tempest.common import utils
from tempest.common import waiters
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from tempest.lib import exceptions as lib_exc
@ -91,6 +92,9 @@ class ContainerQuotasTest(base.BaseObjectTest):
for _ in range(QUOTA_COUNT):
name = data_utils.rand_name(name="TestObject")
self.object_client.create_object(self.container_name, name, "")
waiters.wait_for_object_create(self.object_client,
self.container_name,
name)
nbefore = self._get_object_count()
self.assertEqual(nbefore, QUOTA_COUNT)

View File

@ -612,3 +612,17 @@ def wait_for_caching(client, cache_client, image_id):
if caller:
message = '(%s) %s' % (caller, message)
raise lib_exc.TimeoutException(message)
def wait_for_object_create(object_client, container_name, object_name,
interval=1):
"""Waits for created object to become available"""
start_time = time.time()
while time.time() - start_time < object_client.build_timeout:
try:
return object_client.get_object(container_name, object_name)
except lib_exc.NotFound:
time.sleep(interval)
message = ('Object %s failed to create within the required time (%s s).' %
(object_name, object_client.build_timeout))
raise lib_exc.TimeoutException(message)

View File

@ -1148,6 +1148,9 @@ ObjectStoreGroup = [
help="One name of cluster which is set in the realm whose name "
"is set in 'realm_name' item in this file. Set the "
"same cluster name as Swift's container-sync-realms.conf"),
cfg.IntOpt('build_timeout',
default=10,
help="Timeout in seconds to wait for objects to create."),
]
object_storage_feature_group = cfg.OptGroup(