Skip to content

Commit

Permalink
test: fix clean up of protected & cdc tables (googleapis#2445)
Browse files Browse the repository at this point in the history
Change-Id: Id15852b2b3bbb62746861d7ec02842353612ae77

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
- [ ] Make sure to open an issue as a [bug/issue](https://togithub.com/googleapis/java-bigtable/issues/new/choose) before writing your code!  That way we can discuss the change, evaluate designs, and agree on the general idea
- [ ] Ensure the tests and linter pass
- [ ] Code coverage does not decrease (if any source code was changed)
- [ ] Appropriate docs were updated (if necessary)
- [ ] Rollback plan is reviewed and LGTMed
- [ ] All new data plane features have a completed end to end testing plan

Fixes #<issue_number_goes_here> ☕️

If you write sample code, please follow the [samples format](
https://togithub.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md).
  • Loading branch information
igorbernstein2 authored Dec 4, 2024
1 parent cb4d60e commit caa622e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ If you are using Maven without the BOM, add this to your dependencies:
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigtable</artifactId>
<version>2.40.0</version>
<version>2.48.0</version>
</dependency>

```
Expand Down
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 caa622e

Please sign in to comment.