Skip to content
Open
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
41 changes: 40 additions & 1 deletion tests/test_backup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import time

import pytest
import time
from packaging import version

from arango.errno import DATABASE_NOT_FOUND, FILE_NOT_FOUND, FORBIDDEN, HTTP_NOT_FOUND
Expand All @@ -14,6 +15,41 @@
)
from tests.helpers import assert_raises

def wait_for_cluster_resilient(sys_db):
firstExec = True
collectionsInSync = True
attempts = 100
while not collectionsInSync and attempts > 0:
collectionsInSync = True
countInSync = 0
countStillWaiting = 0
cols = sys_db.replication.cluster_inventory(include_system=True)
print(cols)
if cols is None:
collectionsInSync = False
time.sleep(1)
attempts -= 1
continue
for col in cols:
collectionsInSync = collectionsInSync and col.allInSync
if not col.allInSync:
countStillWaiting += 1
else:
countInSync+= 1

if not collectionsInSync:
time.sleep(1)
if attempts % 50 == 0:
print(cols)
print(f"Amount of collection in sync: {countInSync}. Still not in sync: {countStillWaiting}")
if firstExec:
firstExec = False
if countInSync + countStillWaiting > 100:
attempts = Math.round((countInSync + countStillWaiting) * 0.8);
print("Set attempts to {attempts}")
attempts -= 1;
if attempts == 0:
raise Exception("collections didn't come in sync!")

def test_backup_management(sys_db, bad_db, cluster, skip_tests, db_version):
if "enterprise" in skip_tests:
Expand Down Expand Up @@ -113,7 +149,10 @@ def test_backup_management(sys_db, bad_db, cluster, skip_tests, db_version):
assert isinstance(result, dict)

# Wait for restore to complete
time.sleep(10)
if cluster:
wait_for_cluster_resilient(sys_db)
else:
time.sleep(10)

# Test restore backup with bad database.
with assert_raises(BackupRestoreError) as err:
Expand Down
Loading