Use swiftclient Connections in sharding probe tests

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

Change-Id: Ia2e4c94f246230a3e25e4557b4b2c1a3a67df756
This commit is contained in:
Tim Burke 2020-11-09 10:55:15 -08:00
parent 2b79d0befd
commit 90c737e355

View File

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