Skip to content

Commit

Permalink
Don't use Utils.pickUnusedPort. (#11601)
Browse files Browse the repository at this point in the history
  • Loading branch information
rmehta19 authored Oct 8, 2024
1 parent 0a3c034 commit 9d252c2
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import io.grpc.StatusRuntimeException;
import io.grpc.TlsChannelCredentials;
import io.grpc.TlsServerCredentials;
import io.grpc.benchmarks.Utils;
import io.grpc.internal.SharedResourceHolder.Resource;
import io.grpc.netty.NettyServerBuilder;
import io.grpc.stub.StreamObserver;
Expand Down Expand Up @@ -123,7 +122,7 @@ public void getChannelResource_twoDistinctChannels() {
InsecureChannelCredentials.create());
Resource<Channel> resourceTwo =
S2AHandshakerServiceChannel.getChannelResource(
"localhost:" + Utils.pickUnusedPort(), InsecureChannelCredentials.create());
"localhost:" + plaintextServer.getPort() + 1, InsecureChannelCredentials.create());
assertThat(resourceTwo).isNotEqualTo(resource);
}

Expand All @@ -135,7 +134,7 @@ public void getChannelResource_mtlsTwoDistinctChannels() throws Exception {
"localhost:" + mtlsServer.getPort(), getTlsChannelCredentials());
Resource<Channel> resourceTwo =
S2AHandshakerServiceChannel.getChannelResource(
"localhost:" + Utils.pickUnusedPort(), getTlsChannelCredentials());
"localhost:" + mtlsServer.getPort() + 1, getTlsChannelCredentials());
assertThat(resourceTwo).isNotEqualTo(resource);
}

Expand Down Expand Up @@ -229,13 +228,13 @@ private static Server createMtlsServer() throws Exception {
.clientAuth(TlsServerCredentials.ClientAuth.REQUIRE)
.build();
return grpcCleanup.register(
NettyServerBuilder.forPort(Utils.pickUnusedPort(), creds).addService(service).build());
NettyServerBuilder.forPort(0, creds).addService(service).build());
}

private static Server createPlaintextServer() {
SimpleServiceImpl service = new SimpleServiceImpl();
return grpcCleanup.register(
ServerBuilder.forPort(Utils.pickUnusedPort()).addService(service).build());
ServerBuilder.forPort(0).addService(service).build());
}

private static ChannelCredentials getTlsChannelCredentials() throws Exception {
Expand Down

0 comments on commit 9d252c2

Please # to comment.