Watch
0
0
Fork
You've already forked hyperhive
0

swarm-controller: let each test nats-server bind its own port

TestNats picked a port by binding 127.0.0.1:0, dropping the listener
and handing the number to nats-server. Until that server bound it, the
port was free for a concurrent test's bind(0) to return again. Both
servers were then started on it (with the same store dir, since that was
keyed by pid and port); the loser exited silently and both tests'
clients reached the winner. term_stream's tests all use the stream
term-main-iris, and one of them creates it with max_message_size 4096,
so a test sharing its server got "stream name already in use with a
different configuration" (10058) from open_or_create's
get-then-create.

The server now binds a port of its choice (-p -1) and announces it in a
ports file, and each server has its own tempdir for the store and that
file, so a test can only reach the server it started.

Fixes #5261
This commit is contained in:
atlas 2026-10-14 16:27:16 +02:00
commit 41404598f5
3 changed files with 58 additions and 21 deletions

View file

@ -136,6 +136,8 @@ x509-cert.workspace = true
# tests wait out its five-minute bound on paused time.
[dev-dependencies]
tokio = { workspace = true, features = ["test-util"] }
# A fresh directory per test `nats-server`, for its store and ports file.
tempfile = "3"
# `ServiceExt::oneshot`, to drive a route through the real router in tests.
tower = { version = "0.5", features = ["util"] }
# A layer that captures `review_classifier::runs`'s log event in a test.