Add --random-ports as restate-server command line argument
I'm looking into running the restate-server binary in unit tests (in environments where we do not have access to docker).
It would make it easier if the server could be started on random ports, which it would then print out in an easy parsable format.
This was discussed with @slinkydeveloper on the restate slack channel (conversation will expire in 90 days so may no longer be available).
I gave a try to bind to 0 the various open ports we use, but unfortunately this doesn't work with the node port because there is a cross dependency between the config option bind-address = "0.0.0.0:0" and advertised-address. cc @AhmedSoliman.
I'm afraid the workaround at the moment is to try check if a port is open, then try to bind, and if it doesn't work try again with another port...
If the admin and ingress server supported to bind against a unix domain socket, then one could use random files for testing servers w/o port conflicts. The node server supports it but it hasn't been done for the other two servers afair. Until then, the workaround that slinkydeveloper proposed is the best solution right now if you can't containerize your tests. For some of the cluster tests (using the https://github.com/restatedev/restate/blob/386a5f05f3ad8c10d5521fc04d938efc44d3bc6a/crates/local-cluster-runner/src/cluster/mod.rs#L30) we use the same strategy.