Skip to content

Commit

Permalink
fix: try to make test run a bit faster, and update some logs. (#279)
Browse files Browse the repository at this point in the history
  • Loading branch information
yirutang committed May 14, 2020
1 parent 8ad4637 commit 4749b85
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Expand Up @@ -146,7 +146,6 @@ private StreamWriter(Builder builder)
stubSettings =
BigQueryWriteSettings.newBuilder()
.setCredentialsProvider(builder.credentialsProvider)
.setExecutorProvider(builder.executorProvider)
.setTransportChannelProvider(builder.channelProvider)
.setEndpoint(builder.endpoint)
.build();
Expand Down Expand Up @@ -250,15 +249,14 @@ public ApiFuture<AppendRowsResponse> append(AppendRowsRequest message) {
* @throws IOException
*/
public void refreshAppend() throws IOException, InterruptedException {
LOG.info("Establish a write connection.");
synchronized (this) {
if (shutdown.get()) {
LOG.warning("Cannot refresh on a already shutdown writer.");
return;
}
// There could be a moment, stub is not yet initialized.
if (clientStream != null) {
LOG.info("Closing the stream");
LOG.info("Closing the stream " + streamName);
clientStream.closeSend();
}
messagesBatch.resetAttachSchema();
Expand Down
Expand Up @@ -516,7 +516,7 @@ public void testStreamReconnectionExceedRetry() throws Exception {
StatusRuntimeException transientError = new StatusRuntimeException(Status.UNAVAILABLE);
testBigQueryWrite.addException(transientError);
testBigQueryWrite.addException(transientError);
ApiFuture<AppendRowsResponse> future3 = sendTestMessage(writer, new String[] {"m3"});
ApiFuture<AppendRowsResponse> future3 = sendTestMessage(writer, new String[] {"toomanyretry"});
try {
future3.get();
Assert.fail("This should fail.");
Expand Down Expand Up @@ -821,12 +821,11 @@ public void testBuilderInvalidArguments() {

@Test
public void testAwaitTermination() throws Exception {
StreamWriter writer =
getTestStreamWriterBuilder().setExecutorProvider(SINGLE_THREAD_EXECUTOR).build();
StreamWriter writer = getTestStreamWriterBuilder().build();
testBigQueryWrite.addResponse(AppendRowsResponse.newBuilder().build());
ApiFuture<AppendRowsResponse> appendFuture1 = sendTestMessage(writer, new String[] {"A"});
writer.shutdown();
assertTrue(writer.awaitTermination(2, TimeUnit.MINUTES));
assertTrue(writer.awaitTermination(1, TimeUnit.MINUTES));
}

@Test
Expand Down

0 comments on commit 4749b85

Please sign in to comment.