kfaraz commented on code in PR #18194:
URL: https://github.com/apache/druid/pull/18194#discussion_r2182065314
##########
services/src/test/java/org/apache/druid/testing/embedded/EmbeddedResource.java:
##########
@@ -38,4 +38,14 @@ public interface EmbeddedResource
* Cleans up this resource.
*/
void stop() throws Exception;
+
+ /**
+ * Configures a cluster to use this resource. This method executes after the
resource has
+ * been started. It is intended for use by resources that are started before
any Druid
+ * services.
+ */
+ default void configureCluster(EmbeddedDruidCluster cluster)
Review Comment:
Nit: Suggested rename in the same vein as
`EmbeddedDruidServer.onAddedToCluster()`.
This name is also appropriate since it indicates when this method is called.
```suggestion
default void onStarted(EmbeddedDruidCluster cluster)
```
##########
extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/simulate/KafkaResourceTest.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.indexing.kafka.simulate;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class KafkaResourceTest
+{
+ @Test
+ @Timeout(60)
+ public void testKafka()
+ {
+ final KafkaResource resource = new KafkaResource();
+
+ resource.start();
+ assertTrue(resource.isRunning());
+
+ // Verify bootstrap server URL
+ final String bootstrapServerUrl = resource.getBootstrapServerUrl();
+ assertTrue(bootstrapServerUrl.contains(":"));
+
+ // Test producer properties
+ final var producerProps = resource.producerProperties();
+ assertEquals(bootstrapServerUrl, producerProps.get("bootstrap.servers"));
+ assertEquals("all", producerProps.get("acks"));
+ assertEquals("true", producerProps.get("enable.idempotence"));
+
+ // Test consumer properties
+ final var consumerProps = resource.consumerProperties();
Review Comment:
Nit: Maybe use `Map` type instead of `var` since we are anyway invoking
`.get()` on it in the subsequent lines.
##########
extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/simulate/KafkaResource.java:
##########
@@ -19,102 +19,48 @@
package org.apache.druid.indexing.kafka.simulate;
Review Comment:
I think we had missed renaming this package in the first PR. Let's rename
this to `kafka.embedded` or something.
##########
extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/simulate/KafkaResourceTest.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.druid.indexing.kafka.simulate;
+
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class KafkaResourceTest
+{
+ @Test
+ @Timeout(60)
+ public void testKafka()
+ {
+ final KafkaResource resource = new KafkaResource();
+
+ resource.start();
+ assertTrue(resource.isRunning());
+
+ // Verify bootstrap server URL
+ final String bootstrapServerUrl = resource.getBootstrapServerUrl();
+ assertTrue(bootstrapServerUrl.contains(":"));
+
+ // Test producer properties
+ final var producerProps = resource.producerProperties();
+ assertEquals(bootstrapServerUrl, producerProps.get("bootstrap.servers"));
+ assertEquals("all", producerProps.get("acks"));
+ assertEquals("true", producerProps.get("enable.idempotence"));
+
+ // Test consumer properties
+ final var consumerProps = resource.consumerProperties();
+ assertEquals(bootstrapServerUrl, consumerProps.get("bootstrap.servers"));
+
+ // Test topic creation
+ final String topicName = "test-topic";
+ resource.createTopicWithPartitions(topicName, 3);
+ resource.deleteTopic(topicName);
Review Comment:
Should we list topics before deleting to verify that the topic actually got
created?
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]