From: J. Eric Ivancich Date: Thu, 18 Jul 2024 21:48:56 +0000 (-0400) Subject: test/rgw: address potential race condition in reshard testing X-Git-Tag: testing/wip-xiubli-testing-20240812.080715-reef~10^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=1fd136732e91f408837a607c369015cd76a0eee2;p=ceph-ci.git test/rgw: address potential race condition in reshard testing The testing code does a `reshard add` followed by a `reshard list`. On the narrow chance that the reshard was completed between those two commands, we need to be able to handle the case where the reshard list is empty. In that case we'll do a `bucket stats` to verify the reshard completed successfully. Signed-off-by: J. Eric Ivancich (cherry picked from commit aeaeaae7f5b677951773a6d718f327a9a04d5d75) --- diff --git a/qa/workunits/rgw/test_rgw_reshard.py b/qa/workunits/rgw/test_rgw_reshard.py index 6326e7b173c..e22050fc27f 100755 --- a/qa/workunits/rgw/test_rgw_reshard.py +++ b/qa/workunits/rgw/test_rgw_reshard.py @@ -163,9 +163,14 @@ def main(): cmd = exec_cmd('radosgw-admin reshard add --bucket {} --num-shards {}'.format(BUCKET_NAME, num_shards_expected)) cmd = exec_cmd('radosgw-admin reshard list') json_op = json.loads(cmd) - log.debug('bucket name {}'.format(json_op[0]['bucket_name'])) - assert json_op[0]['bucket_name'] == BUCKET_NAME - assert json_op[0]['tentative_new_num_shards'] == num_shards_expected + if (len(json_op) >= 1): + log.debug('bucket name {}'.format(json_op[0]['bucket_name'])) + assert json_op[0]['bucket_name'] == BUCKET_NAME + assert json_op[0]['tentative_new_num_shards'] == num_shards_expected + else: + cmd = exec_cmd('radosgw-admin bucket stats --bucket {}'.format(BUCKET_NAME)) + json_op = json.loads(cmd) + assert json_op['num_shards'] == num_shards_expected # TESTCASE 'reshard-process','reshard','','process bucket resharding','succeeds' log.debug('TEST: reshard process\n') @@ -187,8 +192,14 @@ def main(): cmd = exec_cmd('radosgw-admin reshard add --bucket {} --num-shards {}'.format(BUCKET_NAME, num_shards_expected)) cmd = exec_cmd('radosgw-admin reshard list') json_op = json.loads(cmd) - assert json_op[0]['bucket_name'] == BUCKET_NAME - assert json_op[0]['tentative_new_num_shards'] == num_shards_expected + if (len(json_op) >= 1): + log.debug('bucket name {}'.format(json_op[0]['bucket_name'])) + assert json_op[0]['bucket_name'] == BUCKET_NAME + assert json_op[0]['tentative_new_num_shards'] == num_shards_expected + else: + cmd = exec_cmd('radosgw-admin bucket stats --bucket {}'.format(BUCKET_NAME)) + json_op = json.loads(cmd) + assert json_op['num_shards'] == num_shards_expected # TESTCASE 'reshard process ,'reshard','process','reshard non empty bucket','succeeds' log.debug('TEST: reshard process non empty bucket\n')