Skip to content

Update nightly org deletion tests to account for bg job #2118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 90 additions & 6 deletions backend/test_nightly/test_org_deletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,38 @@ def test_delete_org_crawl_running(
f"{API_PREFIX}/orgs/{non_default_org_id}", headers=admin_auth_headers
)
assert r.status_code == 200
assert r.json()["deleted"]
data = r.json()
assert data["deleted"]

time.sleep(5)
job_id = data["id"]

# Check that background job is launched and eventually succeeds
max_attempts = 18
attempts = 1
while True:
try:
r = requests.get(
f"{API_PREFIX}/orgs/all/jobs/{job_id}", headers=admin_auth_headers
)
assert r.status_code == 200
success = r.json()["success"]

if success:
break

if success is False:
assert False

if attempts >= max_attempts:
assert False

time.sleep(10)
except:
pass

attempts += 1

# Check that org was deleted
r = requests.get(f"{API_PREFIX}/orgs", headers=admin_auth_headers)
data = r.json()
for org in data["items"]:
Expand All @@ -159,10 +187,38 @@ def test_delete_org_qa_running(
f"{API_PREFIX}/orgs/{non_default_org_id}", headers=admin_auth_headers
)
assert r.status_code == 200
assert r.json()["deleted"]
data = r.json()
assert data["deleted"]

time.sleep(5)
job_id = data["id"]

# Check that background job is launched and eventually succeeds
max_attempts = 18
attempts = 1
while True:
try:
r = requests.get(
f"{API_PREFIX}/orgs/all/jobs/{job_id}", headers=admin_auth_headers
)
assert r.status_code == 200
success = r.json()["success"]

if success:
break

if success is False:
assert False

if attempts >= max_attempts:
assert False

time.sleep(10)
except:
pass

attempts += 1

# Check that org was deleted
r = requests.get(f"{API_PREFIX}/orgs", headers=admin_auth_headers)
data = r.json()
for org in data["items"]:
Expand All @@ -177,10 +233,38 @@ def test_delete_org_profile_running(
f"{API_PREFIX}/orgs/{non_default_org_id}", headers=admin_auth_headers
)
assert r.status_code == 200
assert r.json()["deleted"]
data = r.json()
assert data["deleted"]

time.sleep(5)
job_id = data["id"]

# Check that background job is launched and eventually succeeds
max_attempts = 18
attempts = 1
while True:
try:
r = requests.get(
f"{API_PREFIX}/orgs/all/jobs/{job_id}", headers=admin_auth_headers
)
assert r.status_code == 200
success = r.json()["success"]

if success:
break

if success is False:
assert False

if attempts >= max_attempts:
assert False

time.sleep(10)
except:
pass

attempts += 1

# Check that org was deleted
r = requests.get(f"{API_PREFIX}/orgs", headers=admin_auth_headers)
data = r.json()
for org in data["items"]:
Expand Down
Loading