RamanVerma commented on code in PR #20:
URL:
https://github.com/apache/flink-connector-kafka/pull/20#discussion_r1160275482
##########
flink-connector-kafka/src/test/java/org/apache/flink/connector/kafka/source/reader/KafkaPartitionSplitReaderTest.java:
##########
@@ -319,6 +321,51 @@ public void
testUsingCommittedOffsetsWithEarliestOrLatestOffsetResetStrategy(
assertThat(reader.consumer().position(partition)).isEqualTo(expectedOffset);
}
+ @Test
+ public void testConsumerClientRackSupplier() {
+ AtomicReference<Boolean> supplierCalled = new AtomicReference<>(false);
+ String rackId = "use1-az1";
+ Supplier<String> rackIdSupplier =
+ () -> {
+ supplierCalled.set(true);
+ return rackId;
+ };
+ Properties properties = new Properties();
+ createReader(
+ properties,
+ UnregisteredMetricsGroup.createSourceReaderMetricGroup(),
+ rackIdSupplier);
+ assertThat(supplierCalled.get()).isEqualTo(true);
+ }
+
+ @ParameterizedTest
+ @NullAndEmptySource
+ public void testSetConsumerClientRackIgnoresNullAndEmpty(String rackId) {
+ Properties properties = new Properties();
+ Supplier<String> rackIdSupplier = () -> rackId;
+ KafkaPartitionSplitReader reader =
+ createReader(
+ properties,
+
UnregisteredMetricsGroup.createSourceReaderMetricGroup(),
+ rackIdSupplier);
+ reader.setConsumerClientRack(properties, rackIdSupplier);
Review Comment:
Supplier function should get called from `KafkaPartitionSplitReader`
constructor. Do you need to call this method. Same for line 365
##########
flink-connector-kafka/src/test/java/org/apache/flink/connector/kafka/source/reader/KafkaPartitionSplitReaderTest.java:
##########
@@ -319,6 +321,51 @@ public void
testUsingCommittedOffsetsWithEarliestOrLatestOffsetResetStrategy(
assertThat(reader.consumer().position(partition)).isEqualTo(expectedOffset);
}
+ @Test
+ public void testConsumerClientRackSupplier() {
+ AtomicReference<Boolean> supplierCalled = new AtomicReference<>(false);
+ String rackId = "use1-az1";
+ Supplier<String> rackIdSupplier =
+ () -> {
+ supplierCalled.set(true);
+ return rackId;
+ };
+ Properties properties = new Properties();
+ createReader(
+ properties,
+ UnregisteredMetricsGroup.createSourceReaderMetricGroup(),
+ rackIdSupplier);
+ assertThat(supplierCalled.get()).isEqualTo(true);
+ }
+
+ @ParameterizedTest
+ @NullAndEmptySource
+ public void testSetConsumerClientRackIgnoresNullAndEmpty(String rackId) {
+ Properties properties = new Properties();
+ Supplier<String> rackIdSupplier = () -> rackId;
+ KafkaPartitionSplitReader reader =
+ createReader(
+ properties,
+
UnregisteredMetricsGroup.createSourceReaderMetricGroup(),
+ rackIdSupplier);
+ reader.setConsumerClientRack(properties, rackIdSupplier);
+
assertThat(properties.containsKey(ConsumerConfig.CLIENT_RACK_CONFIG)).isFalse();
+ }
+
+ @Test
+ public void testSetConsumerClientRackUsesCorrectParameter() {
Review Comment:
This test can be combined with the first one if you add the assertion from
line 366 to after line 338
##########
flink-connector-kafka/src/test/java/org/apache/flink/connector/kafka/source/reader/KafkaPartitionSplitReaderTest.java:
##########
@@ -319,6 +321,51 @@ public void
testUsingCommittedOffsetsWithEarliestOrLatestOffsetResetStrategy(
assertThat(reader.consumer().position(partition)).isEqualTo(expectedOffset);
}
+ @Test
+ public void testConsumerClientRackSupplier() {
+ AtomicReference<Boolean> supplierCalled = new AtomicReference<>(false);
+ String rackId = "use1-az1";
+ Supplier<String> rackIdSupplier =
+ () -> {
+ supplierCalled.set(true);
+ return rackId;
+ };
+ Properties properties = new Properties();
+ createReader(
+ properties,
+ UnregisteredMetricsGroup.createSourceReaderMetricGroup(),
+ rackIdSupplier);
+ assertThat(supplierCalled.get()).isEqualTo(true);
+ }
+
+ @ParameterizedTest
+ @NullAndEmptySource
+ public void testSetConsumerClientRackIgnoresNullAndEmpty(String rackId) {
+ Properties properties = new Properties();
+ Supplier<String> rackIdSupplier = () -> rackId;
+ KafkaPartitionSplitReader reader =
+ createReader(
+ properties,
+
UnregisteredMetricsGroup.createSourceReaderMetricGroup(),
+ rackIdSupplier);
+ reader.setConsumerClientRack(properties, rackIdSupplier);
Review Comment:
If this call is not needed, you can make the implementation of
`setConsumerClientRack` private.
--
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]