-
Notifications
You must be signed in to change notification settings - Fork 98
Add E2E tests for lowered winning probabilities #6511
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📝 WalkthroughWalkthroughThis pull request modifies 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
|
Updated TicketSelector to support multiple channels and added new fields like win_prob_lt. Implemented ticket rejection logic for tickets below a new minimum winning probability.
…g probability Refactor ticket marking to use a unified `mark_tickets_as` method with the new `TicketMarker` enum. This enhancement simplifies ticket operations, replaces individual marking methods, and ensures consistent statistical updates. Updated tests and documentation to support this change.
…ukas/winning-prob-tests
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: 4
🧹 Outside diff range comments (1)
.github/workflows/tests.yaml (1)
Line range hint
158-214
: Expanded test coverage and improved consistency. Consider version pinning.The changes to the
tests-smoke
job are excellent improvements:
- The addition of new test suites ('redeeming', 'rest_api', and 'win_prob') enhances the coverage of the smoke tests.
- The Cloud SDK setup and snapshot handling changes are consistent with those in the
tests-smoke-websocket
job, which improves the overall structure and reliability of the workflow.These modifications contribute to a more comprehensive and coherent testing process.
As suggested for the
tests-smoke-websocket
job, consider pinning the exact version of the Cloud SDK in the setup step:- name: Set up Cloud SDK uses: google-github-actions/setup-gcloud@v2 with: version: '363.0.0'This change would ensure consistency across jobs and improve reproducibility.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
📒 Files selected for processing (3)
- .github/workflows/tests.yaml (5 hunks)
- scripts/run-local-anvil.sh (1 hunks)
- tests/conftest.py (7 hunks)
🔇 Additional comments (4)
.github/workflows/tests.yaml (1)
103-111
: Improved snapshot handling and verification.The changes to the snapshot download and verification process are well-implemented:
- The use of the
--recursive
flag in thegcloud storage rsync
command ensures all files and subdirectories are synced.- The standardized destination path (
smoke_test_snapshot
) improves consistency.- The addition of the "Check snapshot" step helps verify the download's success.
These improvements enhance the reliability and consistency of the snapshot handling process.
tests/conftest.py (3)
7-7
: LGTM: Import statements updatedThe addition of the
re
module import and the inclusion ofCalledProcessError
in the subprocess import are appropriate for the newrun_hopli_cmd
function introduced later in the file.Also applies to: 11-11
127-127
: LGTM: Node 6 configuration updated for lower winning probabilityThe change of Node 6's configuration file to "barebone-lower-win-prob.cfg.yaml" aligns with the PR objective of testing lowered winning probabilities. This modification ensures that Node 6 is set up correctly for the new test scenarios.
218-220
: LGTM: Improved logging in snapshot_reuse functionThe addition of logging for copying the anvil state file enhances the visibility of the snapshot reuse process. This will help with debugging and understanding the test setup process.
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 (2)
- .github/workflows/tests.yaml (5 hunks)
- tests/conftest.py (6 hunks)
🔇 Additional comments (7)
.github/workflows/tests.yaml (5)
84-88
: Consider pinning the Cloud SDK to an exact version.While adding the Cloud SDK setup step is a good improvement, it's recommended to pin to an exact version instead of using a minimum version constraint. This ensures consistent behavior across different environments and CI runs.
As suggested in a previous review:
- name: Set up Cloud SDK uses: google-github-actions/setup-gcloud@v2 with: version: '363.0.0'This change would improve reproducibility and prevent potential issues from unexpected updates.
103-108
: Improved snapshot download process.The changes to the snapshot download step are beneficial:
- Standardizing the snapshot storage path to
smoke_test_snapshot/snapshot
improves consistency and makes it easier to manage snapshots across different test suites.- Adding the
--recursive
flag to thegcloud storage rsync
command ensures that all nested directories and files are properly synchronized, which is crucial for comprehensive snapshot management.These improvements align with best practices for cloud storage operations and should enhance the reliability of the snapshot download process.
117-123
: Improved snapshot upload configuration.The changes to the snapshot upload step are well-considered:
Changing the destination path to
hoprnet-test-artifacts/smoke_test_snapshot
aligns with the standardization implemented in the download step. This consistency improves the overall organization and manageability of test artifacts.Setting
gzip: false
is appropriate for snapshot files. This ensures that the files are uploaded without additional compression, which is beneficial for snapshots that may already be compressed or contain binary data.These modifications enhance the reliability and efficiency of the snapshot upload process.
159-162
: Expanded test coverage with new test suites.The addition of new test suites ('redeeming', 'rest_api', and 'win_prob') to the matrix strategy is a significant improvement:
- It expands the coverage of the smoke tests, enhancing the overall quality assurance process.
- The 'win_prob' suite aligns perfectly with the PR objective of adding E2E tests for lowered winning probabilities.
- The 'rest_api' suite suggests improved testing of API endpoints, which is crucial for ensuring the reliability of the application's interface.
- The 'redeeming' suite likely focuses on ticket redemption processes, which is important given the changes in winning probabilities.
These additions demonstrate a comprehensive approach to testing, covering various aspects of the system's functionality.
177-180
: Consistent improvements across jobs, with a suggestion for Cloud SDK setup.The changes to the
tests-smoke
job mirror those in thetests-smoke-websocket
job, which is excellent for maintaining consistency across the workflow:
- The addition of the Cloud SDK setup step ensures that necessary tools are available for both jobs.
- The modifications to snapshot download and upload steps standardize the process across different test suites.
These changes improve the overall structure and reliability of the workflow. However, as mentioned earlier, consider pinning the Cloud SDK to an exact version for better reproducibility:
- name: Set up Cloud SDK uses: google-github-actions/setup-gcloud@v2 with: version: '363.0.0'This change would ensure consistent behavior across different environments and CI runs for both jobs.
Also applies to: 196-201, 210-216
tests/conftest.py (2)
127-127
: LGTM: Removed NETWORK2 references and updated Node 6 configurationThe changes align well with the PR objectives:
- Node 6's configuration file has been updated to "barebone-lower-win-prob.cfg.yaml", which supports testing lowered winning probabilities.
- The removal of commented-out code related to NETWORK2 improves code cleanliness.
These modifications effectively streamline the testing framework for the new scenarios with lowered winning probabilities.
Also applies to: 511-512
279-291
: LGTM: Updated snapshot validation processThe changes to the
snapshot_usable
function improve the snapshot validation process by:
- Including checks for new configuration files (e.g., "barebone-lower-win-prob.cfg.yaml").
- Ensuring that all necessary node-specific files are present in the snapshot.
These updates enhance the reliability of the snapshot system, which is crucial for efficient and consistent testing.
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: 4
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
📒 Files selected for processing (1)
- tests/conftest.py (7 hunks)
🧰 Additional context used
📓 Learnings (1)
tests/conftest.py (1)
Learnt from: NumberFour8 PR: hoprnet/hoprnet#6511 File: tests/conftest.py:147-149 Timestamp: 2024-10-01T16:57:58.727Z Learning: When a user indicates that a comment is invalid and requests not to notify, acknowledge their request and avoid similar notifications in future.
🔇 Additional comments (2)
tests/conftest.py (2)
7-7
: LGTM: New imports addedThe addition of
re
andCalledProcessError
imports suggests new functionality related to regular expressions and subprocess error handling. These changes align with the newrun_hopli_cmd
function introduced later in the file.Also applies to: 11-11
127-127
: LGTM: Updated Node 6 configuration for lower winning probabilityThe change of Node 6's configuration file to "barebone-lower-win-prob.cfg.yaml" aligns with the PR objective of testing lowered winning probabilities. This modification ensures that Node 6 is set up correctly for the new test scenarios.
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 (1)
- tests/conftest.py (9 hunks)
🧰 Additional context used
📓 Learnings (1)
tests/conftest.py (1)
Learnt from: NumberFour8 PR: hoprnet/hoprnet#6511 File: tests/conftest.py:147-149 Timestamp: 2024-10-01T16:57:58.727Z Learning: When a user indicates that a comment is invalid and requests not to notify, acknowledge their request and avoid similar notifications in future.
🔇 Additional comments (5)
tests/conftest.py (5)
7-7
: Importingre
module is appropriateThe addition of
import re
is necessary for the regular expression operations used later in the code.
127-127
: Updated configuration for Node 6 aligns with PR objectivesChanging Node 6's configuration to
"barebone-lower-win-prob.cfg.yaml"
is consistent with the goal of testing lowered winning probabilities.
147-149
: Function renaming accurately reflects its purposeRenaming the function to
nodes_with_lower_outgoing_win_prob
makes its purpose clearer, indicating that it returns nodes with a lower outgoing ticket winning probability.
283-298
: Snapshot verification enhancements are validIncluding
protocol-config.json
and node-specific files inexpected_files
improves the robustness of snapshot verification. The iterative check ensures all necessary files are present.
352-354
: Addition ofis_node_ready
function improves readiness checksIntroducing the
is_node_ready
function provides a more granular approach to determine when a node is fully ready, enhancing the reliability of the startup process.Also applies to: 359-359
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: 4
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
📒 Files selected for processing (1)
- tests/test_redeeming.py (1 hunks)
🔇 Additional comments (6)
tests/test_redeeming.py (6)
15-21
: Well-structured test for unredeemed tickets without message transmissionThe test
test_hoprd_should_not_have_unredeemed_tickets_without_sending_messages
correctly verifies that a node has no unredeemed tickets before any messages are sent. The use of parameterization ensures coverage across different nodes.
136-136
:⚠️ Potential issueEnsure integer division when calculating
message_count
Similar to line 58, ensure that integer division is used to prevent accidental float-to-integer conversion which can lead to incorrect
message_count
.Apply this diff:
-message_count = int(TICKET_AGGREGATION_THRESHOLD / 10) +message_count = TICKET_AGGREGATION_THRESHOLD // 10Likely invalid or redundant comment.
160-160
: 🛠️ Refactor suggestionAvoid using fixed sleep durations in tests
Using
await asyncio.sleep(10)
can lead to longer test times and flakiness. It's better to wait for a specific condition, such as checking if aggregation has completed.Replace the fixed sleep with a polling mechanism:
-await asyncio.sleep(10) # wait for aggregation to finish before redeeming +timeout = 30 +start_time = asyncio.get_event_loop().time() +while True: + # Implement a condition check appropriate for your aggregation completion + if await is_aggregation_complete(swarm7[route[1]]): + break + elif asyncio.get_event_loop().time() - start_time > timeout: + raise TimeoutError("Aggregation did not complete in time") + await asyncio.sleep(1)Ensure that you implement
is_aggregation_complete
to accurately check the aggregation status.Likely invalid or redundant comment.
182-184
:⚠️ Potential issueAdd validation to prevent
IndexError
due to insufficient route lengthAccessing
route[1]
androute[-1]
assumes thatroute
has at least two elements. Ifroute
is shorter, this will raise anIndexError
.Apply this diff to add a safeguard:
+assert len(route) >= 2, "Route must contain at least two nodes" await send_and_receive_packets_with_pop( packets, src=swarm7[route[0]], dest=swarm7[route[-1]], path=[swarm7[route[1]].peer_id] )
Likely invalid or redundant comment.
93-96
: 🧹 Nitpick (assertive)Correct the indentation of the multi-line assertion
The assertion spanning lines 93-96 is over-indented, which may affect readability and could potentially lead to misunderstandings of the code structure.
Apply this diff to adjust the indentation:
assert ( - balance_str_to_int(statistics_after_redemption.redeemed_value) - - balance_str_to_int(statistics_after.redeemed_value) - ) == (len(packets) * TICKET_PRICE_PER_HOP) + balance_str_to_int(statistics_after_redemption.redeemed_value) + - balance_str_to_int(statistics_after.redeemed_value) +) == (len(packets) * TICKET_PRICE_PER_HOP)Likely invalid or redundant comment.
23-51
: 🛠️ Refactor suggestionConsider limiting retries in
channel_redeem_tickets
to prevent potential infinite loopsThe
channel_redeem_tickets
function contains awhile True
loop without a termination condition other than success. While this ensures eventual completion if the channel redeems successfully, it could lead to an infinite loop if the redemption continuously fails.Apply this diff to limit the number of retries:
async def channel_redeem_tickets(api: HoprdAPI, channel: str): + max_retries = 40 + retries = 0 while True: if await api.channel_redeem_tickets(channel): break else: await asyncio.sleep(0.5) + retries += 1 + if retries >= max_retries: + raise Exception("Max retries reached while redeeming tickets")Likely invalid or redundant comment.
Follow-up to #6501
This PR repurposes Node 6 in E2E tests to send tickets with winning probability lowered to 10%. Node 7 has been discarded completely from tests.
Then several integration tests are added to test multiple different scenarios with relaying tickets with lowered winning probability.