Skip to content

Commit

Permalink
test: fix clean up of protected & cdc tables
Browse files Browse the repository at this point in the history
Change-Id: Id15852b2b3bbb62746861d7ec02842353612ae77
  • Loading branch information
igorbernstein2 committed Dec 4, 2024
1 parent cb4d60e commit 13febd2
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import com.google.cloud.bigtable.admin.v2.models.AppProfile;
import com.google.cloud.bigtable.admin.v2.models.Cluster;
import com.google.cloud.bigtable.admin.v2.models.Instance;
import com.google.cloud.bigtable.admin.v2.models.Table;
import com.google.cloud.bigtable.admin.v2.models.UpdateAuthorizedViewRequest;
import com.google.cloud.bigtable.admin.v2.models.UpdateTableRequest;
import com.google.common.collect.ImmutableSet;
import java.io.IOException;
import java.util.ArrayList;
Expand Down Expand Up @@ -178,8 +180,19 @@ private void cleanupStaleTables(String stalePrefix) {
}

private void prepTableForDelete(String tableId) {
// Unprotected views
if (!(env() instanceof EmulatorEnv)) {
// unprotect table
Table table = env().getTableAdminClient().getTable(tableId);
if (table.isDeletionProtected() || table.getChangeStreamRetention() != null) {
env()
.getTableAdminClient()
.updateTable(
UpdateTableRequest.of(tableId)
.setDeletionProtection(false)
.disableChangeStreamRetention());
}

// Unprotected views
for (String viewId : env().getTableAdminClient().listAuthorizedViews(tableId)) {
try {
env()
Expand Down

0 comments on commit 13febd2

Please sign in to comment.