This repository was archived by the owner on Dec 19, 2025. It is now read-only.
Repository navigation
Add listen_tcp_on_free_port to return a test port - #41
Merged
Merged
Conversation
DanGould
force-pushed
the
return-port
branch
3 times, most recently
from
December 30, 2024 20:40
25261c1 to
4b8a43c
Compare
DanGould
force-pushed
the
return-port
branch
from
December 30, 2024 21:42
4b8a43c to
e591dd5
Compare
Reduce a bunch of duplicated boilerplate code
Previously in tests downstream ohttp_relay was initiated with a port that may no longer be free by the time it got bound. By having this code bind on and return the port the indirection is removed.
DanGould
force-pushed
the
return-port
branch
from
December 30, 2024 21:43
e591dd5 to
d8f7578
Compare
NGINX was also returning before binding to the port, sometimes leading to port contention with other test services Fix by waiting for it to connect before attempting to start other services
nothingmuch
approved these changes
Dec 31, 2024
Contributor
There was a problem hiding this comment.
not sure about the last commit, i'd prefer if start_nginx returned a Result<NginxProcess>, but i think it's fine to merge this so that listen_tcp_on_free_port is exposed and followup with a refactor, since the new behavior is still an improvement on the old
Comment on lines
+459
to
+464
| while start.elapsed() < timeout { | ||
| if let Ok(_) = std::net::TcpStream::connect(format!("127.0.0.1:{}", n_https_port)) { | ||
| break; | ||
| } | ||
| tokio::time::sleep(std::time::Duration::from_millis(100)).await; | ||
| } |
Contributor
There was a problem hiding this comment.
happy path and error path are not distinguished, which is strange to me... if the timeout elapses and nginx was not yet listening, why proceed?
DanGould
force-pushed
the
return-port
branch
2 times, most recently
from
December 31, 2024 03:10
e04c6ce to
d8f7578
Compare
Member
Author
|
I accidentally pushed the fix here but will open it in a new PR. that was a brain fart, obviously we want to separate the paths and return an error if we fail. I'm going to merge the approved commit to enable forward motion |
This was referenced Dec 31, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously in tests downstream ohttp_relay was initiated with a port
that may no longer be free by the time it got bound. By having this
code bind on and return the port the indirection is removed.
I also found that the way I was having NGINX listen on a free port may also have led to the same problem, so the 3rd commit ensures NGINX is bound before the ohttp_relay tries to get a free port.