-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
rpctest: integration test harness fixes #2071
Conversation
Pull Request Test Coverage Report for Build 7298210334
💛 - Coveralls |
integration/rpctest/rpc_harness.go
Outdated
// if no port is found and the maximum available TCP port is reached. | ||
func NextAvailablePortForProcess(pid int) int { | ||
lockFile := fmt.Sprintf( | ||
"%s/rpctest-port-pid-%d.lock", os.TempDir(), pid, |
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.
curious about whether this would behave the same on windows?
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.
Oh, good point. I think we need to explicitly close a file before we can delete it. And we should probably use filepath.Join()
instead of fmt.Sprintf()
to create the path. Will fix.
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.
Updated things to be more Windows friendly.
|
||
// We take the next one. | ||
lastPort++ | ||
for lastPort < 65535 { |
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.
I think if we just listen to port 0 it will give us a random free port? Something like this
https://github.com/phayes/freeport/blob/master/freeport.go#L8
or this,
https://gist.github.com/sevkin/96bdae9274465b2d09191384f86ef39d
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.
Yes, but we do want ports in order so we can incrementally distribute them. Otherwise we'd need to keep a list of already used ports in the file instead of just the last one we used.
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.
LGTM ⚙️
Merge pending that windows fix.
0ac03ae
to
4bf8b11
Compare
4bf8b11
to
203c984
Compare
I updated things a bit with the node's |
It looks like #1955 broke the compilation on 32-bit systems. I added a commit to fix that, @kcalvinalvin could you take a look at the last commit in this PR please? |
This commit adds a new NextAvailablePortForProcess function that takes a process ID and then assures unique (non-occupied) port numbers are returned per process. This uses a temporary file that contains the latest used port and a secondary temporary lock file to assure only a single goroutine can request a new port at a time. The GenerateProcessUniqueListenerAddresses is intened to be used as a package-level override for the ListenAddressGenerator variable. We don't use it by default to make sure we don't break any existing assumptions.
38c904b
to
b308ab4
Compare
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.
LGTM🏖
b308ab4
to
7644d14
Compare
This fixes two issues with the current RPC integration test framework: