mirror of
https://github.com/ceph/s3-tests.git
synced 2024-11-25 13:47:27 +00:00
Add context, get_next_key, and fill_pools to s3tests.common
context is a generic Bunch that we can store items in to be shared across modules, without invoking the wrath of the globals -- yuck! get_next_key will generate a sequentially numbered key for us to use fill_pools will take a variable list of gevent.pool.Pool objects and top them all off
This commit is contained in:
parent
298bc99c5d
commit
b6e0287810
1 changed files with 15 additions and 0 deletions
|
@ -10,7 +10,13 @@ s3 = bunch.Bunch()
|
||||||
config = bunch.Bunch()
|
config = bunch.Bunch()
|
||||||
prefix = ''
|
prefix = ''
|
||||||
|
|
||||||
|
# For those scripts that use a context, these are pretty univerally needed.
|
||||||
|
context = bunch.Bunch(
|
||||||
|
bucket = None,
|
||||||
|
)
|
||||||
|
|
||||||
bucket_counter = itertools.count(1)
|
bucket_counter = itertools.count(1)
|
||||||
|
key_counter = itertools.count(1)
|
||||||
|
|
||||||
def choose_bucket_prefix(template, max_len=30):
|
def choose_bucket_prefix(template, max_len=30):
|
||||||
"""
|
"""
|
||||||
|
@ -156,3 +162,12 @@ def get_new_bucket(connection=None):
|
||||||
|
|
||||||
def teardown():
|
def teardown():
|
||||||
nuke_prefixed_buckets()
|
nuke_prefixed_buckets()
|
||||||
|
|
||||||
|
def fill_pools(*args):
|
||||||
|
for pool in args:
|
||||||
|
while not pool.full():
|
||||||
|
pool.spawn()
|
||||||
|
|
||||||
|
def get_next_key(bucket=None):
|
||||||
|
return bucket.new_key("seqkey-{num}".format(num=next(key_counter)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue