-
Notifications
You must be signed in to change notification settings - Fork 489
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
Make the test signer easier to use in parallel tests #2373
Conversation
This is especially useful in test code when you want to be able to bring up local servers in your tests without conflicting with a test that might be running in parallel. Currently, the tests tagged challengetest fail on CI when they are run in parallel with each other because only one test is able to bring up a Signer on port 1234. The others silently fail to bring up a signer, and the signer brought up by the first one may not still be around when subsequently started parallel tests need one.
This makes the linter happy.
Previously, tests running in parallel would interfere with each other because the hard-coded signer port (1234) could only be bound in one of the two tests. Now, the signer starts on an operating-system provided unused port.
These are fully expected and shouldn't be considered errors.
`!=` would have missed when those errors were wrapped.
Both the httpServer struct's Addr and the SignerURL function can just use the address directly.
This allows us to know the port we're listening on from the moment of construction, but only start the server when Start is called.
Okay. This change now uses the new net.FreeTCPPortListener() function and uses the At this point, I'm "mildly" bothered that simply constructing the SigningServer also starts listening on the port. I think it's a bit counter-intuitive. If reviewers agree, I'll move the call 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.
Looks good!
At this point, I'm "mildly" bothered that simply constructing the SigningServer also starts listening on the port.
I don't mind it.
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.
A few comments, but this is going in the right direction. Labeled.
Specifically: 1. Move the net package to util/testhelpers. 2. Remove the concurrency test. 3. Rename the SignerServer listner member.
Previously, tests running in parallel would interfere with each other because the hard-coded signer port (1234) could only be bound in one of the two tests.
Now, the signer starts on an operating-system provided unused port.