Skip to content

Cypress: Rate limiting returns 429 when 200 expected on consumer limit #1292

Description

@rustyjux

API Services Portal Bug Issue

Seems isolated to Cypress tests. Currently not able to duplicate locally - might just be a matter of adding more wait time.

Failures on two instances of verify rate limit error when the API calls beyond the limit:

Test Case

ENV

  • e2e
  • DEV
  • TEST
  • PROD

TESTCASE

Failures are on tests where:

  • global rate limit (20/hr, local policy) is set first,
  • then a consumer limit (2/hr, adjusted down to 1/hr following redis key clearing fix) is set (for Service and Route, respectively, in each test).

EXPECTED

  • The first request returns 200
  • The second request returns 429 Too Many Requests

ACTUAL

  • The first request gets a 429

ANALYSIS

The cause seems to be carried over requests from previous tests being stored in redis, leading to a 429 error.

An attempted fix (which works when running Cypress locally) was to clear relevant redis keys via redis-cli before the test requests. This actually works so well (locally at least) that the test needed to be adjusted to the (expected) limit of 1/hr, because the test makes 1 request (200 expected), then a second with 429 expected. Nevertheless, the issue of first request returning 429 persists in CI e2e testing.

Sometimes only 1 of the 2 tests fails, e.g. #1295

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions