Merge "Add waiter for object creation"
This commit is contained in:
commit
13036879e2
@ -16,6 +16,7 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from tempest.common import custom_matchers
|
from tempest.common import custom_matchers
|
||||||
|
from tempest.common import waiters
|
||||||
from tempest import config
|
from tempest import config
|
||||||
from tempest.lib.common.utils import data_utils
|
from tempest.lib.common.utils import data_utils
|
||||||
from tempest.lib import exceptions as lib_exc
|
from tempest.lib import exceptions as lib_exc
|
||||||
@ -124,6 +125,9 @@ class BaseObjectTest(tempest.test.BaseTestCase):
|
|||||||
object_name,
|
object_name,
|
||||||
data,
|
data,
|
||||||
metadata=metadata)
|
metadata=metadata)
|
||||||
|
waiters.wait_for_object_create(cls.object_client,
|
||||||
|
container_name,
|
||||||
|
object_name)
|
||||||
return object_name, data
|
return object_name, data
|
||||||
# after bucket creation we might see Conflict
|
# after bucket creation we might see Conflict
|
||||||
except lib_exc.Conflict as e:
|
except lib_exc.Conflict as e:
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
from tempest.api.object_storage import base
|
from tempest.api.object_storage import base
|
||||||
from tempest.common import utils
|
from tempest.common import utils
|
||||||
|
from tempest.common import waiters
|
||||||
from tempest.lib.common.utils import data_utils
|
from tempest.lib.common.utils import data_utils
|
||||||
from tempest.lib import decorators
|
from tempest.lib import decorators
|
||||||
from tempest.lib import exceptions as lib_exc
|
from tempest.lib import exceptions as lib_exc
|
||||||
@ -91,6 +92,9 @@ class ContainerQuotasTest(base.BaseObjectTest):
|
|||||||
for _ in range(QUOTA_COUNT):
|
for _ in range(QUOTA_COUNT):
|
||||||
name = data_utils.rand_name(name="TestObject")
|
name = data_utils.rand_name(name="TestObject")
|
||||||
self.object_client.create_object(self.container_name, name, "")
|
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()
|
nbefore = self._get_object_count()
|
||||||
self.assertEqual(nbefore, QUOTA_COUNT)
|
self.assertEqual(nbefore, QUOTA_COUNT)
|
||||||
|
@ -612,3 +612,17 @@ def wait_for_caching(client, cache_client, image_id):
|
|||||||
if caller:
|
if caller:
|
||||||
message = '(%s) %s' % (caller, message)
|
message = '(%s) %s' % (caller, message)
|
||||||
raise lib_exc.TimeoutException(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)
|
||||||
|
@ -1148,6 +1148,9 @@ ObjectStoreGroup = [
|
|||||||
help="One name of cluster which is set in the realm whose name "
|
help="One name of cluster which is set in the realm whose name "
|
||||||
"is set in 'realm_name' item in this file. Set the "
|
"is set in 'realm_name' item in this file. Set the "
|
||||||
"same cluster name as Swift's container-sync-realms.conf"),
|
"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(
|
object_storage_feature_group = cfg.OptGroup(
|
||||||
|
Loading…
Reference in New Issue
Block a user