Loop waiting for chaos object deletion (#22446)

Signed-off-by: ThreadDao <yufen.zong@zilliz.com>
pull/22452/head
ThreadDao 2023-02-28 09:17:48 +08:00 committed by GitHub
parent 8dd1add3d8
commit 4cc721564f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 4 deletions

View File

@ -96,10 +96,19 @@ class TestChaosApply:
# delete chaos
chaos_res.delete(meta_name)
log.info("chaos deleted")
res = chaos_res.list_all()
chaos_list = [r['metadata']['name'] for r in res['items']]
# verify the chaos is deleted
assert meta_name not in chaos_list
wait_chaos_deleted = 120 # wait 2m for chaos object deleted
wait_start = time.time()
while True:
res = chaos_res.list_all()
chaos_list = [r['metadata']['name'] for r in res['items']]
# if the chaos is deleted
if meta_name not in chaos_list:
break
if time.time() - wait_start > wait_chaos_deleted:
raise Exception(f"Failed to delete chaos {meta_name} within {wait_chaos_deleted}s, all chaos: {chaos_list}")
sleep(1.0)
sleep(2)
# wait all pods ready
log.info(f"wait for pods in namespace {constants.CHAOS_NAMESPACE} with label app.kubernetes.io/instance={meta_name}")