From 42ab1dc98b1aece700573b81c6dcf2117d97a2ec Mon Sep 17 00:00:00 2001 From: Mattie Fu Date: Thu, 7 May 2026 09:13:48 -0400 Subject: [PATCH 1/2] test: make bulk mutate it less flaky Change-Id: I13871cd3a6903eb07ecc272df5bff0519b256816 --- .../bigtable/data/v2/it/BulkMutateIT.java | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/BulkMutateIT.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/BulkMutateIT.java index bd2e8e5352e2..ac6c7d2c14ad 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/BulkMutateIT.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/BulkMutateIT.java @@ -232,26 +232,19 @@ public void testManyMutationsOnAuthorizedView() throws IOException, InterruptedE .first() .call(Query.create(testEnvRule.env().getTableId()).rowKey(rowPrefix + "test-key")); assertThat(row.getCells()).hasSize(100002); - } - // We should not be able to mutate rows outside the authorized view - try { - try (BigtableDataClient client = BigtableDataClient.create(settings); - Batcher batcherOutsideAuthorizedView = - client.newBulkMutationBatcher( - AuthorizedViewId.of( - testEnvRule.env().getTableId().getTableId(), testAuthorizedView.getId()))) { - String keyOutsideAuthorizedView = UUID.randomUUID() + "-outside-authorized-view"; - RowMutationEntry rowMutationEntry = RowMutationEntry.create(keyOutsideAuthorizedView); - rowMutationEntry.setCell( - testEnvRule.env().getFamilyId(), AUTHORIZED_VIEW_COLUMN_QUALIFIER, "test-value"); - @SuppressWarnings("UnusedVariable") - ApiFuture ignored = batcherOutsideAuthorizedView.add(rowMutationEntry); - batcherOutsideAuthorizedView.flush(); + // We should not be able to mutate rows outside the authorized view + String keyOutsideAuthorizedView = UUID.randomUUID() + "-outside-authorized-view"; + RowMutationEntry rowMutationEntry = RowMutationEntry.create(keyOutsideAuthorizedView); + rowMutationEntry.setCell( + testEnvRule.env().getFamilyId(), AUTHORIZED_VIEW_COLUMN_QUALIFIER, "test-value"); + try { + ApiFuture ignored = batcher.add(rowMutationEntry); + batcher.flush(); + fail("Should not be able to apply bulk mutation on rows outside authorized view"); + } catch (Exception e) { + // ignore } - fail("Should not be able to apply bulk mutation on rows outside authorized view"); - } catch (Exception e) { - // Ignore. } testEnvRule From df64317384c1aa51c00ad65d7f1cabd73ae5bc5d Mon Sep 17 00:00:00 2001 From: Mattie Fu Date: Thu, 7 May 2026 10:23:40 -0400 Subject: [PATCH 2/2] fix Change-Id: Iec3186a92b425124b4f645b689fa9d85d391f054 --- .../google/cloud/bigtable/data/v2/it/BulkMutateIT.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/BulkMutateIT.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/BulkMutateIT.java index ac6c7d2c14ad..aaf32decfe17 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/BulkMutateIT.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/BulkMutateIT.java @@ -210,10 +210,10 @@ public void testManyMutationsOnAuthorizedView() throws IOException, InterruptedE .bulkMutateRowsSettings() .setBatchingSettings( batchingSettings.toBuilder().setDelayThreshold(Duration.ofHours(1)).build()); - try (BigtableDataClient client = BigtableDataClient.create(settings); - Batcher batcher = - client.newBulkMutationBatcher( - AuthorizedViewId.of(testEnvRule.env().getTableId(), testAuthorizedView.getId()))) { + try (BigtableDataClient client = BigtableDataClient.create(settings)) { + Batcher batcher = + client.newBulkMutationBatcher( + AuthorizedViewId.of(testEnvRule.env().getTableId(), testAuthorizedView.getId())); String familyId = testEnvRule.env().getFamilyId(); for (int i = 0; i < 2; i++) { String key = rowPrefix + "test-key"; @@ -241,6 +241,8 @@ public void testManyMutationsOnAuthorizedView() throws IOException, InterruptedE try { ApiFuture ignored = batcher.add(rowMutationEntry); batcher.flush(); + // error message is only thrown when closing the batcher + batcher.close(); fail("Should not be able to apply bulk mutation on rows outside authorized view"); } catch (Exception e) { // ignore