Skip to content

Commit 2b9509e

Browse files
authored
s2a: Fix FakeS2AServerTest flakiness
Wait for server response to be received before shutting down resources. Fixes #12501
1 parent 753ed1b commit 2b9509e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

s2a/src/test/java/io/grpc/s2a/internal/handshaker/FakeS2AServerTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import java.util.concurrent.CountDownLatch;
4646
import java.util.concurrent.ExecutorService;
4747
import java.util.concurrent.Executors;
48+
import java.util.concurrent.TimeoutException;
4849
import java.util.logging.Logger;
4950
import org.junit.After;
5051
import org.junit.Before;
@@ -77,7 +78,10 @@ public void tearDown() throws Exception {
7778

7879
@Test
7980
public void callS2AServerOnce_getTlsConfiguration_returnsValidResult()
80-
throws InterruptedException, IOException, java.util.concurrent.ExecutionException {
81+
throws InterruptedException,
82+
IOException,
83+
java.util.concurrent.ExecutionException,
84+
TimeoutException {
8185
ExecutorService executor = Executors.newSingleThreadExecutor();
8286
logger.info("Client connecting to: " + serverAddress);
8387
ManagedChannel channel =
@@ -121,6 +125,7 @@ public void onCompleted() {
121125
// Mark the end of requests.
122126
requestObserver.onCompleted();
123127
// Wait for receiving to happen.
128+
respFuture.get(5, SECONDS);
124129
} finally {
125130
channel.shutdown();
126131
channel.awaitTermination(1, SECONDS);
@@ -165,7 +170,7 @@ public void onCompleted() {
165170

166171
@Test
167172
public void callS2AServerOnce_validatePeerCertifiate_returnsValidResult()
168-
throws InterruptedException, java.util.concurrent.ExecutionException {
173+
throws InterruptedException, java.util.concurrent.ExecutionException, TimeoutException {
169174
ExecutorService executor = Executors.newSingleThreadExecutor();
170175
logger.info("Client connecting to: " + serverAddress);
171176
ManagedChannel channel =
@@ -212,6 +217,7 @@ public void onCompleted() {
212217
// Mark the end of requests.
213218
requestObserver.onCompleted();
214219
// Wait for receiving to happen.
220+
respFuture.get(5, SECONDS);
215221
} finally {
216222
channel.shutdown();
217223
channel.awaitTermination(1, SECONDS);

0 commit comments

Comments
 (0)