[TESTS] Set SO_LINGER and SO_REUSEADDR on the mock socket#34211
Merged
bizybot merged 5 commits intoelastic:masterfrom Oct 3, 2018
Merged
[TESTS] Set SO_LINGER and SO_REUSEADDR on the mock socket#34211bizybot merged 5 commits intoelastic:masterfrom
bizybot merged 5 commits intoelastic:masterfrom
Conversation
In the load balancing test (SessionFactoryLoadBalancingTests - testRoundRobinWithFailures()) we kill ldap servers randomly and immediately bind to that port connecting to mock server socket. This is done to avoid someone else listening to this port. As the creation of mock socket and binding to the port is immediately, sometimes the earlier socket would be in TIME_WAIT state thereby having problems with either bind or connect. This commit sets the SO_REUSEADDR explicitly to `true` and also sets the linger on time to `0`(as we are not writing any data) so as to allow re-use of the port and close immediately. Note: I could not find other places where this might be problematic but looking at test runs and netstat output I do see lot of sockets in TIME_WAIT. If we find that this needs to be addressed we can wrap ServerSocketFactory to set these options and use that with in memory ldap server configuration during tests. Closes elastic#32190
Collaborator
|
Pinging @elastic/es-security |
jaymode
approved these changes
Oct 2, 2018
Member
jaymode
left a comment
There was a problem hiding this comment.
I left a couple of minor comments, otherwise LGTM. Please make sure to get an approval from either @tbrooks8 or @original-brownbear before merging (thanks @jasontedor for requesting their review)
| private MockSocket openMockServerSocket(InetAddress remoteAddress, int remotePort, InetAddress localAddress, int localPort) | ||
| throws IOException { | ||
| final MockSocket socket = new MockSocket(); | ||
| socket.setReuseAddress(true); // allow binding even if the previous socket is in timed state. |
Contributor
Author
There was a problem hiding this comment.
Changed this, Thank you.
| } | ||
|
|
||
| @SuppressForbidden(reason = "Allow opening socket for test") | ||
| private MockSocket openMockServerSocket(InetAddress remoteAddress, int remotePort, InetAddress localAddress, int localPort) |
Member
There was a problem hiding this comment.
this isn't a server socket, so I think the method should be openMockSocket
Contributor
Author
There was a problem hiding this comment.
Yes, changed this. Thank you.
bizybot
added a commit
that referenced
this pull request
Oct 3, 2018
In SessionFactoryLoadBalancingTests#testRoundRobinWithFailures() we kill ldap servers randomly and immediately bind to that port connecting to mock server socket. This is done to avoid someone else listening to this port. As the creation of mock socket and binding to the port is immediate, sometimes the earlier socket would be in TIME_WAIT state thereby having problems with either bind or connect. This commit sets the SO_REUSEADDR explicitly to true and also sets the linger on time to 0(as we are not writing any data) so as to allow re-use of the port and close immediately. Note: I could not find other places where this might be problematic but looking at test runs and netstat output I do see lot of sockets in TIME_WAIT. If we find that this needs to be addressed we can wrap ServerSocketFactory to set these options and use that with in memory ldap server configuration during tests. Closes #32190
jasontedor
added a commit
to jasontedor/elasticsearch
that referenced
this pull request
Oct 4, 2018
* master: (25 commits) HLRC: ML Adding get datafeed stats API (elastic#34271) Small fixes to the HLRC watcher documentation. (elastic#34306) Tasks: Document that status is not semvered (elastic#34270) HLRC: ML Add preview datafeed api (elastic#34284) [CI] Fix bogus ScheduleWithFixedDelayTests.testRunnableRunsAtMostOnceAfterCancellation Fix error in documentation for activete watch SCRIPTING: Terms set query expression (elastic#33856) Logging: Drop remaining Settings log ctor (elastic#34149) [ML] Remove unused last_data_time member from Job (elastic#34262) Docs: Allow skipping response assertions (elastic#34240) HLRC: Add activate watch action (elastic#33988) [Security] Multi Index Expression alias wildcard exclusion (elastic#34144) [ML] Label anomalies with multi_bucket_impact (elastic#34233) Document smtp.ssl.trust configuration option (elastic#34275) Support PKCS#11 tokens as keystores and truststores (elastic#34063) Fix sporadic failure in NestedObjectMapperTests [Authz] Allow update settings action for system user (elastic#34030) Replace version with reader cache key in IndicesRequestCache (elastic#34189) [TESTS] Set SO_LINGER and SO_REUSEADDR on the mock socket (elastic#34211) Security: upgrade unboundid ldapsdk to 4.0.8 (elastic#34247) ...
jasontedor
added a commit
to jasontedor/elasticsearch
that referenced
this pull request
Oct 4, 2018
* rename-ccr-stats: (25 commits) HLRC: ML Adding get datafeed stats API (elastic#34271) Small fixes to the HLRC watcher documentation. (elastic#34306) Tasks: Document that status is not semvered (elastic#34270) HLRC: ML Add preview datafeed api (elastic#34284) [CI] Fix bogus ScheduleWithFixedDelayTests.testRunnableRunsAtMostOnceAfterCancellation Fix error in documentation for activete watch SCRIPTING: Terms set query expression (elastic#33856) Logging: Drop remaining Settings log ctor (elastic#34149) [ML] Remove unused last_data_time member from Job (elastic#34262) Docs: Allow skipping response assertions (elastic#34240) HLRC: Add activate watch action (elastic#33988) [Security] Multi Index Expression alias wildcard exclusion (elastic#34144) [ML] Label anomalies with multi_bucket_impact (elastic#34233) Document smtp.ssl.trust configuration option (elastic#34275) Support PKCS#11 tokens as keystores and truststores (elastic#34063) Fix sporadic failure in NestedObjectMapperTests [Authz] Allow update settings action for system user (elastic#34030) Replace version with reader cache key in IndicesRequestCache (elastic#34189) [TESTS] Set SO_LINGER and SO_REUSEADDR on the mock socket (elastic#34211) Security: upgrade unboundid ldapsdk to 4.0.8 (elastic#34247) ...
kcm
pushed a commit
that referenced
this pull request
Oct 30, 2018
In SessionFactoryLoadBalancingTests#testRoundRobinWithFailures() we kill ldap servers randomly and immediately bind to that port connecting to mock server socket. This is done to avoid someone else listening to this port. As the creation of mock socket and binding to the port is immediate, sometimes the earlier socket would be in TIME_WAIT state thereby having problems with either bind or connect. This commit sets the SO_REUSEADDR explicitly to true and also sets the linger on time to 0(as we are not writing any data) so as to allow re-use of the port and close immediately. Note: I could not find other places where this might be problematic but looking at test runs and netstat output I do see lot of sockets in TIME_WAIT. If we find that this needs to be addressed we can wrap ServerSocketFactory to set these options and use that with in memory ldap server configuration during tests. Closes #32190
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
SessionFactoryLoadBalancingTests#testRoundRobinWithFailures()we kill ldap servers randomly and immediately bind to that port
connecting to mock server socket. This is done to avoid someone else
listening to this port. As the creation of mock socket and binding to the
port is immediate, sometimes the earlier socket would be in
TIME_WAITstatethereby having problems with either bind or connect.
This commit sets the SO_REUSEADDR explicitly to
trueand also setsthe linger on time to
0(as we are not writing any data) so as toallow re-use of the port and close immediately.
Note: I could not find other places where this might be problematic
but looking at test runs and netstat output I do see lot of sockets
in TIME_WAIT. If we find that this needs to be addressed we can
wrap ServerSocketFactory to set these options and use that with in
memory ldap server configuration during tests.
Closes #32190