Skip to content

refactor: update budget exhaustion test description and remove obsolete test case#1769

Merged
Artuomka merged 1 commit into
mainfrom
backend_stripe_proxy_usage_reports
May 14, 2026
Merged

refactor: update budget exhaustion test description and remove obsolete test case#1769
Artuomka merged 1 commit into
mainfrom
backend_stripe_proxy_usage_reports

Conversation

@Artuomka
Copy link
Copy Markdown
Collaborator

@Artuomka Artuomka commented May 14, 2026

Summary by CodeRabbit

  • Improvements
    • Modified query-time budget handling to queue requests when budget is exhausted instead of rejecting them, allowing queries to resume once budget is refilled.

Review Change Stack

Copilot AI review requested due to automatic review settings May 14, 2026 08:27
@Artuomka Artuomka enabled auto-merge May 14, 2026 08:27
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

📝 Walkthrough

Walkthrough

The PR removes an e2e test that checked budget exhaustion triggers request rejection, replacing it with documentation that the expected behavior is queue-and-wait instead. Coverage is moved to unit tests in bucket_test.go.

Changes

Test Coverage Reorganization

Layer / File(s) Summary
Remove budget rejection e2e test and document queue behavior
backend/test/ava-tests/saas-tests/saas-postgres-proxy-e2e.test.ts
The "should reject queries once query-time budget is exhausted" test is removed. Its assertion logic expecting budget-related failure (status code 53400) is replaced with a comment clarifying the actual behavior: budget exhaustion triggers queue-and-wait via Limiter.WaitForBudget, not rejection. Equivalent coverage is documented as present in postgres-proxy/internal/ratelimit/bucket_test.go.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A test once stood, checking rejection's way,
But budget waits—no need to turn away,
The queue now holds what burst before,
Unit tests keep watch at the core,
We hop to cleaner test floors!

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Security Check ⚠️ Warning PR removes budget exhaustion test without equivalent replacement. Claims coverage from non-existent Go test file. No queuing implementation found. Removes DoS protection verification. Restore test or provide equivalent coverage. Verify referenced Go tests exist. Document behavior change and validate queuing prevents DoS attacks properly.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main changes: removing an obsolete budget exhaustion test case and updating test description/comments to reflect new expected behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch backend_stripe_proxy_usage_reports

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes an obsolete AVA e2e test that expected budget exhaustion to fail, replacing it with a comment describing the current queue-and-wait behavior.

Changes:

  • Removed the e2e test that expected a 53400-style budget rejection.
  • Added an explanatory comment pointing to lower-level budget wait tests as intended coverage.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +562 to +567
// token-bucket budget park on `Limiter.WaitForBudget` until tokens refill,
// rather than returning a 53400. End-to-end verification of that wait is
// covered by `postgres-proxy/internal/ratelimit/bucket_test.go`
// (TestLimiter_WaitForBudget_*), which can simulate refill in milliseconds.
// An equivalent rocketadmin e2e check would need a custom plan with a refill
// rate that completes inside the AVA timeout — not worth the moving pieces.
Copy link
Copy Markdown

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/test/ava-tests/saas-tests/saas-postgres-proxy-e2e.test.ts`:
- Around line 561-567: Confirm whether the referenced Go tests actually exist
before removing the e2e check: search the repo and any git
submodules/dependencies for the path
postgres-proxy/internal/ratelimit/bucket_test.go and for symbols named
TestLimiter_WaitForBudget_*; if they are missing, either (a) update the comment
in saas-postgres-proxy-e2e.test.ts to point to the correct path/test names or to
the actual unit tests that provide equivalent coverage, or (b) keep (or restore)
the e2e verification and add a new unit test that exercises the
Limiter.WaitForBudget behavior (or reference the external repo where the tests
live and add verification steps to pull that dependency); make the change by
editing the comment or adding the tests so there is explicit, discoverable proof
of equivalent coverage.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0377f365-6b2d-49eb-a582-31401b43cdcf

📥 Commits

Reviewing files that changed from the base of the PR and between 48030d0 and 2a81ce2.

📒 Files selected for processing (1)
  • backend/test/ava-tests/saas-tests/saas-postgres-proxy-e2e.test.ts

Comment on lines +561 to +567
// Budget-exhaustion behaviour is "queue, don't fail": queries past the
// token-bucket budget park on `Limiter.WaitForBudget` until tokens refill,
// rather than returning a 53400. End-to-end verification of that wait is
// covered by `postgres-proxy/internal/ratelimit/bucket_test.go`
// (TestLimiter_WaitForBudget_*), which can simulate refill in milliseconds.
// An equivalent rocketadmin e2e check would need a custom plan with a refill
// rate that completes inside the AVA timeout — not worth the moving pieces.
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Description: Verify the referenced Go test file and test cases exist

# Check if the referenced test file exists
if fd -t f '^bucket_test\.go$' postgres-proxy/internal/ratelimit 2>/dev/null | grep -q .; then
  echo "✓ Found bucket_test.go"
  
  # Search for TestLimiter_WaitForBudget test cases
  echo -e "\n=== TestLimiter_WaitForBudget test cases ==="
  rg -n "func.*TestLimiter_WaitForBudget" postgres-proxy/internal/ratelimit/bucket_test.go -A 3
  
  # Check if tests verify queue behavior (not rejection)
  echo -e "\n=== Checking for queue/wait behavior verification ==="
  rg -n -C 3 "WaitForBudget|queue|wait.*budget|refill" postgres-proxy/internal/ratelimit/bucket_test.go | head -30
else
  echo "✗ bucket_test.go not found in postgres-proxy/internal/ratelimit/"
  echo "The referenced test file may not exist or the path may be incorrect"
fi

Repository: rocket-admin/rocketadmin

Length of output: 201


🏁 Script executed:

#!/bin/bash
# Search for bucket_test.go anywhere in the codebase
echo "=== Searching for bucket_test.go in entire repository ==="
fd -t f "bucket_test\.go" 2>/dev/null

echo -e "\n=== Searching for TestLimiter_WaitForBudget in entire repository ==="
rg "TestLimiter_WaitForBudget" 2>/dev/null | head -10

echo -e "\n=== Checking if postgres-proxy directory exists and its structure ==="
fd -t d "postgres-proxy" 2>/dev/null | head -10

echo -e "\n=== Checking for bucket-related test files ==="
fd -t f "bucket.*test" 2>/dev/null

echo -e "\n=== Checking for ratelimit-related test files ==="
fd -t f ".*ratelimit.*test" 2>/dev/null

Repository: rocket-admin/rocketadmin

Length of output: 509


Verify that the referenced Go tests actually exist before removing e2e verification.

The comment justifies removing this e2e test based on coverage from postgres-proxy/internal/ratelimit/bucket_test.go (specifically TestLimiter_WaitForBudget_* tests). However, neither this file nor these tests exist anywhere in the repository.

Before this test removal is valid, confirm:

  1. Whether the referenced tests exist in an external/dependency repository
  2. Whether the path or test names are incorrect
  3. If not: that equivalent coverage exists elsewhere before removing the e2e verification

Removing end-to-end test coverage without verifying equivalent unit test coverage exists creates a critical gap.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/test/ava-tests/saas-tests/saas-postgres-proxy-e2e.test.ts` around
lines 561 - 567, Confirm whether the referenced Go tests actually exist before
removing the e2e check: search the repo and any git submodules/dependencies for
the path postgres-proxy/internal/ratelimit/bucket_test.go and for symbols named
TestLimiter_WaitForBudget_*; if they are missing, either (a) update the comment
in saas-postgres-proxy-e2e.test.ts to point to the correct path/test names or to
the actual unit tests that provide equivalent coverage, or (b) keep (or restore)
the e2e verification and add a new unit test that exercises the
Limiter.WaitForBudget behavior (or reference the external repo where the tests
live and add verification steps to pull that dependency); make the change by
editing the comment or adding the tests so there is explicit, discoverable proof
of equivalent coverage.

@Artuomka Artuomka merged commit e6f9a80 into main May 14, 2026
20 checks passed
@Artuomka Artuomka deleted the backend_stripe_proxy_usage_reports branch May 14, 2026 08:35
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