kfaraz commented on code in PR #18413:
URL: https://github.com/apache/druid/pull/18413#discussion_r2292943534
##########
embedded-tests/pom.xml:
##########
@@ -419,6 +461,17 @@
<excludedGroups>docker-test</excludedGroups>
</configuration>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
Review Comment:
This is not needed here since no other module needs to use the test jar of
`embedded-tests`.
If you need to use the test jar of some other module here, please move this
block in that module.
##########
embedded-tests/src/test/java/org/apache/druid/testing/embedded/k8s/K3sDruidService.java:
##########
@@ -36,20 +38,42 @@
*/
public class K3sDruidService
{
- private static final String MANIFEST_TEMPLATE =
"manifests/druid-service.yaml";
-
private final DruidCommand command;
private final Properties properties;
+ private boolean isGovernedByOperator = false;
+ private String manifestTemplate = "manifests/druid-service.yaml";
+ private Map<String, String> operatorVariablesTemplate = Map.of();
public K3sDruidService(DruidCommand command)
{
this.command = command;
this.properties = new Properties();
- addProperty("druid.host", EmbeddedHostname.containerFriendly().toString());
+ // Don't set druid.host here - it will be set when operator variables are
available
command.getDefaultProperties().forEach(properties::setProperty);
}
+ public K3sDruidService governWithOperator()
+ {
+ this.operatorVariablesTemplate = new
HashMap<>(command.getOperatorConfiguration());
+ this.isGovernedByOperator = true;
+ this.manifestTemplate = "manifests/druid-service-operator.yaml";
+ return this;
+ }
Review Comment:
Instead of doing this, pass in the template file to use and try to reuse the
template variables such as `${service}` etc.
##########
extensions-core/druid-testcontainers/src/main/java/org/apache/druid/testing/DruidCommand.java:
##########
@@ -56,6 +60,15 @@ enum Server implements DruidCommand
"druid.coordinator.period", "PT0.5S",
"druid.manager.segments.pollDuration", "PT0.1S"
),
+ 30000,
+ Map.of(
+ "node", "coordinators",
+ "druidServiceType", "coordinator",
+ "healthPath", "/status/health",
+ "readinessProbePath", "/status/health",
+ "sharedStorageDir", "/druid/shared-storage",
+ "metadataName", "test-cluster-coordinator"
+ ),
Review Comment:
It seems like we can skip these changes.
##########
extensions-core/druid-testcontainers/src/main/java/org/apache/druid/testing/DruidCommand.java:
##########
@@ -36,6 +36,10 @@ public interface DruidCommand
Map<String, String> getDefaultProperties();
+ Integer getExposedOperatorPort();
+
+ Map<String, String> getOperatorConfiguration();
Review Comment:
We shouldn't need to make any change to `DruidCommand` for the new tests.
##########
extensions-core/kubernetes-overlord-extensions/src/test/java/org/apache/druid/k8s/simulate/K3SResource.java:
##########
@@ -0,0 +1,331 @@
+/*
+ * 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.k8s.simulate;
+
+import com.github.dockerjava.api.DockerClient;
+import com.github.dockerjava.core.DefaultDockerClientConfig;
+import com.github.dockerjava.core.DockerClientImpl;
+import com.github.dockerjava.httpclient5.ApacheDockerHttpClient;
+import io.fabric8.kubernetes.client.Config;
+import io.fabric8.kubernetes.client.KubernetesClient;
+import io.fabric8.kubernetes.client.KubernetesClientBuilder;
+import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.apache.druid.java.util.common.FileUtils;
+import org.apache.druid.java.util.common.StringUtils;
+import org.apache.druid.java.util.common.logger.Logger;
+import org.apache.druid.testing.embedded.EmbeddedDruidCluster;
+import org.apache.druid.testing.embedded.TestFolder;
+import org.apache.druid.testing.embedded.TestcontainerResource;
+import org.testcontainers.k3s.K3sContainer;
+import org.testcontainers.utility.DockerImageName;
+import org.testcontainers.utility.MountableFile;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.attribute.PosixFilePermission;
+import java.time.Duration;
+import java.util.Set;
+import java.util.zip.GZIPInputStream;
+
+import static org.testcontainers.containers.BindMode.READ_WRITE;
+
+/**
+ * A K3s container for use in embedded tests.
+ */
+public class K3SResource extends TestcontainerResource<K3sContainer>
Review Comment:
This class can be removed since we already have `K3sClusterResource`.
--
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]