Skip to content

test(agent): let the system pick the UDP listener port - #59

Merged
youndie merged 1 commit into
mainfrom
test/agent-udp-ephemeral-ports
Oct 2, 2026
Merged

youndie merged 1 commit into
mainfrom
test/agent-udp-ephemeral-ports

Conversation

@youndie

@youndie youndie commented Oct 2, 2026

Copy link
Copy Markdown
Owner

UdpSenderTest bound its listeners on the hardcoded ports 19317–19319. The same commonTest classes run under jvmTest and linuxX64Test, and in one Gradle invocation those two tasks run at the same time (org.gradle.parallel=true), so two processes shared three ports and whichever bound second failed. Whether it failed depended only on whether the two suites happened to overlap.

The listener now binds port 0 and reads the port back; the sender is pointed at that.

Shown red before, green after

On a Linux x64 host, the native test binary filtered to UdpSenderTest was run 80 times in a loop while :agent:jvmTest --rerun --tests '*UdpSenderTest' ran three times beside it — the overlap the two Gradle tasks produce by chance, made certain:

jvm runs native loop
main (b2d268d) 3 of 3 red — java.net.BindException: Address already in use 1 of 80 failed — the binary aborted (core dumped)
this branch 3 of 3 green 80 of 80 ok

And the plain form, ./gradlew :agent:jvmTest --rerun :agent:linuxX64Test --rerun :agent:ktlintCheck, three times on this branch: green 3 of 3 (18 native tests, all 6 jvm classes).

The server has the same shape in UdpReceiverTest (fixed 19313). That one is fixed together with #57, which changes how UdpReceiver gets its socket and lets the test read the bound port back.

jvmTest and linuxX64Test run the same commonTest classes at the same time in one Gradle invocation, so the hardcoded 19317-19319 were shared by two processes and whichever bound second failed on a busy port. Bind port 0 and read the port back.
@youndie
youndie merged commit bc84ece into main Oct 2, 2026
1 check passed
@youndie
youndie deleted the test/agent-udp-ephemeral-ports branch October 2, 2026 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant