MisterRaindrop commented on code in PR #91:
URL: https://github.com/apache/cloudberry-pxf/pull/91#discussion_r3020974244


##########
automation/src/main/resources/testcontainers/pxf-cbdb/Dockerfile:
##########
@@ -0,0 +1,79 @@
+# --------------------------------------------------------------------
+#
+# 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.
+#
+# --------------------------------------------------------------------
+ARG BASE_IMAGE=apache/incubator-cloudberry:cbdb-build-ubuntu22.04-latest
+FROM ${BASE_IMAGE}
+
+# Install Java 8 & 11: auto-detect OS package manager
+RUN if command -v apt-get >/dev/null 2>&1; then \
+      export DEBIAN_FRONTEND=noninteractive && \
+      sudo apt-get update && \
+      sudo apt-get install -y --no-install-recommends \
+        curl ca-certificates git unzip maven make \
+        locales wget lsb-release openssh-server iproute2 sudo \
+        openjdk-11-jdk-headless; \
+    elif command -v dnf >/dev/null 2>&1; then \
+      sudo dnf install -y --allowerasing \
+        curl ca-certificates wget maven unzip openssh-server iproute sudo 
glibc-langpack-en glibc-locale-source \
+        java-11-openjdk-devel && \
+      sudo dnf clean all; \
+    fi
+
+# Install Gradle and warm wrapper cache (it will download GRADLE_VERSION again)
+# (version must match server/gradle/wrapper/gradle-wrapper.properties)
+ARG GRADLE_VERSION=7.6.6
+RUN curl -fsSL 
"https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip"; \
+      -o /tmp/gradle.zip && \
+    sudo unzip -q /tmp/gradle.zip -d /opt && \
+    sudo ln -s "/opt/gradle-${GRADLE_VERSION}/bin/gradle" 
/usr/local/bin/gradle && \
+    rm /tmp/gradle.zip
+RUN cd /tmp && gradle init && gradle wrapper --gradle-version 
${GRADLE_VERSION} && ./gradlew javaToolchains
+RUN rm -rf /tmp/gradle /tmp/gradlew /tmp/gradlew.bat /tmp/.gradle
+ENV GRADLE_HOME="/opt/gradle-${GRADLE_VERSION}"
+
+# Go toolchain for building pxf_regress inside the container
+ARG GO_VERSION=1.21.13
+RUN ARCH=$(uname -m) && \
+    case "$ARCH" in \
+      x86_64) GARCH=amd64 ;; \
+      aarch64|arm64) GARCH=arm64 ;; \
+      *) echo "unsupported arch: $ARCH" >&2; exit 1 ;; \
+    esac && \
+    curl -fsSL "https://go.dev/dl/go${GO_VERSION}.linux-${GARCH}.tar.gz"; -o 
/tmp/go.tgz && \
+    sudo rm -rf /usr/local/go && \
+    sudo tar -C /usr/local -xzf /tmp/go.tgz && \
+    rm /tmp/go.tgz
+ENV PATH="/usr/local/go/bin:${PATH}"
+
+# Env vars that scripts expect
+ENV GPHD_ROOT=/home/gpadmin/workspace/singlecluster
+ENV GPHOME=/usr/local/cloudberry-db
+
+RUN sudo mkdir -p /home/gpadmin/workspace && \
+    sudo chown -R gpadmin:gpadmin /home/gpadmin/workspace
+
+# Clone Cloudberry source (parametrized via build args)
+ARG CLOUDBERRY_REPO=https://github.com/apache/cloudberry.git
+ARG CLOUDBERRY_BRANCH=main
+RUN git clone --depth 1 -b ${CLOUDBERRY_BRANCH} \
+      ${CLOUDBERRY_REPO} /home/gpadmin/workspace/cloudberry
+
+# Copy and run the build script (demo cluster is created at runtime)
+COPY script/build_cloudberrry.sh /tmp/build_cloudberrry.sh

Review Comment:
   file name build_cloudberrry.sh ? rrr?



##########
automation/pom.xml:
##########
@@ -262,19 +292,19 @@
         <dependency>
             <groupId>com.fasterxml.jackson.core</groupId>
             <artifactId>jackson-core</artifactId>
-            <version>2.14.3</version>
+            <version>2.20.2</version>
         </dependency>
 
         <dependency>
             <groupId>com.fasterxml.jackson.core</groupId>
             <artifactId>jackson-databind</artifactId>
-            <version>2.14.3</version>
+            <version>2.20.2</version>
         </dependency>
 
         <dependency>
             <groupId>com.fasterxml.jackson.core</groupId>
             <artifactId>jackson-annotations</artifactId>
-            <version>2.14.3</version>
+            <version>2.20</version>

Review Comment:
   jackson-annotations jackson-databind 2.20 2.20.2? Wouldn't it be better to 
unify?



##########
.github/workflows/pxf-ci.yml:
##########
@@ -541,10 +574,130 @@ jobs:
           exit 1
         fi
 
+
+  # Stage 2c: Testcontainers-based tests
+  pxf-testcontainer-test:
+    name: "TC Test - ${{ matrix.tc_group }} (${{ matrix.use_fdw == 'true' && 
'fdw' || 'external-table' }}, ${{ matrix.distro }})"
+    needs: [build-pxf-cbdb-testcontainer-image]
+    runs-on: ubuntu-latest
+    strategy:
+      fail-fast: false
+      matrix:
+        include:
+          - tc_group: pxf-jdbc
+            use_fdw: "false"

Review Comment:
   why no test_mode?



##########
automation/src/main/java/org/apache/cloudberry/pxf/automation/testcontainers/PXFCloudberryContainer.java:
##########
@@ -0,0 +1,245 @@
+package org.apache.cloudberry.pxf.automation.testcontainers;
+
+/*
+ * 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.
+ */
+
+import com.github.dockerjava.api.DockerClient;
+import com.github.dockerjava.api.async.ResultCallback;
+import com.github.dockerjava.api.command.ExecCreateCmdResponse;
+import com.github.dockerjava.api.model.Frame;
+import org.testcontainers.DockerClientFactory;
+import org.testcontainers.containers.BindMode;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.Network;
+import org.testcontainers.containers.wait.strategy.AbstractWaitStrategy;
+import org.testcontainers.containers.wait.strategy.Wait;
+import org.testcontainers.utility.DockerImageName;
+import org.testcontainers.utility.MountableFile;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.LinkOption;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.time.Duration;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * PXF + Cloudberry colocated testcontainer.
+ *
+ * Cloudberry is built during image creation.
+ * Demo cluster and PXF are initialised at runtime via {@code entrypoint.sh}.
+ *
+ * Use {@link #getInstance()} to get a singleton that is started once per
+ * automation JVM. The container shares a Docker {@link Network} with other
+ * test containers so they can communicate by hostname.
+ */
+public class PXFCloudberryContainer extends 
GenericContainer<PXFCloudberryContainer> {
+
+    private static final Map<String, String> BASE_IMAGES = new HashMap<>();
+    static {
+        BASE_IMAGES.put("ubuntu", 
"apache/incubator-cloudberry:cbdb-build-ubuntu22.04-latest");
+        BASE_IMAGES.put("rocky9", 
"apache/incubator-cloudberry:cbdb-build-rocky9-latest");
+    }
+
+    public static final int CLOUDBERRY_PORT = 7000;
+    public static final int PXF_PORT = 5888;
+    public static final String CLOUDBERRY_USER = "gpadmin";
+
+    private static final String CONTAINER_GRADLE_RO_CACHE = 
"/home/gpadmin/.gradle-host-cache";
+    private static final String CONTAINER_REPO_DIR = 
"/home/gpadmin/workspace/cloudberry-pxf";

Review Comment:
   Just a suggestion. Wouldn't a relative path be better?



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