Replace sleep in webhook tests with assertEventually#10656
Conversation
📝 WalkthroughWalkthroughReplaces fixed sleep-based waits in webhook end-to-end tests with polling using assertEventually (15s timeout, 500ms interval). Each polling block retrieves and asserts the last webhook request, recomputes and verifies the webhook signature, and validates common headers plus expanded X-Appwrite-Webhook-Events patterns for granular database/table/bucket/team CRUD paths. WebhooksCustomServerTest now imports and uses the Async trait. Several webhook auto-disable and failure-verification flows were updated to perform GETs inside assertEventually instead of after fixed sleeps. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Changes are widespread across tests with repeated, similar refactors (sleep → assertEventually) but include added event-pattern assertions and a trait addition, requiring moderate review to verify correctness and coverage. Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧬 Code graph analysis (1)tests/e2e/Services/Webhooks/WebhooksBase.php (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
🔇 Additional comments (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Security Scan Results for PRDocker Image Scan Results
Source Code Scan Results🎉 No vulnerabilities found! |
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
tests/e2e/Services/Webhooks/WebhooksBase.php(3 hunks)tests/e2e/Services/Webhooks/WebhooksCustomServerTest.php(6 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
tests/e2e/Services/Webhooks/WebhooksBase.php (2)
tests/e2e/Scopes/Scope.php (1)
getLastRequest(130-140)tests/e2e/Client.php (1)
Client(8-342)
tests/e2e/Services/Webhooks/WebhooksCustomServerTest.php (2)
tests/e2e/Scopes/Scope.php (1)
getLastRequest(130-140)tests/e2e/Services/Webhooks/WebhooksBase.php (1)
getWebhookSignature(32-37)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: E2E General Test
- GitHub Check: Unit Test
- GitHub Check: scan
🔇 Additional comments (6)
tests/e2e/Services/Webhooks/WebhooksBase.php (1)
1494-1505: LGTM!The
assertEventuallyusage here is correct. It polls the webhook configuration endpoint to verify that the webhook gets auto-disabled after 10 consecutive failures. Unlike the attribute/column creation tests, there's no race condition here since it's checking the webhook configuration state, not webhook events.tests/e2e/Services/Webhooks/WebhooksCustomServerTest.php (5)
5-5: LGTM!Adding the
Asynctrait enables theassertEventually()method for asynchronous polling throughout the test class. This is the correct approach for replacing fixed sleep delays with retry-based waits.Also applies to: 19-19
94-111: LGTM!The webhook validation is correctly wrapped in
assertEventually()with all assertions (including signature validation) performed inside the retry block. This avoids race conditions and ensures the test waits for the index creation webhook before proceeding.
280-297: LGTM!Consistent with the collection index test above. All webhook assertions are inside the
assertEventuallyblock, preventing race conditions.
740-760: LGTM!The deployment update webhook validation correctly uses
assertEventually()with a 10-second timeout, which is appropriate for deployment build operations. All assertions are inside the retry block.
811-831: LGTM!The execution completion webhook validation uses an appropriate 30-second timeout (longer than other operations) since function executions can legitimately take time. The 1-second polling interval is also reasonable for this longer wait.
✨ Benchmark results
⚡ Benchmark Comparison
|
What does this PR do?
Replace sleep in webhook tests with assertEventually
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Screenshots may also be helpful.)
Related PRs and Issues
Checklist