This is an automated email from the ASF dual-hosted git repository.
mattisonchao 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 3a9fca9dd64 [fix][test] Fix RangeConvert parse issue in the
PerformanceProducer (#20755)
3a9fca9dd64 is described below
commit 3a9fca9dd64df6003f72e880cc2f56d83382b6ab
Author: Cong Zhao <[email protected]>
AuthorDate: Sat Jul 8 21:44:39 2023 +0800
[fix][test] Fix RangeConvert parse issue in the PerformanceProducer (#20755)
---
.../pulsar/testclient/PerformanceProducer.java | 4 ++--
.../pulsar/testclient/PerformanceProducerTest.java | 22 +++++++++++++++-------
2 files changed, 17 insertions(+), 9 deletions(-)
diff --git
a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceProducer.java
b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceProducer.java
index c1d4f54e4d7..63e3e2ec6fd 100644
---
a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceProducer.java
+++
b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceProducer.java
@@ -205,7 +205,7 @@ public class PerformanceProducer {
@Parameter(names = { "-dr", "--delay-range"}, description = "Mark
messages with a given delay by a random"
+ " number of seconds. this value between the specified origin
(inclusive) and the specified bound"
- + " (exclusive). e.g. \"1,300\"", converter =
RangeConvert.class)
+ + " (exclusive). e.g. 1,300", converter = RangeConvert.class)
public Range<Long> delayRange = null;
@Parameter(names = { "-set",
@@ -801,7 +801,7 @@ public class PerformanceProducer {
public Range<Long> convert(String rangeStr) {
try {
requireNonNull(rangeStr);
- final String[] facts = rangeStr.substring(1, rangeStr.length()
- 1).split(",");
+ final String[] facts = rangeStr.split(",");
final long min = Long.parseLong(facts[0].trim());
final long max = Long.parseLong(facts[1].trim());
return Range.closedOpen(min, max);
diff --git
a/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceProducerTest.java
b/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceProducerTest.java
index e343b1d8cbc..bf2fade1c67 100644
---
a/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceProducerTest.java
+++
b/pulsar-testclient/src/test/java/org/apache/pulsar/testclient/PerformanceProducerTest.java
@@ -18,7 +18,14 @@
*/
package org.apache.pulsar.testclient;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.fail;
+import com.google.common.collect.Range;
import com.google.common.collect.Sets;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest;
import org.apache.pulsar.client.api.ClientBuilder;
@@ -35,13 +42,6 @@ import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.util.List;
-import java.util.UUID;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.fail;
-
@Slf4j
public class PerformanceProducerTest extends MockedPulsarServiceBaseTest {
private final String testTenant = "prop-xyz";
@@ -237,4 +237,12 @@ public class PerformanceProducerTest extends
MockedPulsarServiceBaseTest {
});
consumer.close();
}
+
+ @Test
+ public void testRangeConvert() {
+ PerformanceProducer.RangeConvert rangeConvert = new
PerformanceProducer.RangeConvert();
+ Range<Long> range = rangeConvert.convert("100,200");
+ Assert.assertEquals(range.lowerEndpoint(), 100);
+ Assert.assertEquals(range.upperEndpoint(), 200);
+ }
}