Skip to content

Added integration tests#1820

Open
Saadha123 wants to merge 1 commit intowso2:mainfrom
Saadha123:tests/consumer-based-rl
Open

Added integration tests#1820
Saadha123 wants to merge 1 commit intowso2:mainfrom
Saadha123:tests/consumer-based-rl

Conversation

@Saadha123
Copy link
Copy Markdown
Contributor

Purpose

Added integration tests for consumer based ratelimit.

9 scenarios across 3 feature files

Feature Scenarios
consumer-token-based-ratelimit Independent consumer counters; backend blocks all when exhausted; fallback default counter when no app ID
consumer-request-based-ratelimit Same three scenarios for request count limits
consumer-cost-based-ratelimit Same three scenarios for cost limits

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 29, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5c2dd0e6-028a-4e2c-b2c7-93b264c3b3a4

📥 Commits

Reviewing files that changed from the base of the PR and between 49bd727 and e6e2dee.

📒 Files selected for processing (4)
  • gateway/it/features/consumer-cost-based-ratelimit.feature
  • gateway/it/features/consumer-request-based-ratelimit.feature
  • gateway/it/features/consumer-token-based-ratelimit.feature
  • gateway/it/suite_test.go

📝 Walkthrough

Overview

Added comprehensive integration tests for consumer-based rate limiting functionality across three distinct rate-limiting strategies: token-based, request-based, and cost-based. The test suite validates per-consumer quota management with shared backend limits and fallback behavior.

Test Coverage

The integration tests cover nine scenarios distributed across three feature files, each validating three key behaviors:

  1. Independent consumer counters: Separate quota tracking per application, ensuring one consumer reaching their limit does not affect others
  2. Backend-wide limit enforcement: Shared backend quota that, when exhausted, blocks all consumers regardless of their individual counter states
  3. Fallback default bucket: When no application ID is present, requests route to a shared "default" bucket with unified quota enforcement

Feature files added:

  • consumer-token-based-ratelimit.feature: Tests token consumption limits per consumer
  • consumer-request-based-ratelimit.feature: Tests request count limits per consumer
  • consumer-cost-based-ratelimit.feature: Tests cost-based budget limits per consumer

Each scenario dynamically creates test fixtures (LLM provider templates and providers), configures the advanced rate-limit policy with consumer-based settings, validates the expected HTTP responses (including 429 status when limits are exceeded), and performs cleanup.

Changes Made

  • Added three new test feature files totaling 1,264 lines of integration test scenarios
  • Updated gateway/it/suite_test.go to include the new feature files in the default test execution path

Walkthrough

This pull request adds three new integration test feature files that validate consumer-based rate limiting functionality across different rate limit types. The consumer-cost-based-ratelimit.feature file defines four scenarios testing cost-based budget enforcement with independent per-application budgets, shared backend budgets, and default bucket fallback. The consumer-request-based-ratelimit.feature file covers three scenarios validating request quota limits with per-consumer separation and backend quota sharing. The consumer-token-based-ratelimit.feature file specifies three scenarios testing token consumption limits with independent per-consumer tracking and shared backend depletion. Additionally, the test suite configuration is updated to automatically include these three feature files in the default integration test execution path.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete; it covers only Purpose but omits Goals, Approach, Automation tests details, Documentation, Security checks, Samples, Related PRs, and Test environment sections required by the template. Complete the pull request description by filling in all required template sections: Goals, Approach, Documentation, Automation tests (with coverage details), Security checks, and Test environment information.
Title check ❓ Inconclusive The title 'Added integration tests' is too generic and does not specify what type of tests or which functionality they cover. Revise the title to be more specific, such as 'Add consumer-based rate limit integration tests' to clearly indicate the feature being tested.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 unit tests (beta)
  • Create PR with unit tests

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.

🔧 golangci-lint (2.11.4)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain modules listed in go.work or their selected dependencies"


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
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants