-
Notifications
You must be signed in to change notification settings - Fork 98
Add a separate test for wireguard tunnel #6506
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
Conversation
📝 Walkthrough📝 WalkthroughWalkthroughThe changes introduce a new dependency on the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 6
Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Files selected for processing (3)
- hoprd/rest-api/src/session.rs (1 hunks)
- tests/hopr.py (1 hunks)
- tests/test_integration.py (2 hunks)
Additional context used
Ruff
tests/test_integration.py
880-880: Module level import not at top of file
(E402)
885-885: f-string without any placeholders
Remove extraneous
f
prefix(F541)
922-922: Line too long (125 > 120)
(E501)
Additional comments not posted (2)
tests/hopr.py (1)
388-393
: Changes align with PR objectivesThe modification to the
session_client
method, which now allows specifying the host for the session client, aligns well with the PR objective of adding a separate test for the WireGuard tunnel. This change provides the flexibility needed to test different network configurations, which is crucial for thoroughly testing WireGuard tunnel functionality.hoprd/rest-api/src/session.rs (1)
52-52
: 🛠️ Refactor suggestionEnsure consistency in field naming and update documentation
The renaming of "listen_host" to "listenHost" aligns with the
#[serde(rename_all = "camelCase")]
attribute. However, other fields in the struct still use snake_case naming. Consider the following actions:
- Update all field names in the struct to use camelCase for consistency with the serde attribute.
- Update any documentation or API specifications that reference the old field name.
- Ensure that this change doesn't break existing clients that may be using the old field name.
Consider updating all field names in the struct to camelCase:
#[serde(rename_all = "camelCase")] pub(crate) struct SessionClientRequest { #[serde_as(as = "DisplayFromStr")] - pub destination: PeerId, - pub path: RoutingOptions, - pub target: String, + pub destination: PeerId, + pub path: RoutingOptions, + pub target: String, pub listen_host: Option<String>, #[serde_as(as = "Option<Vec<DisplayFromStr>>")] - pub capabilities: Option<Vec<SessionCapability>>, + pub capabilities: Option<Vec<SessionCapability>>, }To ensure this change doesn't break existing usage, run the following script:
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.
Actionable comments posted: 3
Outside diff range comments (1)
transport/session/Cargo.toml (1)
Line range hint
28-49
: Consider grouping related dependenciesWhile the changes look good, you might want to consider grouping related dependencies together for better readability. For example, you could move the "hopr-metrics" dependency closer to other HOPR-related dependencies.
Here's a suggested regrouping:
[dependencies] # ... other dependencies ... hopr-network-types = { workspace = true } hopr-crypto-random = { workspace = true } hopr-crypto-types = { workspace = true } hopr-internal-types = { workspace = true } hopr-metrics = { workspace = true, optional = true } hopr-primitive-types = { workspace = true } # ... rest of the file ...
Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Files ignored due to path filters (1)
Cargo.lock
is excluded by!**/*.lock
Files selected for processing (4)
- METRICS.md (1 hunks)
- transport/api/Cargo.toml (1 hunks)
- transport/session/Cargo.toml (2 hunks)
- transport/session/src/types.rs (2 hunks)
Additional comments not posted (5)
transport/session/Cargo.toml (3)
28-28
: LGTM: New "prometheus" feature addedThe addition of the "prometheus" feature is a good way to introduce optional Prometheus metrics support. It correctly depends on "hopr-metrics" and "lazy_static".
34-34
: LGTM: Optional "lazy_static" dependency addedThe "lazy_static" dependency is correctly added as optional and uses the workspace version, which is good for maintaining consistency across the project.
49-49
: LGTM: Optional "hopr-metrics" dependency addedThe "hopr-metrics" dependency is correctly added as optional and uses the workspace version, ensuring consistency with other parts of the project.
transport/session/src/types.rs (2)
299-301
: LGTM! Metric observation correctly implemented.The addition of the metric observation in the
poll_write
method is well-placed and correctly implemented. It will provide valuable insights into the sizes of data chunks being written in each session.
Line range hint
24-301
: Overall, the changes look good and improve observability.The addition of Prometheus metrics for session inner sizes is a valuable improvement to the codebase. The implementation is correct, follows best practices, and is properly integrated into the existing code. These changes will provide useful insights into the performance and behavior of the session data transfers.
Adjusted the session initialization retry strategy by reducing the backoff delay to 1000 milliseconds and the number of retries to 3. Additionally, fixed the logic for handling UDP parallelism by ensuring the parallelism value cannot be lower than the available parallelism.
…test' into kauki/test/add-wireguard-tunnel-test
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.
Actionable comments posted: 2
Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Files selected for processing (3)
- common/network-types/src/udp.rs (1 hunks)
- hoprd/hoprd/src/lib.rs (1 hunks)
- hoprd/rest-api/src/session.rs (3 hunks)
Additional comments not posted (4)
hoprd/hoprd/src/lib.rs (1)
139-151
: Improved code structure and platform-specific configuration.The changes to the
ConnectedUdpStream
construction improve the code structure by separating the builder configuration from the instantiation. This enhances readability and maintainability. The conditional compilation for Linux-specific configuration is a good practice for handling platform differences.However, there are a couple of points to consider:
The TODO comment about MacOS behavior suggests that there might be platform-specific issues that need to be addressed. It would be beneficial to elaborate on this comment or create a separate issue to track and resolve the MacOS-specific behavior.
Consider adding a comment explaining why
parallelism
is set to 0 for Linux. This would help other developers understand the reasoning behind this platform-specific configuration.To ensure that this change doesn't introduce any regressions, please run the following command to check for any existing tests related to UDP stream creation:
If there are no existing tests, consider adding a new test case to verify the behavior of
ConnectedUdpStream
creation on different platforms.hoprd/rest-api/src/session.rs (2)
52-52
: LGTM: Consistent naming convention applied.The renaming of
listen_host
tolistenHost
aligns with the camelCase formatting specified by the#[serde(rename_all = "camelCase")]
attribute on the struct. This change enhances consistency in the JSON structure.
182-182
: Verify the impact of the modified retry strategy.The retry strategy has been adjusted:
- Backoff duration reduced from 2000ms to 1000ms
- Number of retries decreased from 5 to 3
While this change reduces the total retry time, it might affect the reliability of session initialization in unstable network conditions.
Please confirm that this modification doesn't negatively impact the session establishment success rate. Consider running the following test:
Verification successful
Retry strategy modification appears safe.
No evidence of increased session initialization failures was found based on the recent code analysis. The reduced backoff duration and fewer retries do not seem to negatively impact the reliability under current conditions.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for any recent changes or issues related to session initialization failures # Test: Look for any recent changes or issues related to session initialization rg --type rust -i "session.*initiali[sz]ation|connect.*fail" --glob '!target/'Length of output: 94056
common/network-types/src/udp.rs (1)
170-177
: Improved parallelism calculation logicThe changes in this segment enhance the robustness and clarity of the parallelism calculation:
- The
avail_parallelism
calculation now ensures a minimum value of 1, preventing potential issues with zero parallelism.- The
num_socks
calculation has been simplified and made more explicit, improving readability.These modifications make the code more resilient and easier to understand.
…test' into kauki/test/add-wireguard-tunnel-test
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.
Actionable comments posted: 6
Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Files selected for processing (3)
- common/network-types/src/udp.rs (3 hunks)
- tests/hopr.py (1 hunks)
- tests/test_integration.py (2 hunks)
Additional context used
Ruff
tests/hopr.py
388-388: Line too long (143 > 120)
(E501)
396-396: Line too long (136 > 120)
(E501)
tests/test_integration.py
880-880: Module level import not at top of file
(E402)
885-885: f-string without any placeholders
Remove extraneous
f
prefix(F541)
925-925: Line too long (125 > 120)
(E501)
Additional comments not posted (1)
common/network-types/src/udp.rs (1)
175-182
: Ensurenum_socks
calculation behaves correctly on all platformsThe calculation of
num_socks
relies onself.parallelism
andavail_parallelism
. On non-Linux systems,self.parallelism
will beNone
, resulting innum_socks
being set to1
. Verify that this behavior is intended and that the code does not attempt to create multiple sockets on unsupported platforms.
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.
Actionable comments posted: 3
Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Files selected for processing (2)
- hoprd/rest-api/src/session.rs (3 hunks)
- transport/session/src/types.rs (3 hunks)
Additional context used
Learnings (1)
transport/session/src/types.rs (1)
Learnt from: NumberFour8 PR: hoprnet/hoprnet#6506 File: transport/session/src/types.rs:24-33 Timestamp: 2024-09-24T13:15:42.300Z Learning: When adding metrics, if the description is already contained in the metric definition, no additional comments are necessary.
Additional comments not posted (4)
hoprd/rest-api/src/session.rs (2)
52-52
: LGTM: Consistent camelCase naming in SessionClientRequest structThe renaming of
listen_host
tolistenHost
in the example JSON aligns with the#[serde(rename_all = "camelCase")]
attribute on the struct. This change improves consistency in the JSON representation of the SessionClientRequest.
Line range hint
1-605
: Overall improvements, but no direct relation to PR objectiveThe changes in this file represent general improvements to the session handling code, including:
- Consistent naming in struct fields
- Adjusted retry strategy for session initialization
- Improved UDP socket configuration
While these changes are positive, they don't seem directly related to the stated PR objective of "Add a separate test for wireguard tunnel".
To ensure we're not missing any WireGuard-related changes, let's check for any mentions of WireGuard in the file:
If this search doesn't yield any results, it might be worth clarifying with the PR author how these changes relate to the stated objective, or if the PR description needs updating to reflect these additional improvements.
Verification successful
Overall improvements, but no direct relation to PR objective
The changes in
hoprd/rest-api/src/session.rs
represent general improvements to the session handling code, including:
- Consistent Naming: Streamlined struct field names for better readability.
- Retry Strategy: Adjusted the retry mechanism for session initialization to enhance reliability.
- UDP Socket Configuration: Improved the configuration settings for UDP sockets to optimize performance.
These modifications are positive and contribute to the overall quality of the codebase. However, they do not appear to be directly related to the PR's stated objective of adding a separate test for the WireGuard tunnel.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for any mentions of WireGuard in the file rg -i "wireguard" hoprd/rest-api/src/session.rsLength of output: 47
Script:
#!/bin/bash # Search for any mentions of WireGuard in the entire codebase rg -i "wireguard"Length of output: 2928
transport/session/src/types.rs (2)
24-33
: LGTM! The metric definition is well-structured.The new
METRIC_SESSION_INNER_SIZES
metric is appropriately defined with conditional compilation and uses aMultiHistogram
with well-chosen bucket sizes. This will provide valuable insights into the sizes of data chunks processed by the inner session of the HOPR protocol.
486-494
: LGTM! Excellent performance optimization.The introduction of
BufWriter
for buffering writes into the session is a great performance optimization. This change can significantly reduce the number of write operations, especially when dealing with small writes, by batching them together.Key improvements:
- The buffer capacity is correctly set to
into_session_len
, ensuring optimal buffering.- The use of
FuturesAsyncReadCompatExt::compat
adapter ensures compatibility with tokio's AsyncRead/AsyncWrite traits.- The
copy_duplex
function now works with the buffered session writer, potentially improving overall data transfer efficiency.These changes should lead to more efficient data transfer between the session and the stream.
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.
Actionable comments posted: 1
Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Files selected for processing (1)
- transport/session/src/types.rs (3 hunks)
Additional context used
Learnings (1)
transport/session/src/types.rs (1)
Learnt from: NumberFour8 PR: hoprnet/hoprnet#6506 File: transport/session/src/types.rs:24-33 Timestamp: 2024-09-24T13:15:42.300Z Learning: When adding metrics, if the description is already contained in the metric definition, no additional comments are necessary.
Additional comments not posted (2)
transport/session/src/types.rs (2)
24-33
: No issues found in metric declarationThe metric
METRIC_SESSION_INNER_SIZES
is correctly defined and initialized with appropriate labels and buckets.
299-301
: Optimize string allocation in metric observationAs previously suggested, consider caching the string representation of
self.id
to avoid allocating a newString
on each call toto_string()
. This can enhance performance ifpoll_write
is called frequently.
Modified `tests/hopr.py` to handle capabilities conditionally when creating a session client request. Updated `transport/protocol/src/lib.rs` to replace `debug` log levels with `trace` for packet delay information.
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.
Actionable comments posted: 1
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
⛔ Files ignored due to path filters (1)
Cargo.lock
is excluded by!**/*.lock
📒 Files selected for processing (3)
- Cargo.toml (1 hunks)
- tests/hopr.py (1 hunks)
- transport/protocol/src/lib.rs (2 hunks)
🧰 Additional context used
🪛 Ruff
tests/hopr.py
388-388: Line too long (143 > 120)
(E501)
401-401: Line too long (140 > 120)
(E501)
🔇 Additional comments (2)
Cargo.toml (1)
49-49
: LGTM! Consider documenting the usage ofarrayvec
.The addition of the
arrayvec
dependency with the "serde" feature is appropriate for projects requiring fixed-size arrays with serialization capabilities. This is consistent with the project's existing use of serialization-related crates.To improve maintainability, consider adding a comment in the
Cargo.toml
file or updating the project documentation to explain the intended use ofarrayvec
in the codebase.transport/protocol/src/lib.rs (1)
289-292
: Approved: Improved logging granularityThe change from
debug!
totrace!
for logging the mixer's random packet delay is a good improvement. This modification reduces log verbosity in production environments while still preserving the ability to access this information when needed.Key points:
- The log message content remains unchanged, maintaining the important information about the delay.
- Using
trace!
instead ofdebug!
allows for finer-grained control over log output.- This change doesn't affect the functionality of the code, only its observability.
To be run with a setup and existing tunnel at a specified URL as:
HOPR_TEST_RUNNING_WIREGUARD_TUNNEL=wireguard.tunnel.link:51820 .venv/bin/python3 -m pytest tests/test_integration.py -k test_session_with_wireguard_tunnel