Tezt: Change how fresh ports are generated in a reliable way
We propose a standard way to get a fresh port which is guaranteed to be unused. This requires two cheap system calls.
While this method does not seems to be specified by POSIX, this behavior since to be the one implemented by the popular OS used (including Linux, MacOS).
How to test it?
On my machine if I do:
git checkout 7a4f152ebb
make && tezt --test "Alpha: Testing DAL node (dal attestor)" --loop --keep-going -j 5
I tend to have a lot of times the following errors:
[16:41:54.048] [node1] octez-node: Error:
[16:41:54.048] [node1] An error occured while initializing P2P server on this address: 127.0.0.1:18384.
[16:41:54.048] [node1] Reason: Address already in use.
[16:41:54.048] [node1] Another tezos node is probably running on this address.
[16:41:54.048] [node1] Please choose another P2P port using --net-addr.
[16:41:54.048] [node1]
which shows a limitation of Tezt heuristic. If you apply this patch on top of this MR, this error disappears.
I tend to believe that the trade-off is worth it since those tests are mostly run by Tezos developers and the CI.
Edited by François Thiré