Use swiftclient Connections in sharding probe tests

This gets us retries "for free" and should reduce gate flakiness.

Cherry-Picked-From: Ia2e4c94f246230a3e25e4557b4b2c1a3a67df756
Change-Id: Icdf1f9d02d1e6ae5dc1112d2792ef6845067158b
This commit is contained in:
Tim Burke 2020-11-09 10:55:15 -08:00 committed by Pete Zaitcev
parent 959a98d7b1
commit 5791cec31e
1 changed files with 7 additions and 8 deletions

View File

@ -146,25 +146,24 @@ class BaseTestContainerSharding(ReplProbeTest):
wait_for_server_to_hangup(ipport)
def put_objects(self, obj_names, contents=None):
conn = client.Connection(preauthurl=self.url, preauthtoken=self.token)
results = []
for obj in obj_names:
rdict = {}
client.put_object(self.url, token=self.token,
container=self.container_name, name=obj,
contents=contents, response_dict=rdict)
conn.put_object(self.container_name, obj,
contents=contents, response_dict=rdict)
results.append((obj, rdict['headers'].get('x-object-version-id')))
return results
def delete_objects(self, obj_names_and_versions):
conn = client.Connection(preauthurl=self.url, preauthtoken=self.token)
for obj in obj_names_and_versions:
if isinstance(obj, tuple):
obj, version = obj
client.delete_object(
self.url, self.token, self.container_name, obj,
query_string='version-id=%s' % version)
conn.delete_object(self.container_name, obj,
query_string='version-id=%s' % version)
else:
client.delete_object(
self.url, self.token, self.container_name, obj)
conn.delete_object(self.container_name, obj)
def get_container_shard_ranges(self, account=None, container=None):
account = account if account else self.account