This is an automated email from the ASF dual-hosted git repository.
lhotari pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 3b6a7609674 [fix][test] Stabilize WebService rate limiting test
(#25866)
3b6a7609674 is described below
commit 3b6a76096740870e87c93919b21ddbd1ee2cdeed
Author: Oneby Wang <[email protected]>
AuthorDate: Mon May 25 15:06:40 2026 +0800
[fix][test] Stabilize WebService rate limiting test (#25866)
---
.../apache/pulsar/broker/web/WebServiceTest.java | 24 ++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/web/WebServiceTest.java
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/web/WebServiceTest.java
index bc4260ec771..adf9132f9a9 100644
---
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/web/WebServiceTest.java
+++
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/web/WebServiceTest.java
@@ -268,7 +268,8 @@ public class WebServiceTest {
@Test
public void testRateLimiting() throws Exception {
- setupEnv(false, false, false, false, 10.0, false);
+ double rateLimit = 10.0;
+ setupEnv(false, false, false, false, rateLimit, false);
// setupEnv makes HTTP calls to create the cluster, tenant, and
namespace.
var metrics =
pulsarTestContext.getOpenTelemetryMetricReader().collectAllMetrics();
@@ -282,7 +283,7 @@ public class WebServiceTest {
// Make requests without exceeding the max rate
for (int i = 0; i < 5; i++) {
makeHttpRequest(false, false);
- Thread.sleep(200);
+ Thread.sleep(rateLimitPauseMillis(rateLimit));
}
metrics =
pulsarTestContext.getOpenTelemetryMetricReader().collectAllMetrics();
@@ -572,13 +573,32 @@ public class WebServiceTest {
} catch (ConflictException ce) {
// This is OK.
}
+ sleepForRateLimiter(rateLimit);
+
try {
pulsarAdmin.tenants().createTenant("my-property",
TenantInfo.builder().allowedClusters(Sets.newHashSet(config.getClusterName())).build());
+ } catch (Exception e) {
+ // This is OK.
+ }
+ sleepForRateLimiter(rateLimit);
+
+ try {
pulsarAdmin.namespaces().createNamespace("my-property/my-namespace");
} catch (Exception e) {
// This is OK.
}
+ sleepForRateLimiter(rateLimit);
+ }
+
+ private static void sleepForRateLimiter(double rateLimit) throws
InterruptedException {
+ if (rateLimit > 0) {
+ Thread.sleep(rateLimitPauseMillis(rateLimit));
+ }
+ }
+
+ private static long rateLimitPauseMillis(double rateLimit) {
+ return (long) Math.ceil((1000.0 / rateLimit) * 2);
}
@AfterMethod(alwaysRun = true)