Port object_storage tests to Py3.
Main changes:
* Use bytes instead of strings for object content (data)
* Use bytes when using crypto functions (hmac, md5)
* When we can't make the service client to always return strings
(because we can't know for sure the returned payload is a text),
use decode() in tests.
Change-Id: Ic56827e3401f36ccc555dd0568b606a8c3047f00
diff --git a/tempest/api/object_storage/base.py b/tempest/api/object_storage/base.py
index eb313d2..cf59784 100644
--- a/tempest/api/object_storage/base.py
+++ b/tempest/api/object_storage/base.py
@@ -89,7 +89,7 @@
if object_name is None:
object_name = data_utils.rand_name(name='TestObject')
if data is None:
- data = data_utils.arbitrary_string()
+ data = data_utils.random_bytes()
cls.object_client.create_object(container_name,
object_name,
data,
diff --git a/tempest/api/object_storage/test_container_services.py b/tempest/api/object_storage/test_container_services.py
index 9ce1b18..e4476a1 100644
--- a/tempest/api/object_storage/test_container_services.py
+++ b/tempest/api/object_storage/test_container_services.py
@@ -133,7 +133,7 @@
resp, object_list = self.container_client.list_container_contents(
container_name)
self.assertHeaders(resp, 'Container', 'GET')
- self.assertEqual(object_name, object_list.strip('\n'))
+ self.assertEqual([object_name], object_list)
@test.idempotent_id('4646ac2d-9bfb-4c7d-a3c5-0f527402b3df')
def test_list_container_contents_with_no_object(self):
@@ -143,7 +143,7 @@
resp, object_list = self.container_client.list_container_contents(
container_name)
self.assertHeaders(resp, 'Container', 'GET')
- self.assertEqual('', object_list.strip('\n'))
+ self.assertEmpty(object_list)
@test.idempotent_id('fe323a32-57b9-4704-a996-2e68f83b09bc')
def test_list_container_contents_with_delimiter(self):
@@ -157,7 +157,7 @@
container_name,
params=params)
self.assertHeaders(resp, 'Container', 'GET')
- self.assertEqual(object_name.split('/')[0], object_list.strip('/\n'))
+ self.assertEqual([object_name.split('/')[0] + '/'], object_list)
@test.idempotent_id('55b4fa5c-e12e-4ca9-8fcf-a79afe118522')
def test_list_container_contents_with_end_marker(self):
@@ -170,7 +170,7 @@
container_name,
params=params)
self.assertHeaders(resp, 'Container', 'GET')
- self.assertEqual(object_name, object_list.strip('\n'))
+ self.assertEqual([object_name], object_list)
@test.idempotent_id('196f5034-6ab0-4032-9da9-a937bbb9fba9')
def test_list_container_contents_with_format_json(self):
@@ -226,7 +226,7 @@
container_name,
params=params)
self.assertHeaders(resp, 'Container', 'GET')
- self.assertEqual(object_name, object_list.strip('\n'))
+ self.assertEqual([object_name], object_list)
@test.idempotent_id('c31ddc63-2a58-4f6b-b25c-94d2937e6867')
def test_list_container_contents_with_marker(self):
@@ -239,7 +239,7 @@
container_name,
params=params)
self.assertHeaders(resp, 'Container', 'GET')
- self.assertEqual(object_name, object_list.strip('\n'))
+ self.assertEqual([object_name], object_list)
@test.idempotent_id('58ca6cc9-6af0-408d-aaec-2a6a7b2f0df9')
def test_list_container_contents_with_path(self):
@@ -253,7 +253,7 @@
container_name,
params=params)
self.assertHeaders(resp, 'Container', 'GET')
- self.assertEqual(object_name, object_list.strip('\n'))
+ self.assertEqual([object_name], object_list)
@test.idempotent_id('77e742c7-caf2-4ec9-8aa4-f7d509a3344c')
def test_list_container_contents_with_prefix(self):
@@ -267,7 +267,7 @@
container_name,
params=params)
self.assertHeaders(resp, 'Container', 'GET')
- self.assertEqual(object_name, object_list.strip('\n'))
+ self.assertEqual([object_name], object_list)
@test.attr(type='smoke')
@test.idempotent_id('96e68f0e-19ec-4aa2-86f3-adc6a45e14dd')
diff --git a/tempest/api/object_storage/test_container_staticweb.py b/tempest/api/object_storage/test_container_staticweb.py
index 47ef0d3..edc9271 100644
--- a/tempest/api/object_storage/test_container_staticweb.py
+++ b/tempest/api/object_storage/test_container_staticweb.py
@@ -96,7 +96,7 @@
# Check only the format of common headers with custom matcher
self.assertThat(resp, custom_matchers.AreAllWellFormatted())
- self.assertIn(self.object_name, body)
+ self.assertIn(self.object_name, body.decode())
# clean up before exiting
self.container_client.update_container_metadata(self.container_name,
@@ -126,9 +126,9 @@
resp, body = self.account_client.request("GET",
self.container_name,
headers={})
- self.assertIn(self.object_name, body)
+ self.assertIn(self.object_name, body.decode())
css = '<link rel="stylesheet" type="text/css" href="listings.css" />'
- self.assertIn(css, body)
+ self.assertIn(css, body.decode())
@test.idempotent_id('f18b4bef-212e-45e7-b3ca-59af3a465f82')
@test.requires_ext(extension='staticweb', service='object')
diff --git a/tempest/api/object_storage/test_container_sync.py b/tempest/api/object_storage/test_container_sync.py
index e10b900..f134335 100644
--- a/tempest/api/object_storage/test_container_sync.py
+++ b/tempest/api/object_storage/test_container_sync.py
@@ -96,7 +96,7 @@
cont_client[0].put(str(cont[0]), body=None, headers=headers)
# create object in container
object_name = data_utils.rand_name(name='TestSyncObject')
- data = object_name[::-1] # data_utils.arbitrary_string()
+ data = object_name[::-1].encode() # Raw data, we need bytes
resp, _ = obj_client[0].create_object(cont[0], object_name, data)
self.objects.append(object_name)
@@ -127,7 +127,7 @@
for obj_client, cont in obj_clients:
for obj_name in object_lists[0]:
resp, object_content = obj_client.get_object(cont, obj_name)
- self.assertEqual(object_content, obj_name[::-1])
+ self.assertEqual(object_content, obj_name[::-1].encode())
@test.attr(type='slow')
@decorators.skip_because(bug='1317133')
diff --git a/tempest/api/object_storage/test_crossdomain.py b/tempest/api/object_storage/test_crossdomain.py
index 8dbfd06..18dc254 100644
--- a/tempest/api/object_storage/test_crossdomain.py
+++ b/tempest/api/object_storage/test_crossdomain.py
@@ -40,6 +40,7 @@
@test.requires_ext(extension='crossdomain', service='object')
def test_get_crossdomain_policy(self):
resp, body = self.account_client.get("crossdomain.xml", {})
+ body = body.decode()
self.assertTrue(body.startswith(self.xml_start) and
body.endswith(self.xml_end))
diff --git a/tempest/api/object_storage/test_object_formpost.py b/tempest/api/object_storage/test_object_formpost.py
index 102ec2f..0a87a64 100644
--- a/tempest/api/object_storage/test_object_formpost.py
+++ b/tempest/api/object_storage/test_object_formpost.py
@@ -72,7 +72,9 @@
max_file_count,
expires)
- signature = hmac.new(self.key, hmac_body, hashlib.sha1).hexdigest()
+ signature = hmac.new(
+ self.key.encode(), hmac_body.encode(), hashlib.sha1
+ ).hexdigest()
fields = {'redirect': redirect,
'max_file_size': str(max_file_size),
@@ -119,4 +121,4 @@
resp, body = self.object_client.get("%s/%s%s" % (
self.container_name, self.object_name, "testfile"))
self.assertHeaders(resp, "Object", "GET")
- self.assertEqual(body, "hello world")
+ self.assertEqual(body.decode(), "hello world")
diff --git a/tempest/api/object_storage/test_object_formpost_negative.py b/tempest/api/object_storage/test_object_formpost_negative.py
index 8ff5d82..f193111 100644
--- a/tempest/api/object_storage/test_object_formpost_negative.py
+++ b/tempest/api/object_storage/test_object_formpost_negative.py
@@ -73,7 +73,9 @@
max_file_count,
expires)
- signature = hmac.new(self.key, hmac_body, hashlib.sha1).hexdigest()
+ signature = hmac.new(
+ self.key.encode(), hmac_body.encode(), hashlib.sha1
+ ).hexdigest()
fields = {'redirect': redirect,
'max_file_size': str(max_file_size),
diff --git a/tempest/api/object_storage/test_object_services.py b/tempest/api/object_storage/test_object_services.py
index 8736f9a..4b5d291 100644
--- a/tempest/api/object_storage/test_object_services.py
+++ b/tempest/api/object_storage/test_object_services.py
@@ -81,12 +81,12 @@
def test_create_object(self):
# create object
object_name = data_utils.rand_name(name='TestObject')
- data = data_utils.arbitrary_string()
+ data = data_utils.random_bytes()
resp, _ = self.object_client.create_object(self.container_name,
object_name, data)
# create another object
object_name = data_utils.rand_name(name='TestObject')
- data = data_utils.arbitrary_string()
+ data = data_utils.random_bytes()
resp, _ = self.object_client.create_object(self.container_name,
object_name, data)
self.assertHeaders(resp, 'Object', 'PUT')
@@ -100,7 +100,7 @@
def test_create_object_with_content_disposition(self):
# create object with content_disposition
object_name = data_utils.rand_name(name='TestObject')
- data = data_utils.arbitrary_string()
+ data = data_utils.random_bytes()
metadata = {}
metadata['content-disposition'] = 'inline'
resp, _ = self.object_client.create_object(
@@ -124,7 +124,7 @@
object_name = data_utils.rand_name(name='TestObject')
# put compressed string
- data_before = 'x' * 2000
+ data_before = b'x' * 2000
data = zlib.compress(data_before)
metadata = {}
metadata['content-encoding'] = 'deflate'
@@ -149,7 +149,7 @@
def test_create_object_with_etag(self):
# create object with etag
object_name = data_utils.rand_name(name='TestObject')
- data = data_utils.arbitrary_string()
+ data = data_utils.random_bytes()
md5 = hashlib.md5(data).hexdigest()
metadata = {'Etag': md5}
resp, _ = self.object_client.create_object(
@@ -169,7 +169,7 @@
# create object with expect_continue
object_name = data_utils.rand_name(name='TestObject')
- data = data_utils.arbitrary_string()
+ data = data_utils.random_bytes()
status, _ = self.object_client.create_object_continue(
self.container_name, object_name, data)
@@ -185,7 +185,7 @@
def test_create_object_with_transfer_encoding(self):
# create object with transfer_encoding
object_name = data_utils.rand_name(name='TestObject')
- data = data_utils.arbitrary_string(1024)
+ data = data_utils.random_bytes(1024)
status, _, resp_headers = self.object_client.put_object_with_chunk(
container=self.container_name,
name=object_name,
@@ -202,7 +202,7 @@
def test_create_object_with_x_fresh_metadata(self):
# create object with x_fresh_metadata
object_name_base = data_utils.rand_name(name='TestObject')
- data = data_utils.arbitrary_string()
+ data = data_utils.random_bytes()
metadata_1 = {'X-Object-Meta-test-meta': 'Meta'}
self.object_client.create_object(self.container_name,
object_name_base,
@@ -228,7 +228,7 @@
def test_create_object_with_x_object_meta(self):
# create object with object_meta
object_name = data_utils.rand_name(name='TestObject')
- data = data_utils.arbitrary_string()
+ data = data_utils.random_bytes()
metadata = {'X-Object-Meta-test-meta': 'Meta'}
resp, _ = self.object_client.create_object(
self.container_name,
@@ -247,7 +247,7 @@
def test_create_object_with_x_object_metakey(self):
# create object with the blank value of metadata
object_name = data_utils.rand_name(name='TestObject')
- data = data_utils.arbitrary_string()
+ data = data_utils.random_bytes()
metadata = {'X-Object-Meta-test-meta': ''}
resp, _ = self.object_client.create_object(
self.container_name,
@@ -266,7 +266,7 @@
def test_create_object_with_x_remove_object_meta(self):
# create object with x_remove_object_meta
object_name = data_utils.rand_name(name='TestObject')
- data = data_utils.arbitrary_string()
+ data = data_utils.random_bytes()
metadata_add = {'X-Object-Meta-test-meta': 'Meta'}
self.object_client.create_object(self.container_name,
object_name,
@@ -289,7 +289,7 @@
def test_create_object_with_x_remove_object_metakey(self):
# create object with the blank value of remove metadata
object_name = data_utils.rand_name(name='TestObject')
- data = data_utils.arbitrary_string()
+ data = data_utils.random_bytes()
metadata_add = {'X-Object-Meta-test-meta': 'Meta'}
self.object_client.create_object(self.container_name,
object_name,
@@ -312,7 +312,7 @@
def test_delete_object(self):
# create object
object_name = data_utils.rand_name(name='TestObject')
- data = data_utils.arbitrary_string()
+ data = data_utils.random_bytes()
resp, _ = self.object_client.create_object(self.container_name,
object_name, data)
# delete object
@@ -344,7 +344,7 @@
def test_update_object_metadata_with_remove_metadata(self):
# update object metadata with remove metadata
object_name = data_utils.rand_name(name='TestObject')
- data = data_utils.arbitrary_string()
+ data = data_utils.random_bytes()
create_metadata = {'X-Object-Meta-test-meta1': 'Meta1'}
self.object_client.create_object(self.container_name,
object_name,
@@ -368,7 +368,7 @@
def test_update_object_metadata_with_create_and_remove_metadata(self):
# creation and deletion of metadata with one request
object_name = data_utils.rand_name(name='TestObject')
- data = data_utils.arbitrary_string()
+ data = data_utils.random_bytes()
create_metadata = {'X-Object-Meta-test-meta1': 'Meta1'}
self.object_client.create_object(self.container_name,
object_name,
@@ -466,7 +466,7 @@
def test_list_object_metadata(self):
# get object metadata
object_name = data_utils.rand_name(name='TestObject')
- data = data_utils.arbitrary_string()
+ data = data_utils.random_bytes()
metadata = {'X-Object-Meta-test-meta': 'Meta'}
self.object_client.create_object(self.container_name,
object_name,
@@ -549,7 +549,7 @@
def test_get_object_with_metadata(self):
# get object with metadata
object_name = data_utils.rand_name(name='TestObject')
- data = data_utils.arbitrary_string()
+ data = data_utils.random_bytes()
metadata = {'X-Object-Meta-test-meta': 'Meta'}
self.object_client.create_object(self.container_name,
object_name,
@@ -568,7 +568,7 @@
def test_get_object_with_range(self):
# get object with range
object_name = data_utils.rand_name(name='TestObject')
- data = data_utils.arbitrary_string(100)
+ data = data_utils.random_bytes(100)
self.object_client.create_object(self.container_name,
object_name,
data,
@@ -623,13 +623,13 @@
self.assertEqual(resp['x-object-manifest'],
'%s/%s' % (self.container_name, object_name))
- self.assertEqual(''.join(data_segments), body)
+ self.assertEqual(''.join(data_segments), body.decode())
@test.idempotent_id('c05b4013-e4de-47af-be84-e598062b16fc')
def test_get_object_with_if_match(self):
# get object with if_match
object_name = data_utils.rand_name(name='TestObject')
- data = data_utils.arbitrary_string(10)
+ data = data_utils.random_bytes(10)
create_md5 = hashlib.md5(data).hexdigest()
create_metadata = {'Etag': create_md5}
self.object_client.create_object(self.container_name,
@@ -649,7 +649,7 @@
def test_get_object_with_if_modified_since(self):
# get object with if_modified_since
object_name = data_utils.rand_name(name='TestObject')
- data = data_utils.arbitrary_string()
+ data = data_utils.random_bytes()
time_now = time.time()
self.object_client.create_object(self.container_name,
object_name,
@@ -669,7 +669,7 @@
def test_get_object_with_if_none_match(self):
# get object with if_none_match
object_name = data_utils.rand_name(name='TestObject')
- data = data_utils.arbitrary_string(10)
+ data = data_utils.random_bytes()
create_md5 = hashlib.md5(data).hexdigest()
create_metadata = {'Etag': create_md5}
self.object_client.create_object(self.container_name,
@@ -677,7 +677,7 @@
data,
metadata=create_metadata)
- list_data = data_utils.arbitrary_string(15)
+ list_data = data_utils.random_bytes()
list_md5 = hashlib.md5(list_data).hexdigest()
list_metadata = {'If-None-Match': list_md5}
resp, body = self.object_client.get_object(
@@ -719,15 +719,13 @@
def test_copy_object_in_same_container(self):
# create source object
src_object_name = data_utils.rand_name(name='SrcObject')
- src_data = data_utils.arbitrary_string(size=len(src_object_name) * 2,
- base_text=src_object_name)
+ src_data = data_utils.random_bytes(size=len(src_object_name) * 2)
resp, _ = self.object_client.create_object(self.container_name,
src_object_name,
src_data)
# create destination object
dst_object_name = data_utils.rand_name(name='DstObject')
- dst_data = data_utils.arbitrary_string(size=len(dst_object_name) * 3,
- base_text=dst_object_name)
+ dst_data = data_utils.random_bytes(size=len(dst_object_name) * 3)
resp, _ = self.object_client.create_object(self.container_name,
dst_object_name,
dst_data)
@@ -766,14 +764,12 @@
def test_copy_object_2d_way(self):
# create source object
src_object_name = data_utils.rand_name(name='SrcObject')
- src_data = data_utils.arbitrary_string(size=len(src_object_name) * 2,
- base_text=src_object_name)
+ src_data = data_utils.random_bytes(size=len(src_object_name) * 2)
resp, _ = self.object_client.create_object(self.container_name,
src_object_name, src_data)
# create destination object
dst_object_name = data_utils.rand_name(name='DstObject')
- dst_data = data_utils.arbitrary_string(size=len(dst_object_name) * 3,
- base_text=dst_object_name)
+ dst_data = data_utils.random_bytes(size=len(dst_object_name) * 3)
resp, _ = self.object_client.create_object(self.container_name,
dst_object_name, dst_data)
# copy source object to destination
@@ -801,8 +797,7 @@
self.containers.append(dst_container_name)
# create object in source container
object_name = data_utils.rand_name(name='Object')
- data = data_utils.arbitrary_string(size=len(object_name) * 2,
- base_text=object_name)
+ data = data_utils.random_bytes(size=len(object_name) * 2)
resp, _ = self.object_client.create_object(src_container_name,
object_name, data)
# set object metadata
@@ -935,7 +930,7 @@
# downloading the object
resp, body = self.object_client.get_object(
self.container_name, object_name)
- self.assertEqual(''.join(data_segments), body)
+ self.assertEqual(''.join(data_segments), body.decode())
@test.idempotent_id('50d01f12-526f-4360-9ac2-75dd508d7b68')
def test_get_object_if_different(self):
@@ -960,7 +955,7 @@
# local copy is different, download
local_data = "something different"
- md5 = hashlib.md5(local_data).hexdigest()
+ md5 = hashlib.md5(local_data.encode()).hexdigest()
headers = {'If-None-Match': md5}
resp, body = self.object_client.get(url, headers=headers)
self.assertHeaders(resp, 'Object', 'GET')
@@ -1004,8 +999,7 @@
# create object
object_name = data_utils.rand_name(name='Object')
- data = data_utils.arbitrary_string(size=len(object_name),
- base_text=object_name)
+ data = data_utils.random_bytes(size=len(object_name))
resp, _ = self.object_client.create_object(self.container_name,
object_name, data)
self.assertHeaders(resp, 'Object', 'PUT')
@@ -1041,8 +1035,7 @@
# create object
object_name = data_utils.rand_name(name='Object')
- data = data_utils.arbitrary_string(size=len(object_name) * 1,
- base_text=object_name)
+ data = data_utils.random_bytes(size=len(object_name))
resp, _ = self.object_client.create_object(self.container_name,
object_name, data)
self.assertHeaders(resp, 'Object', 'PUT')
diff --git a/tempest/api/object_storage/test_object_slo.py b/tempest/api/object_storage/test_object_slo.py
index e00bbab..f9c1148 100644
--- a/tempest/api/object_storage/test_object_slo.py
+++ b/tempest/api/object_storage/test_object_slo.py
@@ -56,7 +56,7 @@
object_name_base_1 = object_name + '_01'
object_name_base_2 = object_name + '_02'
data_size = MIN_SEGMENT_SIZE
- self.content = data_utils.arbitrary_string(data_size)
+ self.content = data_utils.random_bytes(data_size)
self._create_object(self.container_name,
object_name_base_1,
self.content)
diff --git a/tempest/api/object_storage/test_object_temp_url.py b/tempest/api/object_storage/test_object_temp_url.py
index 7287a2d..bd0d213 100644
--- a/tempest/api/object_storage/test_object_temp_url.py
+++ b/tempest/api/object_storage/test_object_temp_url.py
@@ -75,7 +75,9 @@
container, object_name)
hmac_body = '%s\n%s\n%s' % (method, expires, path)
- sig = hmac.new(key, hmac_body, hashlib.sha1).hexdigest()
+ sig = hmac.new(
+ key.encode(), hmac_body.encode(), hashlib.sha1
+ ).hexdigest()
url = "%s/%s?temp_url_sig=%s&temp_url_expires=%s" % (container,
object_name,
@@ -129,9 +131,7 @@
@test.idempotent_id('9b08dade-3571-4152-8a4f-a4f2a873a735')
@test.requires_ext(extension='tempurl', service='object')
def test_put_object_using_temp_url(self):
- new_data = data_utils.arbitrary_string(
- size=len(self.object_name),
- base_text=data_utils.rand_name(name="random"))
+ new_data = data_utils.random_bytes(size=len(self.object_name))
expires = self._get_expiry_date()
url = self._get_temp_url(self.container_name,
diff --git a/tempest/api/object_storage/test_object_temp_url_negative.py b/tempest/api/object_storage/test_object_temp_url_negative.py
index 577f3bd..df7a7f6 100644
--- a/tempest/api/object_storage/test_object_temp_url_negative.py
+++ b/tempest/api/object_storage/test_object_temp_url_negative.py
@@ -80,7 +80,9 @@
container, object_name)
hmac_body = '%s\n%s\n%s' % (method, expires, path)
- sig = hmac.new(key, hmac_body, hashlib.sha1).hexdigest()
+ sig = hmac.new(
+ key.encode(), hmac_body.encode(), hashlib.sha1
+ ).hexdigest()
url = "%s/%s?temp_url_sig=%s&temp_url_expires=%s" % (container,
object_name,
diff --git a/tempest/api/object_storage/test_object_version.py b/tempest/api/object_storage/test_object_version.py
index 3f6623b..6d064a2 100644
--- a/tempest/api/object_storage/test_object_version.py
+++ b/tempest/api/object_storage/test_object_version.py
@@ -69,22 +69,24 @@
vers_container_name)
object_name = data_utils.rand_name(name='TestObject')
# create object
+ data_1 = data_utils.random_bytes()
resp, _ = self.object_client.create_object(base_container_name,
- object_name, '1')
+ object_name, data_1)
# create 2nd version of object
+ data_2 = data_utils.random_bytes()
resp, _ = self.object_client.create_object(base_container_name,
- object_name, '2')
+ object_name, data_2)
resp, body = self.object_client.get_object(base_container_name,
object_name)
- self.assertEqual(body, '2')
+ self.assertEqual(body, data_2)
# delete object version 2
resp, _ = self.object_client.delete_object(base_container_name,
object_name)
- self.assertContainer(base_container_name, '1', '1',
+ self.assertContainer(base_container_name, '1', '1024',
vers_container_name)
resp, body = self.object_client.get_object(base_container_name,
object_name)
- self.assertEqual(body, '1')
+ self.assertEqual(body, data_1)
# delete object version 1
resp, _ = self.object_client.delete_object(base_container_name,
object_name)
diff --git a/tempest/lib/common/http.py b/tempest/lib/common/http.py
index 86ea26e..8a47d44 100644
--- a/tempest/lib/common/http.py
+++ b/tempest/lib/common/http.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
+import six
import urllib3
@@ -39,7 +40,9 @@
class Response(dict):
def __init__(self, info):
for key, value in info.getheaders().items():
- self[key.lower()] = value
+ # We assume HTTP header name to be string, not random
+ # bytes, thus ensure we have string keys.
+ self[six.u(key).lower()] = value
self.status = info.status
self['status'] = str(self.status)
self.reason = info.reason
diff --git a/tempest/scenario/manager.py b/tempest/scenario/manager.py
index 376dd19..4b2cbba 100644
--- a/tempest/scenario/manager.py
+++ b/tempest/scenario/manager.py
@@ -1327,7 +1327,7 @@
def upload_object_to_container(self, container_name, obj_name=None):
obj_name = obj_name or data_utils.rand_name('swift-scenario-object')
- obj_data = data_utils.arbitrary_string()
+ obj_data = data_utils.random_bytes()
self.object_client.create_object(container_name, obj_name, obj_data)
self.addCleanup(test_utils.call_and_ignore_notfound_exc,
self.object_client.delete_object,
diff --git a/tempest/services/object_storage/container_client.py b/tempest/services/object_storage/container_client.py
index 2509156..afedd36 100644
--- a/tempest/services/object_storage/container_client.py
+++ b/tempest/services/object_storage/container_client.py
@@ -140,5 +140,11 @@
body = json.loads(body)
elif params and params.get('format') == 'xml':
body = etree.fromstring(body)
+ # Else the content-type is plain/text
+ else:
+ body = [
+ obj_name for obj_name in body.decode().split('\n') if obj_name
+ ]
+
self.expected_success([200, 204], resp.status)
return resp, body