Skip to content

Commit

Permalink
fix: fix the write api integration test (#2333)
Browse files Browse the repository at this point in the history
* fix: an atempt to solve test failure in nightly build

* dummy PR to trigger integration test
  • Loading branch information
GaoleMeng committed Nov 29, 2023
1 parent 1e1b60c commit a69bec9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Expand Up @@ -586,6 +586,12 @@ ConnectionWorkerPool getTestOnlyConnectionWorkerPool() {
return connectionWorkerPool;
}

// A method to clear the static connectio pool to avoid making pool visible to other tests.
@VisibleForTesting
static void clearConnectionPool() {
connectionPoolMap.clear();
}

/** A builder of {@link StreamWriter}s. */
public static final class Builder {
private static final long DEFAULT_MAX_INFLIGHT_REQUESTS = 1000L;
Expand Down
Expand Up @@ -55,7 +55,7 @@ public class ConnectionWorkerPoolTest {
private static MockServiceHelper serviceHelper;
private BigQueryWriteSettings clientSettings;

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

Expand Down Expand Up @@ -372,6 +372,7 @@ public void testToTableName() {
@Test
public void testCloseExternalClient()
throws IOException, InterruptedException, ExecutionException {
StreamWriter.clearConnectionPool();
// Try append 100 requests.
long appendCount = 100L;
// testBigQueryWrite is used to
Expand Down Expand Up @@ -417,6 +418,10 @@ public void testCloseExternalClient()
assertThat(response.getAppendResult().getOffset().getValue()).isEqualTo(i);
}
assertThat(testBigQueryWrite.getAppendRequests().size()).isEqualTo(appendCount * 2);
for (int i = 0; i < streamWriterList.size(); i++) {
streamWriterList.get(i).close();
}
StreamWriter.clearConnectionPool();
}

private AppendRowsResponse createAppendResponse(long offset) {
Expand Down

0 comments on commit a69bec9

Please sign in to comment.