]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
qa/tasks: pass encoding to Key.get_content_as_string()
authorKefu Chai <kchai@redhat.com>
Mon, 6 Apr 2020 15:08:59 +0000 (23:08 +0800)
committerKefu Chai <kchai@redhat.com>
Tue, 7 Apr 2020 13:51:23 +0000 (21:51 +0800)
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 <kchai@redhat.com>
qa/tasks/radosgw_admin.py

index 7904d9c189cd16232d0b77abbac7a01f99ba6309..2cc85865fbc99a34f41f5df57195ae3c4c5c02f6 100644 (file)
@@ -664,7 +664,7 @@ def task(ctx, config):
     rl.log_and_clear("put_obj", bucket_name, user1)
 
     # fetch it too (for usage stats presently)
-    s = key.get_contents_as_string()
+    s = key.get_contents_as_string(encoding='ascii')
     rl.log_and_clear("get_obj", bucket_name, user1)
     assert s == object_name
     # list bucket too (for usage stats presently)
@@ -943,7 +943,7 @@ def task(ctx, config):
 
     # get bucket and object to test if user keys are preserved
     bucket = connection3.get_bucket(bucket_name + '6')
-    s = key1.get_contents_as_string()
+    s = key1.get_contents_as_string(encoding='ascii')
     rl.log_and_clear("get_obj", bucket_name + '6', user4)
     assert s == object_name1
 
@@ -975,12 +975,12 @@ def task(ctx, config):
 
     # test if user 2 and user4 can still access their bucket and objects after rename fails
     bucket = connection3.get_bucket(bucket_name + '6')
-    s = key1.get_contents_as_string()
+    s = key1.get_contents_as_string(encoding='ascii')
     rl.log_and_clear("get_obj", bucket_name + '6', user4)
     assert s == object_name1
 
     bucket = connection2.get_bucket(bucket_name + '7')
-    s = key2.get_contents_as_string()
+    s = key2.get_contents_as_string(encoding='ascii')
     rl.log_and_clear("get_obj", bucket_name + '7', user2)
     assert s == object_name2