Skip to content

Commit

Permalink
chore(test): remove some warnings from tests (#2398)
Browse files Browse the repository at this point in the history
Make sure to close the ephemeral stubs to avoid polluting the logs with unclosed channel errors
  • Loading branch information
igorbernstein2 authored Nov 4, 2024
1 parent 81431d9 commit c3e9230
Showing 1 changed file with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,16 @@ public void testExecuteQueryRequestsIgnoreOverriddenMaxAttempts() throws IOExcep
.stubSettings()
.executeQuerySettings()
.setRetrySettings(RetrySettings.newBuilder().setMaxAttempts(10).build());
EnhancedBigtableStub overrideStub =
EnhancedBigtableStub.create(overrideSettings.build().getStubSettings());
SqlServerStream stream =
overrideStub.executeQueryCallable().call(Statement.of("SELECT * FROM table"));

Iterator<SqlRow> iterator = stream.rows().iterator();
try (EnhancedBigtableStub overrideStub =
EnhancedBigtableStub.create(overrideSettings.build().getStubSettings())) {
SqlServerStream stream =
overrideStub.executeQueryCallable().call(Statement.of("SELECT * FROM table"));
Iterator<SqlRow> iterator = stream.rows().iterator();

assertThrows(UnavailableException.class, iterator::next).getCause();
assertThat(fakeService.attempts).isEqualTo(1);
assertThrows(UnavailableException.class, iterator::next).getCause();
assertThat(fakeService.attempts).isEqualTo(1);
}
}

@Test
Expand Down Expand Up @@ -160,13 +161,15 @@ public void testExecuteQueryRequestsRespectDeadline() throws IOException {
.setInitialRpcTimeout(Duration.ofMillis(10))
.setMaxRpcTimeout(Duration.ofMillis(10))
.build());
EnhancedBigtableStub overrideDeadline =
EnhancedBigtableStub.create(overrideSettings.build().getStubSettings());
SqlServerStream streamOverride =
overrideDeadline.executeQueryCallable().call(Statement.of("SELECT * FROM table"));
Iterator<SqlRow> overrideIterator = streamOverride.rows().iterator();
// We don't care about this but are reusing the fake service that tests retries
assertThrows(DeadlineExceededException.class, overrideIterator::next).getCause();

try (EnhancedBigtableStub overrideDeadline =
EnhancedBigtableStub.create(overrideSettings.build().getStubSettings())) {
SqlServerStream streamOverride =
overrideDeadline.executeQueryCallable().call(Statement.of("SELECT * FROM table"));
Iterator<SqlRow> overrideIterator = streamOverride.rows().iterator();
// We don't care about this but are reusing the fake service that tests retries
assertThrows(DeadlineExceededException.class, overrideIterator::next).getCause();
}
}

private static class FakeService extends BigtableGrpc.BigtableImplBase {
Expand Down

0 comments on commit c3e9230

Please sign in to comment.