Skip to content

Commit

Permalink
add additional error handling test + some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
igorbernstein2 committed Sep 1, 2020
1 parent 91cb7a5 commit 5e1a94d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ public static EnhancedBigtableStubSettings finalizeSettings(
throws IOException {
EnhancedBigtableStubSettings.Builder builder = settings.toBuilder();

// TODO: this implementation is on the cusp of unwieldy, if we end up adding more features
// consider splitting it up by feature.

// Inject channel priming
if (settings.isRefreshingChannel()) {
// Fix the credentials so that they can be shared
Credentials credentials = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.mockito.Mockito;
import org.mockito.internal.stubbing.answers.ThrowsException;

@RunWith(JUnit4.class)
public class BigtableChannelPrimerTest {
Expand Down Expand Up @@ -158,6 +160,27 @@ public ReadRowsResponse apply(ReadRowsRequest req) {
}
}

@Test
public void testErrorsAreLoggedForBasic() {
BigtableChannelPrimer basicPrimer =
BigtableChannelPrimer.create(
OAuth2Credentials.create(new AccessToken(TOKEN_VALUE, null)),
"fake-project",
"fake-instance",
"fake-app-profile",
ImmutableList.<String>of());

ManagedChannel channel =
Mockito.mock(
ManagedChannel.class, new ThrowsException(new UnsupportedOperationException()));
primer.primeChannel(channel);

assertThat(logHandler.logs).hasSize(1);
for (LogRecord log : logHandler.logs) {
assertThat(log.getMessage()).contains("Unexpected");
}
}

private static class MetadataInterceptor implements ServerInterceptor {
ConcurrentLinkedQueue<Metadata> metadataList = new ConcurrentLinkedQueue<>();

Expand Down

0 comments on commit 5e1a94d

Please sign in to comment.