py3: Fix up probe tests

Change-Id: Ic0f54f393002e2170e7f1459625ee5a2b37df900
This commit is contained in:
Tim Burke 2020-02-03 13:01:51 -08:00
parent 01b1d60cd9
commit ff885d30e4
2 changed files with 9 additions and 8 deletions

View File

@ -14,13 +14,13 @@
from __future__ import print_function from __future__ import print_function
import functools import functools
import sys import sys
from io import BytesIO
import itertools import itertools
import uuid import uuid
from optparse import OptionParser from optparse import OptionParser
import random import random
import six import six
from six import StringIO
from six.moves.urllib.parse import urlparse, parse_qs, quote from six.moves.urllib.parse import urlparse, parse_qs, quote
from swift.common.manager import Manager from swift.common.manager import Manager
@ -233,7 +233,7 @@ def translate_client_exception(m):
return m(*args, **kwargs) return m(*args, **kwargs)
except UnexpectedResponse as err: except UnexpectedResponse as err:
raise ClientException( raise ClientException(
err.message, err.args[0],
http_scheme=err.resp.environ['wsgi.url_scheme'], http_scheme=err.resp.environ['wsgi.url_scheme'],
http_host=err.resp.environ['SERVER_NAME'], http_host=err.resp.environ['SERVER_NAME'],
http_port=err.resp.environ['SERVER_PORT'], http_port=err.resp.environ['SERVER_PORT'],
@ -274,7 +274,7 @@ class InternalBrainClient(object):
@translate_client_exception @translate_client_exception
def put_object(self, container_name, object_name, headers, contents, def put_object(self, container_name, object_name, headers, contents,
query_string=None): query_string=None):
return self.swift.upload_object(StringIO(contents), self.account, return self.swift.upload_object(BytesIO(contents), self.account,
container_name, object_name, container_name, object_name,
headers=headers, headers=headers,
params=self.parse_qs(query_string)) params=self.parse_qs(query_string))
@ -294,7 +294,7 @@ class InternalBrainClient(object):
status, headers, resp_iter = self.swift.get_object( status, headers, resp_iter = self.swift.get_object(
self.account, container_name, object_name, self.account, container_name, object_name,
params=self.parse_qs(query_string)) params=self.parse_qs(query_string))
return headers, ''.join(resp_iter) return headers, b''.join(resp_iter)
@six.add_metaclass(meta_command) @six.add_metaclass(meta_command)

View File

@ -358,9 +358,10 @@ class TestContainerMergePolicyIndex(ReplProbeTest):
for i in range(20))) for i in range(20)))
# and regular upload should work now too # and regular upload should work now too
self.brain.client.put_object(self.container_name, self.object_name, {}, self.brain.client.put_object(
utils.json.dumps(manifest_data), self.container_name, self.object_name, {},
query_string='multipart-manifest=put') utils.json.dumps(manifest_data).encode('ascii'),
query_string='multipart-manifest=put')
metadata = self.brain.client.head_object(self.container_name, metadata = self.brain.client.head_object(self.container_name,
self.object_name) self.object_name)
self.assertEqual(int(metadata['content-length']), self.assertEqual(int(metadata['content-length']),
@ -392,7 +393,7 @@ class TestContainerMergePolicyIndex(ReplProbeTest):
'X-Symlink-Target': '%s/%s' % ( 'X-Symlink-Target': '%s/%s' % (
self.container_name, target_name), self.container_name, target_name),
'Content-Type': 'application/symlink', 'Content-Type': 'application/symlink',
}, '') }, b'')
# at this point we have a broken symlink (the container_info has the # at this point we have a broken symlink (the container_info has the
# proxy looking for the target in the wrong policy) # proxy looking for the target in the wrong policy)