kfaraz commented on code in PR #18891:
URL: https://github.com/apache/druid/pull/18891#discussion_r2850814098


##########
embedded-tests/src/test/java/org/apache/druid/testing/embedded/docker/IngestionRollingUpgradeDockerTest.java:
##########
@@ -0,0 +1,278 @@
+/*
+ * 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.docker;
+
+import org.apache.druid.common.utils.IdUtils;
+import org.apache.druid.data.input.MaxSizeSplitHintSpec;
+import org.apache.druid.indexing.common.task.IndexTask;
+import org.apache.druid.indexing.common.task.TaskBuilder;
+import 
org.apache.druid.indexing.common.task.batch.parallel.ParallelIndexSupervisorTask;
+import org.apache.druid.java.util.common.StringUtils;
+import org.apache.druid.query.DruidMetrics;
+import org.apache.druid.query.http.SqlTaskStatus;
+import org.apache.druid.storage.s3.output.S3StorageConnectorModule;
+import org.apache.druid.testing.DruidCommand;
+import org.apache.druid.testing.DruidContainer;
+import org.apache.druid.testing.MountedDir;
+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.indexing.MoreResources;
+import org.apache.druid.testing.embedded.indexing.Resources;
+import org.apache.druid.testing.embedded.junit5.EmbeddedClusterTestBase;
+import org.apache.druid.testing.embedded.minio.MinIOStorageResource;
+import org.apache.druid.testing.embedded.msq.EmbeddedMSQApis;
+import org.apache.druid.testing.embedded.msq.MinIODurableStorageResource;
+import org.apache.druid.testing.embedded.psql.PostgreSQLMetadataResource;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Tests that ingestion works correctly during a rolling upgrade, where the
+ * cluster has a mix of old-version and new-version indexers (the assumption 
is that job logic is shared betwen indexers and MM/Peons, indexers are just 
easier to use in tests).
+ * Validates that segments and intermediate shuffle data written to S3 by one 
version can be
+ * read by the other.
+ * <p>
+ * Use this test to verify rolling upgrade safety for any change that affects
+ * how data is written to or read from deep storage or MSQ durable shuffle
+ * storage (e.g. storage format changes, SDK upgrades, serialization changes).
+ * <p>
+ * <h3>Cluster architecture</h3>
+ * <ul>
+ * <li>Overlord, Coordinator, Broker, Historical, Indexer (new) -- embedded 
(current version)</li>
+ * <li>Indexer (old) -- Docker container ({@link 
DruidContainer.Image#APACHE_33})</li>
+ * <li>Deep Storage + MSQ Shuffle -- MinIO (S3-compatible)</li>
+ * <li>Metadata -- PostgreSQL (required for Docker container access)</li>
+ * </ul>
+ *
+ * <h3>Task distribution guarantees</h3>
+ * The Overlord uses {@code EqualDistributionWorkerSelectStrategy} by default,
+ * which assigns each task to the worker with the most available capacity.
+ * Both indexers are configured with capacity 2 (4 total slots).
+ * <ul>
+ * <li><b>Native batch ({@code index})</b>: Two IndexTasks are submitted
+ *     concurrently to separate datasources. The first task reduces one
+ *     indexer's available capacity, so the second is assigned to the other
+ *     indexer.</li>
+ * <li><b>Native batch ({@code index_parallel})</b>: The supervisor task
+ *     occupies one slot, then 3 subtasks (one per input file) are submitted.
+ *     With 3 remaining slots across 2 indexers, subtasks are guaranteed to
+ *     land on both.</li>
+ * <li><b>MSQ</b>: With {@code maxNumTasks=3} (1 controller + 2 workers), the
+ *     controller task fills one slot, so the two worker tasks are distributed
+ *     across both indexers. This guarantees cross-version S3 shuffle I/O.</li>
+ * </ul>
+ * <p>
+ * This test does not implement {@link LatestImageDockerTest} and runs in the
+ * {@code mvn test} phase.
+ */
+public class IngestionRollingUpgradeDockerTest extends EmbeddedClusterTestBase
+{
+  private final EmbeddedOverlord overlord = new EmbeddedOverlord();
+  private final EmbeddedBroker broker = new EmbeddedBroker();
+
+  private final EmbeddedIndexer embeddedIndexer = new EmbeddedIndexer();
+
+  private final MinIOStorageResource storageResource = new 
MinIOStorageResource();
+  private final MinIODurableStorageResource durableStorageResource =
+      new MinIODurableStorageResource(storageResource);
+
+  /**
+   * Datasources created during a test, cleaned up in {@link #cleanUp()}.
+   */
+  private final List<String> createdDataSources = new ArrayList<>();
+
+  @Override
+  public EmbeddedDruidCluster createCluster()
+  {
+    // Use port 7091 for the embedded indexer to avoid conflict with Docker 
INDEXER on 8091
+    embeddedIndexer
+        .setServerMemory(300_000_000)
+        .addProperty("druid.plaintextPort", "7091")
+        .addProperty("druid.worker.capacity", "2")
+        .addProperty("druid.segment.handoff.pollDuration", "PT0.1s");
+
+    // Mount the test data directory so the Docker indexer can read local 
input files
+    // at the same absolute paths used by the embedded indexer.
+    final File testDataDir = 
Resources.DataFile.tinyWiki1Json().getParentFile();
+    final MountedDir testDataMount = new MountedDir(testDataDir, testDataDir);
+
+    DruidContainerResource containerIndexer = new 
DruidContainerResource(DruidCommand.Server.INDEXER)
+        .usingImage(DruidContainer.Image.APACHE_33)
+        .addMount(testDataMount);
+
+    return EmbeddedDruidCluster
+        .withZookeeper()
+        .useContainerFriendlyHostname()
+        .useLatchableEmitter()
+        .useDefaultTimeoutForLatchableEmitter(60)
+        .addExtensions(S3StorageConnectorModule.class)
+        .addResource(new PostgreSQLMetadataResource())

Review Comment:
   you could probably get away with the embedded Derby itself since coordinator 
and overlord are still embedded.



-- 
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]

Reply via email to