From: Kefu Chai Date: Mon, 6 Apr 2020 15:08:59 +0000 (+0800) Subject: qa/tasks: pass encoding to Key.get_content_as_string() X-Git-Tag: v16.1.0~2648^2~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9ccf88d95fa5d184c56ac638bed37c3e3101356d;p=ceph.git qa/tasks: 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 --- diff --git a/qa/tasks/radosgw_admin.py b/qa/tasks/radosgw_admin.py index 7904d9c189c..2cc85865fbc 100644 --- a/qa/tasks/radosgw_admin.py +++ b/qa/tasks/radosgw_admin.py @@ -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