Skip to content

Commit

Permalink
fix: always delete all backups from an owned test instance
Browse files Browse the repository at this point in the history
An instance can only be deleted once all backups on the instance have been
deleted. The integration test environment should therefore first delete all
backups on an owned instance before trying to delete the instance itself.

Fixes #542
  • Loading branch information
olavloite committed Oct 27, 2020
1 parent d92b7c2 commit d10a107
Showing 1 changed file with 12 additions and 0 deletions.
Expand Up @@ -165,6 +165,18 @@ private void cleanUpInstance() {
if (isOwnedInstance) {
// Delete the instance, which implicitly drops all databases in it.
try {
// Backups must be explicitly deleted before the instance may be deleted.
logger.log(
Level.FINE, "Deleting backups on test instance {0}", testHelper.getInstanceId());
for (Backup backup :
testHelper
.getClient()
.getDatabaseAdminClient()
.listBackups(testHelper.getInstanceId().getInstance())
.iterateAll()) {
logger.log(Level.FINE, "Deleting backup {0}", backup.getId());
backup.delete();
}
logger.log(Level.FINE, "Deleting test instance {0}", testHelper.getInstanceId());
instanceAdminClient.deleteInstance(testHelper.getInstanceId().getInstance());
logger.log(Level.INFO, "Deleted test instance {0}", testHelper.getInstanceId());
Expand Down

0 comments on commit d10a107

Please sign in to comment.