Visitar URL original
fix test · googleapis/java-bigtable@74e9d4c · GitHub
Skip to content
This repository was archived by the owner on Aug 30, 2026. It is now read-only.

Commit 74e9d4c

Browse files
committed
fix test
1 parent 78c623f commit 74e9d4c

2 files changed

Lines changed: 25 additions & 7 deletions

File tree

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

‎google-cloud-bigtable-emulator-core/src/main/java/com/google/cloud/bigtable/emulator/core/EmulatorController.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public class EmulatorController {
4747
private boolean isStopped = true;
4848
private Thread shutdownHook;
4949

50+
private Thread processWatcher;
51+
5052
private int port;
5153

5254
public static EmulatorController createFromPath(Path path) {

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

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@
1616
package com.google.cloud.bigtable.data.v2.it;
1717

1818
import static com.google.common.truth.Truth.assertThat;
19+
import static com.google.common.truth.TruthJUnit.assume;
1920

2021
import com.google.api.gax.batching.BatcherImpl;
22+
import com.google.api.gax.batching.BatchingSettings;
2123
import com.google.api.gax.batching.FlowControlEventStats;
2224
import com.google.cloud.bigtable.data.v2.BigtableDataClient;
2325
import com.google.cloud.bigtable.data.v2.BigtableDataSettings;
2426
import com.google.cloud.bigtable.data.v2.models.BulkMutation;
2527
import com.google.cloud.bigtable.data.v2.models.Query;
2628
import com.google.cloud.bigtable.data.v2.models.Row;
2729
import com.google.cloud.bigtable.data.v2.models.RowMutationEntry;
30+
import com.google.cloud.bigtable.test_helpers.env.EmulatorEnv;
2831
import com.google.cloud.bigtable.test_helpers.env.TestEnvRule;
2932
import java.io.IOException;
3033
import java.util.Objects;
@@ -33,6 +36,7 @@
3336
import org.junit.Test;
3437
import org.junit.runner.RunWith;
3538
import org.junit.runners.JUnit4;
39+
import org.threeten.bp.Duration;
3640

3741
@RunWith(JUnit4.class)
3842
public class BulkMutateIT {
@@ -86,24 +90,36 @@ public void test() throws IOException, InterruptedException {
8690

8791
@Test
8892
public void testManyMutations() throws IOException, InterruptedException {
93+
// Emulator is very slow and will take a long time for the test to run
94+
assume()
95+
.withMessage("testManyMutations is not supported on Emulator")
96+
.that(testEnvRule.env())
97+
.isNotInstanceOf(EmulatorEnv.class);
98+
8999
BigtableDataSettings settings = testEnvRule.env().getDataClientSettings();
90100
String rowPrefix = UUID.randomUUID().toString();
91-
// Set target latency really low so it'll trigger adjusting thresholds
92-
BigtableDataSettings.Builder builder =
93-
settings.toBuilder().enableBatchMutationLatencyBasedThrottling(2L);
94101

95-
try (BigtableDataClient client = BigtableDataClient.create(builder.build());
102+
BatchingSettings batchingSettings =
103+
settings.getStubSettings().bulkMutateRowsSettings().getBatchingSettings();
104+
105+
settings
106+
.toBuilder()
107+
.stubSettings()
108+
.bulkMutateRowsSettings()
109+
.setBatchingSettings(
110+
batchingSettings.toBuilder().setDelayThreshold(Duration.ofHours(1)).build());
111+
try (BigtableDataClient client = BigtableDataClient.create(settings);
96112
BatcherImpl<RowMutationEntry, Void, BulkMutation, Void> batcher =
97113
(BatcherImpl<RowMutationEntry, Void, BulkMutation, Void>)
98114
client.newBulkMutationBatcher(testEnvRule.env().getTableId())) {
99115

100116
String familyId = testEnvRule.env().getFamilyId();
101-
for (int i = 0; i < 4; i++) {
117+
for (int i = 0; i < 2; i++) {
102118
String key = rowPrefix + "test-key";
103119
RowMutationEntry rowMutationEntry = RowMutationEntry.create(key);
104120
// Create mutation entries with many columns. The batcher should flush every time.
105121
for (long j = 0; j < 50001; j++) {
106-
rowMutationEntry.setCell(familyId, "q" + j + i, "value" + j);
122+
rowMutationEntry.setCell(familyId, "q" + j + i, j);
107123
}
108124
batcher.add(rowMutationEntry);
109125
}
@@ -116,7 +132,7 @@ public void testManyMutations() throws IOException, InterruptedException {
116132
.readRowsCallable()
117133
.first()
118134
.call(Query.create(testEnvRule.env().getTableId()).rowKey(rowPrefix + "test-key"));
119-
assertThat(row.getCells()).hasSize(50001);
135+
assertThat(row.getCells()).hasSize(100002);
120136
}
121137
}
122138
}

0 commit comments

Comments
 (0)