]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/rgw: address potential race condition in reshard testing 58794/head
authorJ. Eric Ivancich <ivancich@redhat.com>
Thu, 18 Jul 2024 21:48:56 +0000 (17:48 -0400)
committerJ. Eric Ivancich <ivancich@redhat.com>
Wed, 24 Jul 2024 15:33:08 +0000 (11:33 -0400)
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 <ivancich@redhat.com>
(cherry picked from commit aeaeaae7f5b677951773a6d718f327a9a04d5d75)

qa/workunits/rgw/test_rgw_reshard.py

index 6326e7b173cf4ba429bc2c412ff61f760f350e5e..e22050fc27f8a7aae8423ea14836038b99965c6e 100755 (executable)
@@ -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')