Skip to content

Commit a69bec9

Browse files
authored
fix: fix the write api integration test (#2333)
* fix: an atempt to solve test failure in nightly build * dummy PR to trigger integration test
1 parent 1e1b60c commit a69bec9

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

google-cloud-bigquerystorage/src/main/java/com/google/cloud/bigquery/storage/v1/StreamWriter.java

+6
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,12 @@ ConnectionWorkerPool getTestOnlyConnectionWorkerPool() {
586586
return connectionWorkerPool;
587587
}
588588

589+
// A method to clear the static connectio pool to avoid making pool visible to other tests.
590+
@VisibleForTesting
591+
static void clearConnectionPool() {
592+
connectionPoolMap.clear();
593+
}
594+
589595
/** A builder of {@link StreamWriter}s. */
590596
public static final class Builder {
591597
private static final long DEFAULT_MAX_INFLIGHT_REQUESTS = 1000L;

google-cloud-bigquerystorage/src/test/java/com/google/cloud/bigquery/storage/v1/ConnectionWorkerPoolTest.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public class ConnectionWorkerPoolTest {
5555
private static MockServiceHelper serviceHelper;
5656
private BigQueryWriteSettings clientSettings;
5757

58-
private static final String TEST_TRACE_ID = "home:job1";
58+
private static final String TEST_TRACE_ID = "DATAFLOW:job_id";
5959
private static final String TEST_STREAM_1 = "projects/p1/datasets/d1/tables/t1/streams/_default";
6060
private static final String TEST_STREAM_2 = "projects/p1/datasets/d1/tables/t2/streams/_default";
6161

@@ -372,6 +372,7 @@ public void testToTableName() {
372372
@Test
373373
public void testCloseExternalClient()
374374
throws IOException, InterruptedException, ExecutionException {
375+
StreamWriter.clearConnectionPool();
375376
// Try append 100 requests.
376377
long appendCount = 100L;
377378
// testBigQueryWrite is used to
@@ -417,6 +418,10 @@ public void testCloseExternalClient()
417418
assertThat(response.getAppendResult().getOffset().getValue()).isEqualTo(i);
418419
}
419420
assertThat(testBigQueryWrite.getAppendRequests().size()).isEqualTo(appendCount * 2);
421+
for (int i = 0; i < streamWriterList.size(); i++) {
422+
streamWriterList.get(i).close();
423+
}
424+
StreamWriter.clearConnectionPool();
420425
}
421426

422427
private AppendRowsResponse createAppendResponse(long offset) {

0 commit comments

Comments
 (0)