Skip to content

Commit 0404a33

Browse files
authored
test: delete referencing databases before backups (#581)
* test: delete referencing databases before backups * fix: use proto value Co-authored-by: larkee <[email protected]>
1 parent db63aee commit 0404a33

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/system/_helpers.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,20 @@ def _has_all_ddl(database):
7171
retry_has_all_dll = retry.RetryInstanceState(_has_all_ddl)
7272

7373

74+
def scrub_referencing_databases(to_scrub, db_list):
75+
for db_name in db_list:
76+
db = to_scrub.database(db_name.split("/")[-1])
77+
try:
78+
retry_429_503(db.delete)()
79+
except exceptions.NotFound: # lost the race
80+
pass
81+
82+
7483
def scrub_instance_backups(to_scrub):
7584
try:
7685
for backup_pb in to_scrub.list_backups():
86+
# Backup cannot be deleted while referencing databases exist.
87+
scrub_referencing_databases(to_scrub, backup_pb.referencing_databases)
7788
bkp = instance_mod.Backup.from_pb(backup_pb, to_scrub)
7889
try:
7990
# Instance cannot be deleted while backups exist.

0 commit comments

Comments
 (0)