From: Kefu Chai Date: Mon, 6 Apr 2020 15:11:21 +0000 (+0800) Subject: test/rgw: pass encoding to Key.get_content_as_string() X-Git-Tag: v14.2.10~17^2~54 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3819c85884a83ce48e16786631ae520a25b61d83;p=ceph.git test/rgw: pass encoding to Key.get_content_as_string() we assume that boto.Key.get_content_as_string() returns str instead of bytes, and compare the return value with a string, so, to ensure that lhs and rhs are both strings, we need to decode the returned content. since we always store strings composed with ASCII, it's safe to use 'ascii' to decode them. Signed-off-by: Kefu Chai (cherry picked from commit fcf4de3855f01e80b90d246529916a5915fe413d) Conflicts: src/test/rgw/rgw_multi/tests_az.py: trivial resolution --- diff --git a/src/test/rgw/rgw_multi/tests.py b/src/test/rgw/rgw_multi/tests.py index 6c797e668183..01529c59d9d8 100644 --- a/src/test/rgw/rgw_multi/tests.py +++ b/src/test/rgw/rgw_multi/tests.py @@ -1011,14 +1011,14 @@ def test_multi_zone_redirect(): key2 = bucket2.get_key(obj) - eq(data, key2.get_contents_as_string()) + eq(data, key2.get_contents_as_string(encoding='ascii')) key = bucket.new_key(obj) for x in ['a', 'b', 'c', 'd']: data = x*512 key.set_contents_from_string(data) - eq(data, key2.get_contents_as_string()) + eq(data, key2.get_contents_as_string(encoding='ascii')) # revert config changes set_sync_from_all(z2, True) @@ -1252,10 +1252,10 @@ def test_encrypted_object_sync(): # read the encrypted objects from the second zone bucket2 = get_bucket(zone2, bucket_name) key = bucket2.get_key('testobj-sse-c', headers=sse_c_headers) - eq(data, key.get_contents_as_string(headers=sse_c_headers)) + eq(data, key.get_contents_as_string(headers=sse_c_headers, encoding='ascii')) key = bucket2.get_key('testobj-sse-kms') - eq(data, key.get_contents_as_string()) + eq(data, key.get_contents_as_string(encoding='ascii')) def test_bucket_index_log_trim(): zonegroup = realm.master_zonegroup() diff --git a/src/test/rgw/rgw_multi/zone_cloud.py b/src/test/rgw/rgw_multi/zone_cloud.py index e9dcc4b10ca5..43b1f76e0f3f 100644 --- a/src/test/rgw/rgw_multi/zone_cloud.py +++ b/src/test/rgw/rgw_multi/zone_cloud.py @@ -129,8 +129,8 @@ class CloudKey: self.content_language = k.content_language - def get_contents_as_string(self): - r = self.key.get_contents_as_string() + def get_contents_as_string(self, encoding=None): + r = self.key.get_contents_as_string(encoding=encoding) # the previous call changed the status of the source object, as it loaded # its metadata