kfaraz commented on code in PR #18413: URL: https://github.com/apache/druid/pull/18413#discussion_r2295081876
########## embedded-tests/src/test/java/org/apache/druid/testing/embedded/k8s/K3sClusterWithOperatorResource.java: ########## @@ -0,0 +1,286 @@ +/* + * 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.k8s; + +import org.apache.commons.compress.archivers.tar.TarArchiveEntry; +import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; +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.docker.DruidContainerResource; +import org.apache.druid.testing.embedded.indexing.Resources; +import org.testcontainers.containers.Container; +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.attribute.PosixFilePermission; +import java.time.Duration; +import java.util.Properties; +import java.util.Set; +import java.util.zip.GZIPInputStream; + +public class K3sClusterWithOperatorResource extends K3sClusterResource +{ + private static final Logger log = new Logger(K3sClusterWithOperatorResource.class); + private static final String RBAC_MANIFEST = "manifests/druid-operator-rbac.yaml"; + private static final String OPERATOR_NAMESPACE_MANIFEST = "manifests/druid-operator-namespace.yaml"; + private static final String OPERATOR_NAMESPACE = "druid-operator-system"; + private static final String HELM_RELEASE_NAME = "druid-operator"; + private static final String HELM_REPO_NAME = "datainfra"; + private static final String HELM_REPO_URL = "https://charts.datainfra.io"; + private static final String HELM_CHART_NAME = "datainfra/druid-operator"; + private static final String HELM_VERSION = "v3.13.1"; + private static final String HELM_PLATFORM = "linux-amd64"; + private static final String HELM_MOUNT_PATH = "/usr/local/bin/helm"; + + + public K3sClusterWithOperatorResource() + { + super(); + manifestFiles.add(Resources.getFileForResource(RBAC_MANIFEST)); + manifestFiles.add(Resources.getFileForResource(OPERATOR_NAMESPACE_MANIFEST)); + } + + @Override + public K3sClusterWithOperatorResource usingTestImage() + { + return usingDruidImage(DruidContainerResource.getTestDruidImageName()); + } + + @Override + public K3sClusterWithOperatorResource usingDruidImage(String druidImageName) + { + super.usingDruidImage(druidImageName); + return this; + } + + @Override + public K3sClusterWithOperatorResource addService(K3sDruidService service) + { + super.addService(service); + return this; + } + + @Override + public void onStarted(EmbeddedDruidCluster cluster) + { + super.loadImageAndApplyClusterManifests(cluster); + installHelm(cluster); + setupOperatorWithHelm(); + super.waitUntilPodsAreReady(OPERATOR_NAMESPACE); + Properties clusterCommon = super.injectClusterCommonPropertiesToConfigMap(cluster); + Properties yamlCommonProperties = getCombinedCommonProperties(clusterCommon); + initializeDruidServices(yamlCommonProperties); + } + + private void initializeDruidServices(Properties properties) + { + for (K3sDruidService druidService : getServices()) { + applyManifest(druidService.withCommonProperties(properties)); + } + + waitUntilPodsAreReady(DRUID_NAMESPACE); + super.waitUntilServicesAreHealthy(); + } + + private Properties getCombinedCommonProperties(Properties properties) + { + Properties defaults = new Properties(); + defaults.setProperty("druid.metadata.storage.type", "derby"); + defaults.setProperty("druid.metadata.storage.connector.connectURI", "jdbc:derby://localhost:1527/var/druid/metadata.db;create=true"); + defaults.setProperty("druid.metadata.storage.connector.host", "localhost"); + defaults.setProperty("druid.metadata.storage.connector.port", "1527"); + defaults.setProperty("druid.metadata.storage.connector.createTables", "true"); Review Comment: Aren't we using PSql DB? -- 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]
