Skip to content

V4 dequeue test fixes #1991

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

Merged
merged 5 commits into from
Apr 29, 2025
Merged

V4 dequeue test fixes #1991

merged 5 commits into from
Apr 29, 2025

Conversation

matt-aitken
Copy link
Member

@matt-aitken matt-aitken commented Apr 28, 2025

When dequeuing in v4 now, we only return a max of 1 run per environment. The tests didn't assume this so some were failing

Summary by CodeRabbit

  • Tests
    • Adjusted test logic to perform multiple single-item dequeues in loops instead of bulk dequeues.
    • Updated type annotations for improved clarity in test assertions.
    • Marked certain tests as expected to fail, with comments explaining current system limitations.
    • No changes to exported or public interfaces.

Copy link

changeset-bot bot commented Apr 28, 2025

⚠️ No Changeset found

Latest commit: 3fc381c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Apr 28, 2025

Walkthrough

This update modifies several test files to change how messages or runs are dequeued from queues. Instead of dequeuing multiple items in a single call, the tests now perform multiple sequential dequeue operations, each retrieving a single item. In some cases, the tests are marked as expected to fail due to current system limitations. The changes also include updates to type annotations and the explicit use of queue names. No changes were made to exported or public entities.

Changes

File(s) Change Summary
.../run-engine/src/engine/tests/batchTrigger.test.ts
.../engine/tests/pendingVersion.test.ts
.../engine/tests/priority.test.ts
Modified tests to replace bulk dequeue calls with loops that dequeue one message at a time, accumulating results. Added explicit type annotations (DequeuedMessage[]) and used the hardcoded queue name "main" where applicable. Assertions and test logic remain functionally unchanged.
.../run-engine/src/engine/tests/dequeuing.test.ts Updated the "Dequeues 5 runs" test to use a loop for single-item dequeues instead of a bulk dequeue. Marked "Dequeues runs within machine constraints" as expected to fail due to current limitations. Added type annotations for dequeued arrays.
.../run-engine/src/run-queue/index.test.ts Changed the test for dequeuing multiple messages to be expected to fail, with a comment explaining the current system limitation. Test logic remains the same, still verifying queue lengths and message counts after dequeues.

Possibly related PRs

  • triggerdotdev/trigger.dev#1989: Refactors internal dequeue logic to remove looping and repeated queue checks for performance; related as both PRs involve changes to dequeue operations, though at different layers (test usage vs. core logic).

Suggested reviewers

  • ericallam

Poem

In queues where messages hop and wait,
Tests now dequeue them one by one, not eight!
Rabbits in loops, with careful delight,
Count every message, morning to night.
Though some tests may fail,
Progress will prevail—
And soon, all the queues will feel just right! 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f579afb and 3fc381c.

📒 Files selected for processing (5)
  • internal-packages/run-engine/src/engine/tests/batchTrigger.test.ts (2 hunks)
  • internal-packages/run-engine/src/engine/tests/dequeuing.test.ts (2 hunks)
  • internal-packages/run-engine/src/engine/tests/pendingVersion.test.ts (2 hunks)
  • internal-packages/run-engine/src/engine/tests/priority.test.ts (3 hunks)
  • internal-packages/run-engine/src/run-queue/index.test.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
internal-packages/run-engine/src/run-queue/index.test.ts (1)
internal-packages/testcontainers/src/index.ts (1)
  • redisTest (132-132)
internal-packages/run-engine/src/engine/tests/pendingVersion.test.ts (1)
packages/core/src/v3/schemas/runEngine.ts (2)
  • DequeuedMessage (226-261)
  • DequeuedMessage (262-262)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: units / 🧪 Unit Tests
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (13)
internal-packages/run-engine/src/run-queue/index.test.ts (1)

358-359: Test marked as expected to fail with clear explanation

The comment clearly indicates why this test is now marked to fail - it aligns with the PR's stated purpose of updating tests to handle the v4 dequeue behavior change which only returns one run per environment.

internal-packages/run-engine/src/engine/tests/batchTrigger.test.ts (2)

8-8: Type import added for better type safety

Adding the DequeuedMessage type import provides proper typing for the dequeued messages array.


119-129: Adjusted dequeue pattern to align with v4 behavior

The code has been updated to perform sequential single-item dequeues rather than a bulk dequeue operation, aligning with the new v4 behavior where only one run per environment is returned.

internal-packages/run-engine/src/engine/tests/pendingVersion.test.ts (2)

6-6: Type import added for better type safety

Adding the DequeuedMessage type import provides proper typing for the dequeued messages array.


105-115: Adjusted dequeue pattern to align with v4 behavior

The code has been updated to perform multiple sequential dequeues with maxRunCount=1 instead of a single bulk dequeue. This properly aligns with the new v4 behavior that only returns one run per environment.

internal-packages/run-engine/src/engine/tests/priority.test.ts (3)

9-9: Type import added for better type safety

Adding the DequeuedMessage type import provides proper typing for the dequeued messages array.


81-89: Updated dequeue approach to handle v4 single-run limitation

The code now performs 4 sequential dequeue operations instead of a single bulk dequeue, while maintaining the original test's verification of run priority order. This aligns with the v4 limitation of only returning one run per environment.


183-192: Updated dequeue approach to handle v4 single-run limitation

The code now performs 5 sequential dequeue operations instead of a single bulk dequeue, properly maintaining the test's verification of run queue timestamp ordering.

internal-packages/run-engine/src/engine/tests/dequeuing.test.ts (5)

9-9: Good addition of type safety

Adding the DequeuedMessage type import improves type checking for the dequeued messages array.


67-76: Well-implemented sequential dequeuing approach

This change correctly implements the new dequeuing behavior by making 5 separate calls with maxRunCount: 1 instead of a single bulk dequeue. The accumulation of results into a typed array is clean and maintainable.


84-85: Good use of containerTest.fails with explanatory comment

Excellent approach to mark this test as an expected failure with a clear comment explaining why it will fail. This helps maintain the test for future compatibility when multiple runs per environment are supported.


142-151: Test correctly preserved for future compatibility

The test code for dequeuing with resource constraints is correctly preserved and will be ready to use once multiple runs per environment dequeuing is supported. The expected behavior (dequeuing 2 runs) is clearly documented with the expectation statement.


157-170: Second dequeue operation correctly preserved

The second dequeue operation with different resource constraints is also properly maintained for future compatibility, with clear expectations set for the number of runs that should be dequeued (6) and the resulting queue length.

✨ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@matt-aitken matt-aitken merged commit 280a6d0 into main Apr 29, 2025
12 checks passed
@matt-aitken matt-aitken deleted the dequeue-test-fixes branch April 29, 2025 11:40
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