Skip to content

Commit 155b498

Browse files
authored
Merge pull request ceph#58670 from ivancich/wip-bolster-reshard-testing
test/rgw: address potential race condition in reshard testing Reviewed-by: Casey Bodley <[email protected]>
2 parents c8324ba + aeaeaae commit 155b498

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

qa/workunits/rgw/test_rgw_reshard.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,14 @@ def main():
163163
cmd = exec_cmd('radosgw-admin reshard add --bucket {} --num-shards {}'.format(BUCKET_NAME, num_shards_expected))
164164
cmd = exec_cmd('radosgw-admin reshard list')
165165
json_op = json.loads(cmd)
166-
log.debug('bucket name {}'.format(json_op[0]['bucket_name']))
167-
assert json_op[0]['bucket_name'] == BUCKET_NAME
168-
assert json_op[0]['tentative_new_num_shards'] == num_shards_expected
166+
if (len(json_op) >= 1):
167+
log.debug('bucket name {}'.format(json_op[0]['bucket_name']))
168+
assert json_op[0]['bucket_name'] == BUCKET_NAME
169+
assert json_op[0]['tentative_new_num_shards'] == num_shards_expected
170+
else:
171+
cmd = exec_cmd('radosgw-admin bucket stats --bucket {}'.format(BUCKET_NAME))
172+
json_op = json.loads(cmd)
173+
assert json_op['num_shards'] == num_shards_expected
169174

170175
# TESTCASE 'reshard-process','reshard','','process bucket resharding','succeeds'
171176
log.debug('TEST: reshard process\n')
@@ -187,8 +192,14 @@ def main():
187192
cmd = exec_cmd('radosgw-admin reshard add --bucket {} --num-shards {}'.format(BUCKET_NAME, num_shards_expected))
188193
cmd = exec_cmd('radosgw-admin reshard list')
189194
json_op = json.loads(cmd)
190-
assert json_op[0]['bucket_name'] == BUCKET_NAME
191-
assert json_op[0]['tentative_new_num_shards'] == num_shards_expected
195+
if (len(json_op) >= 1):
196+
log.debug('bucket name {}'.format(json_op[0]['bucket_name']))
197+
assert json_op[0]['bucket_name'] == BUCKET_NAME
198+
assert json_op[0]['tentative_new_num_shards'] == num_shards_expected
199+
else:
200+
cmd = exec_cmd('radosgw-admin bucket stats --bucket {}'.format(BUCKET_NAME))
201+
json_op = json.loads(cmd)
202+
assert json_op['num_shards'] == num_shards_expected
192203

193204
# TESTCASE 'reshard process ,'reshard','process','reshard non empty bucket','succeeds'
194205
log.debug('TEST: reshard process non empty bucket\n')

0 commit comments

Comments
 (0)