Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update rate limiting test so it's not flaky #8872

Merged
merged 1 commit into from
Mar 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ CommonCreateConfigs.VALUE_FORMAT_PROPERTY, new StringLiteral("json")
public void shouldThrowIfRateLimitHit() {
// Given:
final DistributingExecutor rateLimitedDistributor = new DistributingExecutor(
new KsqlConfig(ImmutableMap.of(KsqlRestConfig.KSQL_COMMAND_TOPIC_RATE_LIMIT_CONFIG, 0.5)),
new KsqlConfig(ImmutableMap.of(KsqlRestConfig.KSQL_COMMAND_TOPIC_RATE_LIMIT_CONFIG, 0.25)),
queue,
DURATION_10_MS,
(ec, sc) -> InjectorChain.of(schemaInjector, topicInjector),
Expand All @@ -521,13 +521,20 @@ public void shouldThrowIfRateLimitHit() {


// Then:
final KsqlRestException e = assertThrows(
KsqlRestException.class,
() -> rateLimitedDistributor.execute(CONFIGURED_STATEMENT, executionContext, securityContext)
);

assertEquals(e.getResponse().getStatus(), 429);
final KsqlErrorMessage errorMessage = (KsqlErrorMessage) e.getResponse().getEntity();
assertTrue(errorMessage.getMessage().contains("DDL/DML rate is crossing the configured rate limit of statements/second"));
boolean exceptionFound = false;
try {
rateLimitedDistributor.execute(CONFIGURED_STATEMENT, executionContext, securityContext);
rateLimitedDistributor.execute(CONFIGURED_STATEMENT, executionContext, securityContext);
rateLimitedDistributor.execute(CONFIGURED_STATEMENT, executionContext, securityContext);
rateLimitedDistributor.execute(CONFIGURED_STATEMENT, executionContext, securityContext);
} catch (Exception e) {
assertTrue(e instanceof KsqlRestException);
final KsqlRestException restException = (KsqlRestException) e;
assertEquals(restException.getResponse().getStatus(), 429);
final KsqlErrorMessage errorMessage = (KsqlErrorMessage) restException.getResponse().getEntity();
assertTrue(errorMessage.getMessage().contains("DDL/DML rate is crossing the configured rate limit of statements/second"));
exceptionFound = true;
}
assertTrue(exceptionFound);
}
}