Merged in feature/rate-limiting (pull request #190)

Implement global and per ip rate limiting

* all tests passing

* test fix

* Enhances test environment for rate limiting

Updates the test environment to better support rate limiting tests.

- Increases rate limits in test container to avoid interference with legitimate test traffic.
- Increases the polling interval for client status checks to reduce load on the rate limiter.
- Adds logic to retry status checks if rate limiting is encountered.

* Merge branch 'main' of bitbucket.org:aarete/query-orchestration into feature/rate-limiting

* build fix

* test fix
This commit is contained in:
Jay Brown
2025-10-13 22:13:15 +00:00
parent 4783b8420a
commit 7638fd3a90
11 changed files with 1224 additions and 8 deletions
+11 -1
View File
@@ -89,7 +89,7 @@ func WaitForClientStatus(t testing.TB, ctx context.Context, service queryapi.Cli
t.Helper()
timeout := time.After(60 * time.Second)
ticker := time.NewTicker(100 * time.Millisecond)
ticker := time.NewTicker(500 * time.Millisecond) // Increased from 100ms to avoid rate limiting (2 req/s < 5 req/s limit)
defer ticker.Stop()
for {
@@ -103,6 +103,16 @@ func WaitForClientStatus(t testing.TB, ctx context.Context, service queryapi.Cli
require.NoError(t, err)
}
// Check if we got a non-200 response (e.g., 429 rate limit)
if jRes.JSON200 == nil {
if jRes.StatusCode() == http.StatusTooManyRequests {
slog.Warn("rate limit hit while polling status, will retry", "status_code", jRes.StatusCode())
continue
}
require.Fail(t, fmt.Sprintf("unexpected status code %d waiting for client status", jRes.StatusCode()))
return
}
if jRes.JSON200.Status == status {
assert.Equal(t, status, jRes.JSON200.Status)
slog.Info("returned client status", "status", jRes.JSON200.Status)