Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flakey RoundRobinConnectionPoolTest test #7421

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,14 @@ protected void service(String target, Request jettyRequest, HttpServletRequest r
assertTrue(clientLatch.await(count, TimeUnit.SECONDS));
assertEquals(count, remotePorts.size());

// Unix Domain does not have ports.
if (transport == Transport.UNIX_DOMAIN)
return;

// UDP does not have TIME_WAIT so ports may be reused by different connections.
if (transport == Transport.H3)
return;

// Maps {remote_port -> number_of_times_port_was_used}.
Map<Integer, Long> results = remotePorts.stream()
.collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
Expand All @@ -257,7 +265,6 @@ protected void service(String target, Request jettyRequest, HttpServletRequest r
// [p1, p2, p3 | p1, p2, p3 | p4, p4, p5 | p6, p5, p7]
// Opening p5 and p6 was delayed, so the opening of p7 was triggered
// to replace p4 while p5 and p6 were busy sending their requests.
if (transport != Transport.UNIX_DOMAIN)
assertThat(remotePorts.toString(), count / maxUsage, lessThanOrEqualTo(results.size()));
assertThat(results.toString(), count / maxUsage, lessThanOrEqualTo(results.size()));
}
}