Repository navigation
test: keep other programs off the IPv4 port of the DAP loopback tests - #2035
Conversation
`DAPLoopbackConnectionTest.withoutAnAddressTheWaitForTheDAPServerSeesItsSocketOnTheIPv6LoopbackAddress` failed in the 2026.3 job of redhat-developer#2032, which doesn't touch DAP: org.opentest4j.AssertionFailedError: expected: <false> but was: <true> at ...DAPLoopbackConnectionTest.java:59 The three tests of the class listen on a port of `::1` that the system picks, and expect nothing on the same port of `127.0.0.1`: a connection there must be refused, and a client without an address must fall through to `::1`. A port that is free on `::1` can be in use on `127.0.0.1` by another program or test, and then the connection is accepted and the test fails. The tests now also bind that port of `127.0.0.1` with a socket that doesn't listen, and take another port when it is in use. While it is bound, nothing else can listen there, so a connection to it is refused.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2035 +/- ##
==========================================
+ Coverage 49.39% 49.43% +0.03%
==========================================
Files 813 813
Lines 33323 33323
Branches 5191 5191
==========================================
+ Hits 16461 16472 +11
+ Misses 14290 14278 -12
- Partials 2572 2573 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action not completed
|
|
@coderabbitai review |
Action performed
|
…server on ::1 only (#2043) Two tests of `SocketStreamConnectionProviderTest` have the race that #2035 removes from `DAPLoopbackConnectionTest`. They listen on a port of `::1` that the system picks, and expect nothing on the same port of `127.0.0.1`: - `testWithoutAHostItReachesALanguageServerWhichListensOnTheIPv6LoopbackAddressOnly` expects a provider without a host to fall through to `::1`. With another program on that port of `127.0.0.1`, the provider connects there, and the test waits for a connection to its server that never comes; - `testAnIPv4AddressAsTheHostIsNotTriedOverIPv6` expects the connection to `127.0.0.1` to be refused, and it is accepted. `IPv6OnlyLoopbackPort` listens on a port of `::1` and binds the same port of `127.0.0.1` with a socket that doesn't listen, and takes another port when it is in use there, as #2035 does. While it is bound, nothing else can listen there. Its server's accept times out after 10 seconds rather than hang a test. Test: `SocketStreamConnectionProviderTest` passes on a default JVM and on one that prefers IPv6 addresses (30 tests). `DAPLoopbackConnectionTest` keeps its own copy of the helper in #2035, which is still open; once both are merged, it can use `IPv6OnlyLoopbackPort` too.
DAPLoopbackConnectionTest.withoutAnAddressTheWaitForTheDAPServerSeesItsSocketOnTheIPv6LoopbackAddressfailed in the 2026.3 job of #2032, which doesn't touch DAP:
The three tests of the class listen on a port of
::1that the systempicks, and expect nothing on the same port of
127.0.0.1: a connectionthere must be refused, and a client without an address must fall through
to
::1. A port that is free on::1can be in use on127.0.0.1byanother program or test, and then the connection is accepted and the
test fails.
The tests now also bind that port of
127.0.0.1with a socket thatdoesn't listen, and take another port when it is in use. While it is
bound, nothing else can listen there, so a connection to it is refused.
Tests
Checked on macOS, with another process as the other program:
127.0.0.1on the port that the test has on::1, and a connection to it is then accepted, which is the failure of the job;Address already in use), and the test takes another one;SO_REUSEADDR, nor can aServerSocketwithSO_REUSEADDR, and a connection to it is refused.DAPLoopbackConnectionTestpasses on a default JVM and on one that prefers IPv6 addresses.Not here: two tests of
SocketStreamConnectionProviderTesthave the same race,testWithoutAHostItReachesALanguageServerWhichListensOnTheIPv6LoopbackAddressOnlyandtestAnIPv4AddressAsTheHostIsNotTriedOverIPv6. #2033 and #2034 change that file, so they can follow once those are merged.