Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -451,13 +451,33 @@ public void testEncryptedDatabaseAndBackupSamples() throws Exception {
} finally {
// Delete the backups from the test instance first, as the instance can only be deleted once
// all backups have been deleted.
for (Backup backup : dbClient.listBackups(instanceId).iterateAll()) {
backup.delete();
}
deleteAllBackups(instanceId);
instanceAdminClient.deleteInstance(instanceId);
}
}

private void deleteAllBackups(String instanceId) throws InterruptedException {
for (Backup backup : dbClient.listBackups(instanceId).iterateAll()) {
int attempts = 0;
while (attempts < 30) {
try {
attempts++;
backup.delete();
break;
} catch (SpannerException e) {
if (e.getErrorCode() == ErrorCode.FAILED_PRECONDITION && e.getMessage()
.contains("Please try deleting the backup once the restore or post-restore optimize "
+ "operations have completed on these databases.")) {
// Wait 30 seconds and then retry.
Thread.sleep(30_000L);
} else {
throw e;
}
}
}
}
}

private String runSampleRunnable(Runnable sample) {
PrintStream stdOut = System.out;
ByteArrayOutputStream bout = new ByteArrayOutputStream();
Expand Down