From: Casey Bodley Date: Thu, 10 Feb 2022 19:32:16 +0000 (-0500) Subject: test/rgw: test_rgw_reshard.py injects ECANCELED on set_target_layout/commit_target_layout X-Git-Tag: v18.0.0~787^2~30 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=87efd66db0809764f150cae9b9918ef4e3e9614b;p=ceph.git test/rgw: test_rgw_reshard.py injects ECANCELED on set_target_layout/commit_target_layout Signed-off-by: Casey Bodley --- diff --git a/qa/workunits/rgw/test_rgw_reshard.py b/qa/workunits/rgw/test_rgw_reshard.py index 435c6f5fe619..eba3811226a6 100755 --- a/qa/workunits/rgw/test_rgw_reshard.py +++ b/qa/workunits/rgw/test_rgw_reshard.py @@ -97,6 +97,8 @@ def run_bucket_reshard_cmd(bucket_name, num_shards, **kwargs): cmd += ' --inject-error-at {}'.format(kwargs.pop('error_at')) elif 'abort_at' in kwargs: cmd += ' --inject-abort-at {}'.format(kwargs.pop('abort_at')) + if 'error_code' in kwargs: + cmd += ' --inject-error-code {}'.format(kwargs.pop('error_code')) return exec_cmd(cmd, **kwargs) def test_bucket_reshard(conn, name, **fault): @@ -115,27 +117,31 @@ def test_bucket_reshard(conn, name, **fault): # try reshard with fault injection _, ret = run_bucket_reshard_cmd(name, num_shards_expected, check_retcode=False, **fault) - assert(ret != 0 and ret != errno.EBUSY) - # check shard count - cur_shard_count = get_bucket_stats(name).num_shards - assert(cur_shard_count == old_shard_count) + if fault.get('error_code') == errno.ECANCELED: + assert(ret == 0) # expect ECANCELED to retry and succeed + else: + assert(ret != 0 and ret != errno.EBUSY) - # verify that the bucket is writeable by deleting an object - objs.pop().delete() + # check shard count + cur_shard_count = get_bucket_stats(name).num_shards + assert(cur_shard_count == old_shard_count) - assert grants == bucket.Acl().grants # recheck grants after cancel + # verify that the bucket is writeable by deleting an object + objs.pop().delete() - # retry reshard without fault injection. if radosgw-admin aborted, - # we'll have to retry until the reshard lock expires - while True: - _, ret = run_bucket_reshard_cmd(name, num_shards_expected, check_retcode=False) - if ret == errno.EBUSY: - log.info('waiting 30 seconds for reshard lock to expire...') - time.sleep(30) - continue - assert(ret == 0) - break + assert grants == bucket.Acl().grants # recheck grants after cancel + + # retry reshard without fault injection. if radosgw-admin aborted, + # we'll have to retry until the reshard lock expires + while True: + _, ret = run_bucket_reshard_cmd(name, num_shards_expected, check_retcode=False) + if ret == errno.EBUSY: + log.info('waiting 30 seconds for reshard lock to expire...') + time.sleep(30) + continue + assert(ret == 0) + break # recheck shard count final_shard_count = get_bucket_stats(name).num_shards @@ -236,6 +242,8 @@ def main(): # TESTCASE 'manual bucket resharding','inject error','fail','check bucket accessibility', 'retry reshard' log.debug('TEST: reshard bucket with EIO injected at set_target_layout\n') test_bucket_reshard(connection, 'error-at-set-target-layout', error_at='set_target_layout') + log.debug('TEST: reshard bucket with ECANCELED injected at set_target_layout\n') + test_bucket_reshard(connection, 'error-at-set-target-layout', error_at='set_target_layout', error_code=errno.ECANCELED) log.debug('TEST: reshard bucket with abort at set_target_layout\n') test_bucket_reshard(connection, 'abort-at-set-target-layout', abort_at='set_target_layout') @@ -246,6 +254,8 @@ def main(): log.debug('TEST: reshard bucket with EIO injected at commit_target_layout\n') test_bucket_reshard(connection, 'error-at-commit-target-layout', error_at='commit_target_layout') + log.debug('TEST: reshard bucket with ECANCELED injected at commit_target_layout\n') + test_bucket_reshard(connection, 'error-at-commit-target-layout', error_at='commit_target_layout', error_code=errno.ECANCELED) log.debug('TEST: reshard bucket with abort at commit_target_layout\n') test_bucket_reshard(connection, 'abort-at-commit-target-layout', abort_at='commit_target_layout')