Skip to content

fix(tests): un-quarantine gateway proxy integration suites - #1654

Open
Mossad-esc wants to merge 1 commit into
CalloraOrg:mainfrom
Mossad-esc:fix/issue-1563-unquarantine-proxy-suites
Open

Mossad-esc wants to merge 1 commit into
CalloraOrg:mainfrom
Mossad-esc:fix/issue-1563-unquarantine-proxy-suites

Conversation

@Mossad-esc

Copy link
Copy Markdown

Summary

Repairs and un-quarantines the four gateway proxy integration suites (proxy.integration.test.ts, proxy.drain.test.ts, hopByHopProxy.integration.test.ts, and gateway.integration.test.ts) so the /v1/call and /api/gateway proxy paths run in CI.

Root Causes & Changes

Production Bug Fixes

  • src/routes/proxyRoutes.ts:
    • Restored the drainGuard middleware (using drainState?.isDraining()) ahead of authMiddleware so draining instances immediately reject new requests with 503 Service Unavailable, Connection: close, and Retry-After: 0 without forwarding upstream or recording usage.
    • Restored idempotencyMiddleware on POST and PATCH /v1/call routes (setting res.locals.authenticatedUser from req.apiKeyRecord.userId so idempotency scopes remain isolated per developer).
  • src/services/usageStore.ts:
    • Updated InMemoryUsageStore.getEvents(apiKey) to match e.apiKey === apiKey || e.apiKeyId === apiKey (aligning with PostgresUsageStore.getEvents), since proxy routes record apiKeyId rather than plaintext apiKey.

Test & Quarantine Updates

  • src/__tests__/proxy.integration.test.ts: Added an in-memory idempotency_store pool mock, passed a shared InMemoryCircuitBreakerStore reset in beforeEach, flushed async setImmediate usage recording before assertions, updated error assertions for the { error: { code, message, details } } envelope, replaced Promise.withResolvers with a Node 20 helper, fixed the concurrent IDEMPOTENCY_IN_PROGRESS race, and updated slow-header/timeout tests for the 3-attempt GET retry contract.
  • src/__tests__/hopByHopProxy.integration.test.ts: Added allowedHosts: ['localhost'] and errorHandler, and used node:http with buildHopByHopSet to verify dynamic Connection-listed header stripping.
  • src/__tests__/gateway.integration.test.ts: Registered requestIdMiddleware and errorHandler, updated 402/429/504 assertions to the JSON error envelope, and updated the 504 test to assert no usage event is recorded on upstream timeout.
  • jest.quarantine.json: Removed the 4 suites (79/79 tests passing under npm test -- --runInBand).

Closes #1563

Restore drainGuard and Idempotency-Key middleware on /v1/call proxy routes, align InMemoryUsageStore.getEvents with apiKeyId lookups, and update proxy/gateway integration tests for current error envelopes, allowlists, and async usage recording.

Closes CalloraOrg#1563
@drips-wave

drips-wave Bot commented Nov 23, 2026

Copy link
Copy Markdown

@Mossad-esc Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Un-quarantine the gateway proxy integration suites

1 participant