Repository navigation
test(functional): start a ServerProcess again when another process took its port - #555
Conversation
…her process took its port FreePort closes its listener before the Server binds the port, so another process, such as the host port of a test container, can take it first. The Server then stops with AddressInUseException and the role test fails. A start that fails to bind now runs again on a new port, at most three times.
|
review-gate: passed 5ccf75e One independent thermo-nuclear review ran. It found no high or medium finding. It ran the built Server with its port held and confirmed that the JSON console output names Open findings:
|
|
verifier: PASS fbc1b5f Base: c43bb23 (main) Hack (temporary, uncommitted, the same patch at base and head): Command:
At base each of the 5 failures is "The Server stopped with exit code 1" with |
Why
CI on #553 failed
a_worker_whose_worker_group_stops_on_a_fault_of_the_job_store_is_unhealthywithFailed to bind to address http://127.0.0.1:32785: address already in use.ServerProcess.FreePortcloses its listener before the Server child binds the port, so another process can take it first. Port 32785 is at the bottom of the range that Docker gives to the host ports of test containers.What changed
ServerProcess.StartAsyncstarts the Server again on a new port when the child stops withAddressInUseException, at most three times. A failed start is disposed before the next one.AddressInUseException.Tradeoffs
A child that binds port 0 and reports its address removes the race. It needs a log override for
Microsoft.Hosting.Lifetimeand a parse of two unnamedhttp://127.0.0.1:Nlines (thehttpand thegrpcendpoints), so the retry is the smaller fix.Verification
FreePortgave. On the old helper, 4 of 6ServerRoleTestsfailed withThe Server stopped with exit code 1. With the retry, 6 of 6 passed. Without the hack, 6 of 6 passed.