-
Notifications
You must be signed in to change notification settings - Fork 11
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
fix: support parallel servers in tests #357
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #357 +/- ##
==========================================
- Coverage 80.84% 80.80% -0.04%
==========================================
Files 35 35
Lines 1618 1620 +2
Branches 1618 1620 +2
==========================================
+ Hits 1308 1309 +1
Misses 245 245
- Partials 65 66 +1 ☔ View full report in Codecov by Sentry. |
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.
Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @dafnamatsry, @giladchase, and @yair-starkware)
crates/tests-integration/src/integration_test_utils.rs
line 85 at r1 (raw file):
} /// Get a unique ip address and port for testing purposes.
Suggestion:
/// Returns a unique IP address and port for testing purposes.
crates/tests-integration/src/integration_test_utils.rs
line 89 at r1 (raw file):
/// Tests run in parallel, so servers (like RPC or web) running on separate tests must have /// different ports, otherwise the server will fail with "address already in use". pub async fn available_socket() -> SocketAddr {
Suggestion:
get_available_socket
crates/tests-integration/src/integration_test_utils.rs
line 94 at r1 (raw file):
.expect("Failed to bind to address") .local_addr() .expect("Failed to get local address")
Converted your explanation above to documentation.
Suggestion:
// Dinamically select port.
// First, set the port to 0 (dynamic port).
TcpListener::bind("127.0.0.1:0")
.await
.expect("Failed to bind to address")
// Then, resolve to the actual selected port.
.local_addr()
.expect("Failed to get local address")
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.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dafnamatsry, @elintul, and @yair-starkware)
crates/tests-integration/src/integration_test_utils.rs
line 94 at r1 (raw file):
Previously, elintul (Elin) wrote…
Converted your explanation above to documentation.
🔥
c269516
to
fd11822
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.
Reviewed 2 of 2 files at r2, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @dafnamatsry and @yair-starkware)
In order to add additional integration tests, the Web and RPC servers must run on unique addresses, otherwise trying to create an additional server will fail due to the socket already being in use. This is achieved by selecting the port dynamically, through setting the port as 0 (dynamic port), which `local_addr` then resolves into an the actual port selected, that is, replacing `127.0.0.1:0` with `127.0.0.1:<available_port_that_was_bound_by_TcpListener>`
fd11822
to
cba6eb5
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.
Reviewed 2 of 2 files at r3, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @dafnamatsry and @yair-starkware)
In order to add additional integration tests, the Web and RPC servers
must run on unique addresses, otherwise trying to create an additional
server will fail due to the socket already being in use.
This is achieved by selecting the port dynamically, through setting the
port as 0 (dynamic port), which
local_addr
then resolves into anthe actual port selected, that is, replacing
127.0.0.1:0
with127.0.0.1:<available_port_that_was_bound_by_TcpListener>
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)