test(opensearch): pin OpenSearchRunner HTTP port to avoid flaky tests#171
Merged
Conversation
OpenSearchRunner selects an HTTP port via an unreliable connect-based scan that can report a port as free even when it is bound on IPv6, causing intermittent "Address already in use" failures. Reserve a free ephemeral port up front, disable the scan, and pin the runner to it. Claude-Session: https://claude.ai/code/session_0177Ci4EJFMP7jyQQ5XdBgu3
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.
Summary
The OpenSearch backend tests intermittently fail to start the embedded node with "Address already in use".
OpenSearchRunnerselects its HTTP port via a connect-based scan that can report a port as free even when it is already bound on the IPv6 loopback ([::1]), so the node occasionally tries to bind a port that is not actually available. This PR makes the test setup deterministic by reserving a free ephemeral port up front and pinning the runner to it.Changes Made
OpenSearchRunnerUtiltest helper withfindFreePort(), which asks the OS for an ephemeral port vianew ServerSocket(0).CrawlerTest,OpenSearchDataServiceTest,OpenSearchUrlFilterServiceTest, andOpenSearchUrlQueueServiceTestto:runner.setMaxHttpPort(-1).baseHttpPort(httpPort - 1)so the first node binds to the reserved port (the runner usesbaseHttpPort + 1for the first node).FesenClient.HTTP_ADDRESSsystem property.Testing
mvn test -pl fess-crawler-opensearch) to confirm the embedded node starts reliably.Breaking Changes
Additional Notes
OpenSearchRunnerUtil.