Skip to content

Commit

Permalink
tests: Handle DB purges in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
spbnick committed Jan 30, 2024
1 parent e573f1e commit 61928a5
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,18 +328,17 @@ def filter_test_data(data):
# Wait and check for the purge
deadline = datetime.now(timezone.utc) + timedelta(minutes=5)
while datetime.now(timezone.utc) < deadline:
time.sleep(5)
dump = filter_test_data(client.dump())
# If data has changed
if not all(
len(dump.get(n, [])) == 2
# If everything was purged
# NOTE: For some reason we're hitting incomplete purges sometimes
if all(
len(dump.get(n, [])) == 1
for n in kcidb.io.SCHEMA.graph
if n
):
assert dump == data_after
break
time.sleep(5)
else:
assert False, "Operational database purge timed out"
assert dump == data_after

# Make sure we were getting the operational DB dump
op_client = kcidb.db.Client(os.environ["KCIDB_OPERATIONAL_DATABASE"])
Expand Down

0 comments on commit 61928a5

Please sign in to comment.