Skip to content

tests: make usagetests robust#9956

Merged
christyjacob4 merged 3 commits intospr/1.7.x/7d7dffacfrom
spr/1.7.x/35fcc17d
Jun 2, 2025
Merged

tests: make usagetests robust#9956
christyjacob4 merged 3 commits intospr/1.7.x/7d7dffacfrom
spr/1.7.x/35fcc17d

Conversation

@loks0n
Copy link
Copy Markdown
Member

@loks0n loks0n commented Jun 2, 2025

Stack:

⚠️ Part of a stack created by spr. Do not merge manually using the UI - doing so may have unexpected results.

Summary by CodeRabbit

  • Tests
    • Improved reliability of several usage and messaging log tests by standardizing the retry mechanism, reducing flakiness due to eventual consistency.
    • Removed manual delays and previous retry attributes, resulting in cleaner and more consistent test behavior.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jun 2, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The test files have been updated to replace manual retry attributes and explicit sleep calls with a unified assertEventually closure-based retry mechanism. This change standardizes retry logic for eventual consistency in multiple test methods across usage and messaging tests, removing redundant imports and retry annotations.

Changes

File(s) Change Summary
tests/e2e/General/UsageTest.php Replaced #[Retry(count: 10)] attributes and sleep calls with assertEventually closure-based retries in multiple test methods; removed related import and retry attributes.
tests/e2e/Services/Messaging/MessagingConsoleClientTest.php Wrapped topic logs retrieval and assertions inside assertEventually closure to handle eventual consistency; no changes to declarations.

Sequence Diagram(s)

sequenceDiagram
    participant TestMethod
    participant assertEventually
    participant API
    TestMethod->>assertEventually: Provide closure with API call & assertions
    loop Retry until success or timeout
        assertEventually->>API: Make API request
        API-->>assertEventually: Return response
        assertEventually->>assertEventually: Run assertions
    end
    assertEventually-->>TestMethod: Return when assertions pass or timeout
Loading

Poem

In the warren of tests, retries once sprawled,
With sleeps and attributes, the logic was called.
Now closure-based retries hop in with grace,
assertEventually brings order to the race.
Consistency found, the code is more neat—
A rabbit’s applause for this tidy feat! 🐇✨


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 75f00a4 and d14eb3f.

📒 Files selected for processing (2)
  • tests/e2e/General/UsageTest.php (6 hunks)
  • tests/e2e/Services/Messaging/MessagingConsoleClientTest.php (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 2, 2025

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
binutils 2.42-r0 CVE-2025-0840 HIGH
libexpat 2.6.4-r0 CVE-2024-8176 HIGH
libxml2 2.12.7-r0 CVE-2024-56171 HIGH
libxml2 2.12.7-r0 CVE-2025-24928 HIGH
libxml2 2.12.7-r0 CVE-2025-27113 HIGH
libxml2 2.12.7-r0 CVE-2025-32414 HIGH
libxml2 2.12.7-r0 CVE-2025-32415 HIGH
sqlite-libs 3.45.3-r1 CVE-2025-29087 HIGH
xz 5.6.2-r0 CVE-2025-31115 HIGH
xz-libs 5.6.2-r0 CVE-2025-31115 HIGH
golang.org/x/crypto v0.31.0 CVE-2025-22869 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a 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 comments (1)
tests/e2e/General/UsageTest.php (1)

1-1: ⚠️ Potential issue

Fix PSR-12 style violations detected by pipeline.

The GitHub Actions linter has detected PSR-12 style violations including method argument spacing and array indentation issues. Please run the following command to automatically fix these formatting issues:

vendor/bin/pint
🧰 Tools
🪛 GitHub Actions: Linter

[error] 1-1: PSR 12 style check failed: method_argument_space, array_indentation, and other style issues detected. Run 'vendor/bin/pint' to fix.

🧹 Nitpick comments (1)
tests/e2e/General/UsageTest.php (1)

587-587: Remove unnecessary empty line.

This appears to be an extraneous empty line that should be removed for cleaner code formatting.

-
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 49e2c33 and 7be7491.

📒 Files selected for processing (1)
  • tests/e2e/General/UsageTest.php (6 hunks)
🧰 Additional context used
🪛 GitHub Actions: Linter
tests/e2e/General/UsageTest.php

[error] 1-1: PSR 12 style check failed: method_argument_space, array_indentation, and other style issues detected. Run 'vendor/bin/pint' to fix.

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: scan
🔇 Additional comments (14)
tests/e2e/General/UsageTest.php (14)

189-208: LGTM! Clean refactoring to use assertEventually pattern.

The refactoring correctly wraps the API call and assertions in the new retry mechanism, maintaining the same test logic while standardizing the retry approach.


210-221: Good refactoring of the second usage stats check.

The migration to assertEventually is properly implemented, preserving all original assertions and test logic.


372-389: Excellent variable scoping in closure.

The refactoring correctly captures the required variables ($requestsTotal, $storageTotal) in the closure using the use clause, maintaining proper test logic.


391-404: Proper implementation of storage usage assertions.

The refactoring maintains all storage-related assertions while correctly implementing the new retry pattern with proper variable scoping.


406-415: Clean bucket-specific usage validation.

The refactoring properly handles bucket-specific usage checks with correct variable capture and assertion preservation.


597-616: Well-implemented database stats validation.

The refactoring correctly wraps the project usage checks with proper variable capture and maintains all database-related assertions.


618-631: Comprehensive database usage assertions maintained.

The migration to assertEventually properly handles all database usage metrics validation with correct variable scoping.


633-645: Database-specific usage validation correctly implemented.

The refactoring maintains proper database-specific usage checks with correct variable capture and assertion logic.


647-656: Collection-specific usage validation properly refactored.

The migration correctly handles collection-specific usage metrics with proper variable capture and maintains all document-related assertions.


821-846: Comprehensive function usage metrics validation.

The refactoring correctly implements the new retry pattern for function-specific usage checks, maintaining all deployment, build, and execution assertions.


848-873: Global functions usage validation well-implemented.

The migration maintains all global functions usage assertions while properly implementing the standardized retry mechanism.


953-985: Comprehensive site usage metrics validation.

The refactoring correctly handles site-specific usage validation with proper variable capture for multiple metrics and maintains all deployment and execution assertions.


987-1017: Global sites usage validation properly migrated.

The refactoring maintains all global sites usage assertions while correctly implementing the new retry pattern with proper variable scoping.


1054-1080: Proper handling of custom domains function stats with reference variables.

The refactoring correctly implements the retry pattern for both function-specific and project usage calls. The use of reference variables (&$response) properly captures responses for later comparison, maintaining the test's logic for validating metric changes.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jun 2, 2025

✨ Benchmark results

  • Requests per second: 868
  • Requests with 200 status code: 156,350
  • P99 latency: 0.217500564

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 868 1,078
200 156,350 194,133
P99 0.217500564 0.174959546

loks0n added 2 commits June 2, 2025 19:05
@loks0n loks0n force-pushed the spr/1.7.x/35fcc17d branch from 75f00a4 to c19d123 Compare June 2, 2025 18:05
@christyjacob4 christyjacob4 merged commit 9fb12fd into spr/1.7.x/7d7dffac Jun 2, 2025
8 of 9 checks passed
@christyjacob4 christyjacob4 deleted the spr/1.7.x/35fcc17d branch June 2, 2025 18:41
@coderabbitai coderabbitai bot mentioned this pull request Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants