Skip to content

Commit ca5809a

Browse files
committed
Allow 0 for --max-length-bytes option (no limit)
1 parent 6fa18e0 commit ca5809a

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/main/java/com/rabbitmq/stream/perf/StreamPerfTest.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public class StreamPerfTest implements Callable<Integer> {
224224

225225
@CommandLine.Option(
226226
names = {"--max-length-bytes", "-mlb"},
227-
description = "max size of created streams",
227+
description = "max size of created streams, use 0 for no limit",
228228
defaultValue = "20gb",
229229
converter = Utils.ByteCapacityTypeConverter.class)
230230
private ByteCapacity maxLengthBytes;
@@ -976,10 +976,13 @@ public Integer call() throws Exception {
976976
private void createStream(Environment environment, String stream) {
977977
StreamCreator streamCreator =
978978
environment.streamCreator().stream(stream)
979-
.maxLengthBytes(this.maxLengthBytes)
980979
.maxSegmentSizeBytes(this.maxSegmentSize)
981980
.leaderLocator(this.leaderLocator);
982981

982+
if (this.maxLengthBytes.toBytes() != 0) {
983+
streamCreator.maxLengthBytes(this.maxLengthBytes);
984+
}
985+
983986
if (this.maxAge != null) {
984987
streamCreator.maxAge(this.maxAge);
985988
}

src/test/java/com/rabbitmq/stream/ByteCapacityTest.java

+6
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ void fromOk(String value, long expectedValueInBytes) {
4848
assertThat(capacity.toString()).isEqualTo(value);
4949
}
5050

51+
@ValueSource(strings = {"0tb", "0gb", "0mb", "0kb", "0"})
52+
@ParameterizedTest
53+
void zero(String value) {
54+
assertThat(ByteCapacity.from(value).toBytes()).isEqualTo(0);
55+
}
56+
5157
@ParameterizedTest
5258
@ValueSource(strings = {"100.0gb", "abc", "100.0", "-10gb", "10b"})
5359
void fromKo(String value) {

0 commit comments

Comments
 (0)