-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove duplicated batchSize factor from target load; add a test case (#…
…662) * Remove duplicated batchSize factor from target load; add a test case
- Loading branch information
1 parent
075b4f9
commit 0c9b7da
Showing
4 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...va/io/confluent/parallelconsumer/AbstractParallelEoSStreamProcessorConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package io.confluent.parallelconsumer; | ||
|
||
/*- | ||
* Copyright (C) 2020-2023 Confluent, Inc. | ||
*/ | ||
|
||
import io.confluent.parallelconsumer.internal.TestParallelEoSStreamProcessor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.kafka.clients.consumer.OffsetResetStrategy; | ||
import org.apache.kafka.clients.consumer.MockConsumer; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
/** | ||
* Tests to verify the protected and internal methods of | ||
* {@link io.confluent.parallelconsumer.internal.AbstractParallelEoSStreamProcessor} work as expected. | ||
* <p> | ||
* | ||
* @author Jonathon Koyle | ||
*/ | ||
@Slf4j | ||
class AbstractParallelEoSStreamProcessorConfigurationTest { | ||
|
||
/** | ||
* Test that the {@link io.confluent.parallelconsumer.internal.AbstractParallelEoSStreamProcessor#getQueueTargetLoaded} | ||
*/ | ||
@Test | ||
void queueTargetLoad() { | ||
final int batchSize = 10; | ||
final int concurrency = 2; | ||
final MockConsumer<String, String> consumer = new MockConsumer<>(OffsetResetStrategy.LATEST); | ||
final ParallelConsumerOptions<String, String> testOptions = ParallelConsumerOptions.<String, String>builder() | ||
.batchSize(batchSize) | ||
.maxConcurrency(concurrency) | ||
.consumer(consumer) | ||
.build(); | ||
try (final TestParallelEoSStreamProcessor<String, String> testInstance = new TestParallelEoSStreamProcessor<>(testOptions)) { | ||
final int defaultLoad = 2; | ||
final int expectedTargetLoad = batchSize * concurrency * defaultLoad; | ||
|
||
final int actualTargetLoad = testInstance.getTargetLoad(); | ||
|
||
Assertions.assertEquals(expectedTargetLoad, actualTargetLoad); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
.../src/test/java/io/confluent/parallelconsumer/internal/TestParallelEoSStreamProcessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.confluent.parallelconsumer.internal; | ||
|
||
/*- | ||
* Copyright (C) 2020-2023 Confluent, Inc. | ||
*/ | ||
|
||
import io.confluent.parallelconsumer.ParallelConsumerOptions; | ||
|
||
/** | ||
* Provides a set of methods for testing internal and configuration based interfaces of | ||
* {@link AbstractParallelEoSStreamProcessor}. | ||
*/ | ||
public class TestParallelEoSStreamProcessor<K, V> extends AbstractParallelEoSStreamProcessor<K, V> { | ||
public TestParallelEoSStreamProcessor(final ParallelConsumerOptions<K, V> newOptions) { | ||
super(newOptions); | ||
} | ||
|
||
public int getTargetLoad() { return getQueueTargetLoaded(); } | ||
} |