kumarpritam863 commented on code in PR #14630:
URL: https://github.com/apache/kafka/pull/14630#discussion_r1380524843
##########
connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerSinkTaskTest.java:
##########
@@ -1999,6 +2004,81 @@ public void
testErrorReporterConfigurationExceptionPropagation() {
PowerMock.verifyAll();
}
+ @Test
+ public void testPartitionCountInCaseOfPartitionRevocation() {
+ mockConsumer = new MockConsumer<>(OffsetResetStrategy.EARLIEST);
+ // Setting up Worker Sink Task to check metrics
+ workerTask = new WorkerSinkTask(
+ taskId, sinkTask, statusListener, TargetState.PAUSED,
workerConfig, ClusterConfigState.EMPTY, metrics,
+ keyConverter, valueConverter, errorHandlingMetrics,
headerConverter,
+ transformationChain, mockConsumer, pluginLoader, time,
+ RetryWithToleranceOperatorTest.NOOP_OPERATOR, null,
statusBackingStore, Collections::emptyList);
+ // Subscribing to Topic = "test" with "MockHandleRebalance"
+ mockConsumer.subscribe(asList(TOPIC), new MockHandleRebalancePass());
+ // Initial Rebalance to assign INITIAL_ASSIGNMENT which is
"TOPIC_PARTITION" and "TOPIC_PARTITION2"
+ ((MockConsumer<byte[], byte[]>)
mockConsumer).rebalance(INITIAL_ASSIGNMENT);
+ assertSinkMetricValue("partition-count", 2);
+ // Revoked "TOPIC_PARTITION" and second rebalnce with
"TOPIC_PARTITION2"
+ ((MockConsumer<byte[], byte[]>)
mockConsumer).rebalance(Collections.singleton(TOPIC_PARTITION2));
+ assertSinkMetricValue("partition-count", 1);
Review Comment:
Yes I have added the close call and assert metrics to check 0 value.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]