You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "jeremy-degroot (via GitHub)" <gi...@apache.org> on 2023/04/07 13:55:29 UTC

[GitHub] [flink-connector-kafka] jeremy-degroot commented on a diff in pull request #20: [FLINK-29398][connector/kafka] Provide rack ID to Kafka Source to take advantage of Rack Awareness

jeremy-degroot commented on code in PR #20:
URL: https://github.com/apache/flink-connector-kafka/pull/20#discussion_r1160718505


##########
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:
   As far as I know, neither the KafkaConsumer nor the KafkaPartitionSplitReader offers any way to examine the final consumer Properties, so to test the behavior of setConsumerClientRack we have to test it directly.



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org