-
Notifications
You must be signed in to change notification settings - Fork 210
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
Use ephemeral ports in integration tests #1780
Use ephemeral ports in integration tests #1780
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 but please take a look at my comment related to reflection
@VisibleForTesting | ||
@SuppressWarnings("unchecked") | ||
public int getPort() { | ||
Field channelsField = FieldUtils.getDeclaredField(Undertow.class, "channels", true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to use reflection to read Undertow port? According to a thread on Stackoverflow something like this should work:
InetSocketAddress socketAddress = (InetSocketAddress) undertow.getListenerInfo().stream().findFirst().orElseThrow(() -> new IllegalStateException("No port available yet.")).getAddress();
return socketAddress.getPort();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I applied your suggestion. Thanks.
@@ -151,4 +159,23 @@ private HttpHandler handlers() { | |||
private boolean isFrontendRequestDumperEnabled() { | |||
return hermesServerParameters.isRequestDumperEnabled(); | |||
} | |||
|
|||
@VisibleForTesting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, this annotation makes the method visible in tests. So do we need this annotation when the method is public, or do we need the public access modifier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand correctly, this annotation makes the method visible in tests.
Nope, this annotation is from Guava and doesn't change anything, it only states that the method was created only for tests. But your question is still valid whether we need it or not. When comes to me, it's ok to use it as it states explicite that the method was created only for test purposes and maybe you shouldn't use it in production.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need it. I added it just to emphasize the purpose of this method. After reconsideration, I removed it to avoid causing confusion, as we don't follow a convention of marking methods that way.
024b170
into
integration_tests_framework
No description provided.