-
Notifications
You must be signed in to change notification settings - Fork 11.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attempt to fix port clash by using different starting port for each test #545
Conversation
Is it possible to avoid manually setting a starting port for each test? That makes it difficult to track and easy to make mistakes. I imagine at least we could use a shared static variable? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for getting back to this!!!
The PortAllocator
we have now makes a lot of sense to me in production: it makes sure we start looking for a port at a specific place, and if the server doesn't have an open port there, it makes things easy to debug : try the following ports in order until you find where your server started.
However, for tests, that's completely overkill: I don't care where I'm gonna end up, and I can just bind to 127.0.0.1:0
and let the underlying OS sort it out.
The PortAllocator
takes a u16
argument to start the port search. Is there a way to refactor it to take an Option<u16>
where the default semantics of None
would be to do TcpListener::bind(("127.0.0.1:0")).is_ok()
? That should provide an easy-to-use default for tests.
Besides that, you start_network
is 🤩
Hmm this is harder then expected... Currently the ports are pre allocated at setup phase (genesis) ahead of the server start up, because we need the port ahead of time to create the I explored the possibility of starting the server first using '127.0.0.1:0' then create
So for now I think using different starting port for each test is an easier fix for now until we refactor |
@patrickkuo So what I'm hearing is that the constructor of the |
Yes the authority server should start using port 0 without problem.... but the wallet won't know which port to connect to... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I've investigated the start of the genesis network enough to be convinced: at the moment we deduce network, genesis and wallet config from each other, and then start the network.
From that moment on, it's hard to get any information back from the network, which makes my fix based on binding to zero pointless (but I note it also makes the info of the PortAllocator
very speculative).
Let's land this to stop the bleeding, I'll try a few tricks to refactor on the downstream.
2a77fac
to
2b09e86
Compare
* test of consensus restore * hack * Fix consensus_restore test (#519) * Revert "hack" This reverts commit f06f9ec782141f8db614ab34fd3a0b95f089f2c1. * fix: adapt the worker address, remove a few mut * test node restore with cluster and switch metric type * update fail message Co-authored-by: François Garillot <4142+huitseeker@users.noreply.github.com>
* test of consensus restore * hack * Fix consensus_restore test (MystenLabs#519) * Revert "hack" This reverts commit f06f9ec782141f8db614ab34fd3a0b95f089f2c1. * fix: adapt the worker address, remove a few mut * test node restore with cluster and switch metric type * update fail message Co-authored-by: François Garillot <4142+huitseeker@users.noreply.github.com>
this should fix #494