-
Notifications
You must be signed in to change notification settings - Fork 0
fix: sandbox retries #59
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
WalkthroughThe changes in this pull request focus on the Changes
Possibly related PRs
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
CodeRabbit Configuration File (
|
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: 0
🧹 Outside diff range and nitpick comments (1)
chat-android/src/test/java/com/ably/chat/Sandbox.kt (1)
20-28
: Consider adding maximum delay and logging for retriesThe retry configuration effectively handles timeouts and error responses with exponential backoff, which is great. Consider these enhancements:
- Add a maximum delay to prevent excessive wait times
- Add logging to track retry attempts in tests
install(HttpRequestRetry) { maxRetries = 5 retryIf { _, response -> !response.status.isSuccess() } retryOnExceptionIf { _, cause -> cause is HttpRequestTimeoutException } - exponentialDelay() + exponentialDelay( + maxDelay = 5000L // 5 seconds maximum delay + ) + delay { retry -> + println("Retrying request. Attempt: $retry") + retry * 1000L // Original delay calculation + } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
chat-android/src/test/java/com/ably/chat/Sandbox.kt
(1 hunks)
🔇 Additional comments (3)
chat-android/src/test/java/com/ably/chat/Sandbox.kt (3)
9-9
: LGTM: Required imports added for new retry functionality
The new imports support the timeout exception handling and HTTP status checking capabilities.
Also applies to: 17-17
19-19
: LGTM: Improved encapsulation with private visibility
The client variable is now properly encapsulated as a private implementation detail.
21-27
: Verify impact on test execution time
The increased retry count and exponential backoff could potentially slow down test execution if timeouts are frequent.
✅ Verification successful
Let me gather more information about the retry implementation and test execution patterns.
Retry configuration is appropriate for test stability
The retry configuration in Sandbox.kt is well-designed and won't significantly impact test execution time:
- The retries are only for HTTP requests to set up test environments
- Tests themselves run with
runTest
coroutine builder which virtualizes time - Retry conditions are specific (HTTP failures and timeouts only)
- The sandbox is created once in
@Before
setup, not per test - Test assertions are focused on functionality verification, not timing-dependent
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for test files that use the Sandbox class to assess potential impact
rg -l "class.*Test.*\{" | xargs rg "Sandbox" -l
# Look for existing timeout-related test configurations
rg "timeout|delay|sleep" --type kotlin
Length of output: 1875
Script:
#!/bin/bash
# Check the Sandbox class implementation for retry configuration details
cat chat-android/src/test/java/com/ably/chat/Sandbox.kt
# Look for test execution patterns in SandboxTest
cat chat-android/src/test/java/com/ably/chat/SandboxTest.kt
# Search for any existing retry-related configurations or patterns
rg "retry|backoff" --type kotlin
Length of output: 5528
Add retries for timeout exceptions for sandbox
Summary by CodeRabbit
New Features
Bug Fixes