kfaraz commented on code in PR #18235:
URL: https://github.com/apache/druid/pull/18235#discussion_r2202448602
##########
embedded-tests/src/test/java/org/apache/druid/testing/embedded/msq/EmbeddedMSQApis.java:
##########
@@ -130,4 +159,33 @@ public MSQTaskReportPayload runTaskSql(String sql,
Object... args)
return taskReportPayload;
}
+
+ public void expectTaskFailure(String sql, String reason, Object... args)
Review Comment:
+1
##########
embedded-tests/src/test/java/org/apache/druid/testing/embedded/msq/EmbeddedMSQRealtimeQueryTest.java:
##########
@@ -141,12 +163,38 @@ public EmbeddedDruidCluster createCluster()
.addResource(kafka)
.addServer(coordinator)
.addServer(overlord)
- .addServer(indexer)
- .addServer(broker)
- .addServer(historical)
.addServer(router);
}
+ @BeforeAll
+ @Override
+ protected void setup() throws Exception
+ {
+ cluster = createCluster();
+ cluster.start();
+
+ // Initialize lookups
+ cluster.callApi().onLeaderCoordinator(
+ c -> c.updateAllLookups(Map.of())
+ );
+
+ final String lookupPayload = StringUtils.format(
+ BULK_UPDATE_LOOKUP_PAYLOAD,
+ LOOKUP_TABLE
+ );
+ cluster.callApi().onLeaderCoordinator(
+ c ->
c.updateAllLookups(EmbeddedClusterApis.deserializeJsonToMap(lookupPayload))
+ );
+
+ // Initialize the broker/data-servers later so that lookups are loaded on
startup.
+ cluster.addServer(broker);
+ broker.start();
+ cluster.addServer(indexer);
+ indexer.start();
+ cluster.addServer(historical);
+ historical.start();
Review Comment:
Nit: You could chain up the `addServer` calls.
##########
embedded-tests/src/test/java/org/apache/druid/testing/embedded/msq/EmbeddedMSQRealtimeQueryTest.java:
##########
@@ -141,12 +163,38 @@ public EmbeddedDruidCluster createCluster()
.addResource(kafka)
.addServer(coordinator)
.addServer(overlord)
- .addServer(indexer)
- .addServer(broker)
- .addServer(historical)
.addServer(router);
}
+ @BeforeAll
+ @Override
+ protected void setup() throws Exception
+ {
+ cluster = createCluster();
+ cluster.start();
Review Comment:
Alternatively, you can add a fresh `@BeforeAll` method named
`initializeLookupsAndAddServers()` or similar.
The `@BeforeAll` of the super class will always run before this one.
##########
embedded-tests/src/test/java/org/apache/druid/testing/embedded/msq/EmbeddedMSQRealtimeUnnestQueryTest.java:
##########
@@ -0,0 +1,312 @@
+/*
+ * 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.testing.embedded.msq;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import it.unimi.dsi.fastutil.bytes.ByteArrays;
+import org.apache.druid.data.input.impl.DimensionsSpec;
+import org.apache.druid.data.input.impl.JsonInputFormat;
+import org.apache.druid.data.input.impl.TimestampSpec;
+import org.apache.druid.frame.testutil.FrameTestUtil;
+import org.apache.druid.indexer.TaskStatusPlus;
+import org.apache.druid.indexer.granularity.UniformGranularitySpec;
+import org.apache.druid.indexing.kafka.KafkaIndexTaskModule;
+import org.apache.druid.indexing.kafka.simulate.KafkaResource;
+import org.apache.druid.indexing.kafka.supervisor.KafkaSupervisorIOConfig;
+import org.apache.druid.indexing.kafka.supervisor.KafkaSupervisorSpec;
+import org.apache.druid.java.util.common.StringUtils;
+import org.apache.druid.java.util.common.granularity.Granularities;
+import org.apache.druid.java.util.common.parsers.CloseableIterator;
+import org.apache.druid.msq.dart.guice.DartControllerMemoryManagementModule;
+import org.apache.druid.msq.dart.guice.DartControllerModule;
+import org.apache.druid.msq.dart.guice.DartWorkerMemoryManagementModule;
+import org.apache.druid.msq.dart.guice.DartWorkerModule;
+import org.apache.druid.msq.guice.IndexerMemoryManagementModule;
+import org.apache.druid.msq.guice.MSQDurableStorageModule;
+import org.apache.druid.msq.guice.MSQIndexingModule;
+import org.apache.druid.msq.guice.MSQSqlModule;
+import org.apache.druid.msq.guice.SqlTaskModule;
+import org.apache.druid.msq.indexing.report.MSQTaskReportPayload;
+import org.apache.druid.query.DruidMetrics;
+import org.apache.druid.segment.QueryableIndexCursorFactory;
+import org.apache.druid.segment.TestHelper;
+import org.apache.druid.segment.TestIndex;
+import org.apache.druid.segment.column.RowSignature;
+import org.apache.druid.segment.indexing.DataSchema;
+import org.apache.druid.sql.calcite.BaseCalciteQueryTest;
+import org.apache.druid.testing.embedded.EmbeddedBroker;
+import org.apache.druid.testing.embedded.EmbeddedClusterApis;
+import org.apache.druid.testing.embedded.EmbeddedCoordinator;
+import org.apache.druid.testing.embedded.EmbeddedDruidCluster;
+import org.apache.druid.testing.embedded.EmbeddedHistorical;
+import org.apache.druid.testing.embedded.EmbeddedIndexer;
+import org.apache.druid.testing.embedded.EmbeddedOverlord;
+import org.apache.druid.testing.embedded.EmbeddedRouter;
+import org.apache.druid.testing.embedded.junit5.EmbeddedClusterTestBase;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.joda.time.Period;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Timeout;
+
+import java.io.IOException;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ExecutionException;
+
+public class EmbeddedMSQRealtimeUnnestQueryTest extends EmbeddedClusterTestBase
Review Comment:
+1,
We should use a `BaseRealtimeQueryTest` to contain the common setup as well
as tests, if any.
I would have liked to move the `createKafkaSupervisor()` method (with
adequate args) to `EmbeddedClusterApis`, but the latter is in the
`druid-services` module.
So, for the time being, we should move it to `Resources` instead.
As we migrate old ITs to the embedded framework, the builders and helper
functions will take more concrete shape.
e.g. A `TaskBuilder` is being added in [PR
#18207](https://github.com/apache/druid/pull/18207/files#diff-75d04ca7e0b706c5dbbad63c1441cbebb6edbf47c988bbcf1cfd2f7a0f4dc559)
##########
services/src/test/java/org/apache/druid/testing/embedded/EmbeddedClusterApis.java:
##########
@@ -116,6 +116,20 @@ public void waitForTaskToSucceed(String taskId,
EmbeddedOverlord overlord)
verifyTaskHasStatus(taskId, TaskStatus.success(taskId));
}
+ /**
+ * Waits for the given task to fail, with the given errorMsq. If the given
+ * {@link EmbeddedOverlord} is not the leader, this method can only return by
+ * throwing an exception upon timeout.
+ */
+ public void waitForTaskToFail(String taskId, String errorMsg,
EmbeddedOverlord overlord)
Review Comment:
I think `waitForTaskToFail` feels like a weird condition to check anyway.
`waitForTaskToSucceed` is a much more common (and constructive) condition
that is required by many tests.
As suggested by @gianm in other comments that we should make things
composable,
this method should probably just be `waitForTaskToFinish`.
The verification of the actual task status and error message can be done in
the calling test itself using matchers.
If a similar assertion needs to be done in multiple places in the test, I
would still prefer it if we add a method `waitForTaskToFail` in that test
rather than here.
--
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]