Commit a69bec9 1 parent 1e1b60c commit a69bec9 Copy full SHA for a69bec9
File tree 2 files changed +12
-1
lines changed
google-cloud-bigquerystorage/src
main/java/com/google/cloud/bigquery/storage/v1
test/java/com/google/cloud/bigquery/storage/v1
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -586,6 +586,12 @@ ConnectionWorkerPool getTestOnlyConnectionWorkerPool() {
586
586
return connectionWorkerPool ;
587
587
}
588
588
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
+
589
595
/** A builder of {@link StreamWriter}s. */
590
596
public static final class Builder {
591
597
private static final long DEFAULT_MAX_INFLIGHT_REQUESTS = 1000L ;
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ public class ConnectionWorkerPoolTest {
55
55
private static MockServiceHelper serviceHelper ;
56
56
private BigQueryWriteSettings clientSettings ;
57
57
58
- private static final String TEST_TRACE_ID = "home:job1 " ;
58
+ private static final String TEST_TRACE_ID = "DATAFLOW:job_id " ;
59
59
private static final String TEST_STREAM_1 = "projects/p1/datasets/d1/tables/t1/streams/_default" ;
60
60
private static final String TEST_STREAM_2 = "projects/p1/datasets/d1/tables/t2/streams/_default" ;
61
61
@@ -372,6 +372,7 @@ public void testToTableName() {
372
372
@ Test
373
373
public void testCloseExternalClient ()
374
374
throws IOException , InterruptedException , ExecutionException {
375
+ StreamWriter .clearConnectionPool ();
375
376
// Try append 100 requests.
376
377
long appendCount = 100L ;
377
378
// testBigQueryWrite is used to
@@ -417,6 +418,10 @@ public void testCloseExternalClient()
417
418
assertThat (response .getAppendResult ().getOffset ().getValue ()).isEqualTo (i );
418
419
}
419
420
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 ();
420
425
}
421
426
422
427
private AppendRowsResponse createAppendResponse (long offset ) {
You can’t perform that action at this time.
0 commit comments