Skip to content

Commit 58bd85c

Browse files
authored
test: make bulkMutateIT less flaky (googleapis#2911)
* test: make bulk mutate it less flaky Change-Id: I13871cd3a6903eb07ecc272df5bff0519b256816 * fix Change-Id: Iec3186a92b425124b4f645b689fa9d85d391f054
1 parent 5a45afa commit 58bd85c

1 file changed

Lines changed: 17 additions & 22 deletions

File tree

  • google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/BulkMutateIT.java

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@ public void testManyMutationsOnAuthorizedView() throws IOException, InterruptedE
210210
.bulkMutateRowsSettings()
211211
.setBatchingSettings(
212212
batchingSettings.toBuilder().setDelayThreshold(Duration.ofHours(1)).build());
213-
try (BigtableDataClient client = BigtableDataClient.create(settings);
214-
Batcher<RowMutationEntry, Void> batcher =
215-
client.newBulkMutationBatcher(
216-
AuthorizedViewId.of(testEnvRule.env().getTableId(), testAuthorizedView.getId()))) {
213+
try (BigtableDataClient client = BigtableDataClient.create(settings)) {
214+
Batcher<RowMutationEntry, Void> batcher =
215+
client.newBulkMutationBatcher(
216+
AuthorizedViewId.of(testEnvRule.env().getTableId(), testAuthorizedView.getId()));
217217
String familyId = testEnvRule.env().getFamilyId();
218218
for (int i = 0; i < 2; i++) {
219219
String key = rowPrefix + "test-key";
@@ -232,26 +232,21 @@ public void testManyMutationsOnAuthorizedView() throws IOException, InterruptedE
232232
.first()
233233
.call(Query.create(testEnvRule.env().getTableId()).rowKey(rowPrefix + "test-key"));
234234
assertThat(row.getCells()).hasSize(100002);
235-
}
236235

237-
// We should not be able to mutate rows outside the authorized view
238-
try {
239-
try (BigtableDataClient client = BigtableDataClient.create(settings);
240-
Batcher<RowMutationEntry, Void> batcherOutsideAuthorizedView =
241-
client.newBulkMutationBatcher(
242-
AuthorizedViewId.of(
243-
testEnvRule.env().getTableId().getTableId(), testAuthorizedView.getId()))) {
244-
String keyOutsideAuthorizedView = UUID.randomUUID() + "-outside-authorized-view";
245-
RowMutationEntry rowMutationEntry = RowMutationEntry.create(keyOutsideAuthorizedView);
246-
rowMutationEntry.setCell(
247-
testEnvRule.env().getFamilyId(), AUTHORIZED_VIEW_COLUMN_QUALIFIER, "test-value");
248-
@SuppressWarnings("UnusedVariable")
249-
ApiFuture<Void> ignored = batcherOutsideAuthorizedView.add(rowMutationEntry);
250-
batcherOutsideAuthorizedView.flush();
236+
// We should not be able to mutate rows outside the authorized view
237+
String keyOutsideAuthorizedView = UUID.randomUUID() + "-outside-authorized-view";
238+
RowMutationEntry rowMutationEntry = RowMutationEntry.create(keyOutsideAuthorizedView);
239+
rowMutationEntry.setCell(
240+
testEnvRule.env().getFamilyId(), AUTHORIZED_VIEW_COLUMN_QUALIFIER, "test-value");
241+
try {
242+
ApiFuture<Void> ignored = batcher.add(rowMutationEntry);
243+
batcher.flush();
244+
// error message is only thrown when closing the batcher
245+
batcher.close();
246+
fail("Should not be able to apply bulk mutation on rows outside authorized view");
247+
} catch (Exception e) {
248+
// ignore
251249
}
252-
fail("Should not be able to apply bulk mutation on rows outside authorized view");
253-
} catch (Exception e) {
254-
// Ignore.
255250
}
256251

257252
testEnvRule

0 commit comments

Comments
 (0)