This is an automated email from the ASF dual-hosted git repository.

dsmiley pushed a commit to branch branch_10x
in repository https://gitbox.apache.org/repos/asf/solr.git

commit 0bb717d9e7c57613de48317bf91d00c27d9aabeb
Author: Sudip Roy <[email protected]>
AuthorDate: Mon Nov 16 19:16:14 2026 +0530

    build/tests: Improve s390x Compatibility  (#5268)
    
    Not all Docker containers support IBM s390x, so check.
    
    (cherry picked from commit deb45188b1c757cd712ff80064ad6ad4f7f8ece7)
---
 gradle/solr/solr-ui.gradle                         | 32 ++++++---
 .../solr/crossdc/manager/KafkaContainerRule.java   |  6 +-
 .../extraction/TikaServerContainerRule.java        |  8 +--
 .../org/apache/solr/s3/S3MockContainerRule.java    |  6 +-
 solr/test-framework/build.gradle                   |  1 +
 .../org/apache/solr/util/TestcontainersUtil.java   | 77 ++++++++++++++++++++++
 6 files changed, 107 insertions(+), 23 deletions(-)

diff --git a/gradle/solr/solr-ui.gradle b/gradle/solr/solr-ui.gradle
index 18cfdc3e19b..e66e7e1b90f 100644
--- a/gradle/solr/solr-ui.gradle
+++ b/gradle/solr/solr-ui.gradle
@@ -22,16 +22,20 @@
 import java.security.MessageDigest
 import org.gradle.tooling.GradleConnector
 
-def uiProps = new Properties()
-// gradle.properties is generated on demand (by gradlew) and gitignored, so it 
may not exist yet,
-// e.g. when this build is evaluated as an includeBuild from a consuming 
composite build. Fall back
-// to the tracked template, which carries the same real pinned defaults, 
rather than forcing that
-// generation step (or a build-from-source fallback) just to read them.
-def uiPropsFile = file("$rootDir/gradle.properties")
-if (!uiPropsFile.exists()) {
-  uiPropsFile = file("$rootDir/gradle/template.gradle.properties")
+def loadProps = { File f ->
+  def props = new Properties()
+  if (f.exists()) {
+    f.withInputStream {props.load(it)}
+  }
+  return props
+}
+def uiProps = loadProps(file("$rootDir/gradle.properties"))
+// gradle.properties is generated and gitignored, so it may be absent (e.g. an 
includeBuild) or lack
+// the solr.ui.* keys (e.g. a CI-provided copy). Then take the pinned commit 
and checksum from the
+// tracked template, together, so a checksum is never paired with a commit it 
doesn't belong to.
+if (!uiProps.getProperty('solr.ui.commit')) {
+  uiProps = loadProps(file("$rootDir/gradle/template.gradle.properties"))
 }
-uiPropsFile.withInputStream {uiProps.load(it)}
 
 def buildFromSource = project.hasProperty('solr.ui.buildFromSource') &&
     project.property('solr.ui.buildFromSource') == 'true'
@@ -133,6 +137,16 @@ tasks.register('buildUiFromSource') {
   inputs.dir(file("$rootDir/ui/shared/src"))
   inputs.dir(file("$rootDir/ui/webApp/src"))
   outputs.dir(uiFromSourceOutputDir)
+  doFirst {
+    // The source build resolves Compose Desktop's per-platform native 
libraries, which have no
+    // s390x variant. The published wasm artifact is platform independent, so 
use that instead.
+    if ("s390x".equalsIgnoreCase(System.getProperty("os.arch"))) {
+      throw new GradleException(
+          "Building the Admin UI from source is not supported on s390x; " +
+              "drop -Psolr.ui.buildFromSource=true to use the published 
artifact."
+      )
+    }
+  }
   doLast {
     def connector = GradleConnector.newConnector()
         .forProjectDirectory(file("$rootDir/ui"))
diff --git 
a/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/KafkaContainerRule.java
 
b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/KafkaContainerRule.java
index 0ec73d2e18b..f162fdf7199 100644
--- 
a/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/KafkaContainerRule.java
+++ 
b/solr/cross-dc-manager/src/test/org/apache/solr/crossdc/manager/KafkaContainerRule.java
@@ -18,11 +18,11 @@
 package org.apache.solr.crossdc.manager;
 
 import java.lang.invoke.MethodHandles;
+import org.apache.solr.util.TestcontainersUtil;
 import org.junit.Assume;
 import org.junit.rules.ExternalResource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.testcontainers.DockerClientFactory;
 import org.testcontainers.kafka.KafkaContainer;
 import org.testcontainers.utility.DockerImageName;
 
@@ -44,9 +44,7 @@ public class KafkaContainerRule extends ExternalResource {
 
   @Override
   protected void before() {
-    Assume.assumeTrue(
-        "Docker/Testcontainers not available; skipping test",
-        DockerClientFactory.instance().isDockerAvailable());
+    TestcontainersUtil.assumeContainerAvailable(KAFKA_DOCKER_IMAGE);
     kafkaContainer = new 
KafkaContainer(DockerImageName.parse(KAFKA_DOCKER_IMAGE));
     kafkaContainer.start();
   }
diff --git 
a/solr/modules/extraction/src/test/org/apache/solr/handler/extraction/TikaServerContainerRule.java
 
b/solr/modules/extraction/src/test/org/apache/solr/handler/extraction/TikaServerContainerRule.java
index 7a6ae393799..f740f6dfcca 100644
--- 
a/solr/modules/extraction/src/test/org/apache/solr/handler/extraction/TikaServerContainerRule.java
+++ 
b/solr/modules/extraction/src/test/org/apache/solr/handler/extraction/TikaServerContainerRule.java
@@ -17,11 +17,11 @@
 package org.apache.solr.handler.extraction;
 
 import java.lang.invoke.MethodHandles;
+import org.apache.solr.util.TestcontainersUtil;
 import org.junit.Assume;
 import org.junit.rules.ExternalResource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.testcontainers.DockerClientFactory;
 import org.testcontainers.containers.GenericContainer;
 import org.testcontainers.containers.wait.strategy.Wait;
 
@@ -46,11 +46,7 @@ public class TikaServerContainerRule extends 
ExternalResource {
   @Override
   @SuppressWarnings("resource")
   protected void before() {
-    Assume.assumeFalse(
-        "Skipping on s390x", 
"s390x".equalsIgnoreCase(System.getProperty("os.arch")));
-    Assume.assumeTrue(
-        "Docker/Testcontainers not available; skipping test",
-        DockerClientFactory.instance().isDockerAvailable());
+    TestcontainersUtil.assumeContainerAvailable(TIKA_DOCKER_IMAGE);
 
     tika =
         new GenericContainer<>(TIKA_DOCKER_IMAGE)
diff --git 
a/solr/modules/s3-repository/src/test/org/apache/solr/s3/S3MockContainerRule.java
 
b/solr/modules/s3-repository/src/test/org/apache/solr/s3/S3MockContainerRule.java
index 216483e8edf..2389a08e2a9 100644
--- 
a/solr/modules/s3-repository/src/test/org/apache/solr/s3/S3MockContainerRule.java
+++ 
b/solr/modules/s3-repository/src/test/org/apache/solr/s3/S3MockContainerRule.java
@@ -20,11 +20,11 @@ package org.apache.solr.s3;
 import com.adobe.testing.s3mock.testcontainers.S3MockContainer;
 import java.lang.invoke.MethodHandles;
 import java.net.URI;
+import org.apache.solr.util.TestcontainersUtil;
 import org.junit.Assume;
 import org.junit.rules.ExternalResource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.testcontainers.DockerClientFactory;
 import org.testcontainers.utility.DockerImageName;
 import software.amazon.awssdk.auth.credentials.AwsBasicCredentials;
 import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider;
@@ -56,9 +56,7 @@ public class S3MockContainerRule extends ExternalResource {
 
   @Override
   protected void before() {
-    Assume.assumeTrue(
-        "Docker/Testcontainers not available; skipping test",
-        DockerClientFactory.instance().isDockerAvailable());
+    TestcontainersUtil.assumeContainerAvailable(S3MOCK_DOCKER_IMAGE);
     s3MockContainer =
         new S3MockContainer(DockerImageName.parse(S3MOCK_DOCKER_IMAGE))
             .withInitialBuckets(bucketName);
diff --git a/solr/test-framework/build.gradle b/solr/test-framework/build.gradle
index ff9e87339db..09710f614d8 100644
--- a/solr/test-framework/build.gradle
+++ b/solr/test-framework/build.gradle
@@ -86,6 +86,7 @@ dependencies {
   implementation libs.carrotsearch.randomizedtesting.runner
   implementation libs.junit.junit
   implementation libs.hamcrest.hamcrest
+  implementation libs.testcontainers
 
   implementation(libs.prometheus.metrics.expositionformats, {
     exclude group: "io.prometheus", module: 
"prometheus-metrics-shaded-protobuf"
diff --git 
a/solr/test-framework/src/java/org/apache/solr/util/TestcontainersUtil.java 
b/solr/test-framework/src/java/org/apache/solr/util/TestcontainersUtil.java
new file mode 100644
index 00000000000..35f0b373020
--- /dev/null
+++ b/solr/test-framework/src/java/org/apache/solr/util/TestcontainersUtil.java
@@ -0,0 +1,77 @@
+/*
+ * 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.solr.util;
+
+import com.github.dockerjava.api.command.PullImageResultCallback;
+import java.lang.invoke.MethodHandles;
+import java.util.concurrent.TimeUnit;
+import org.junit.Assume;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.DockerClientFactory;
+
+/** Utility methods for Testcontainers-based tests. */
+public final class TestcontainersUtil {
+
+  private static final Logger log = 
LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+  private static final String S390X = "s390x";
+  private static final long S390X_PULL_TIMEOUT_MINUTES = 5;
+
+  private TestcontainersUtil() {}
+
+  /**
+   * Asserts that Docker/Testcontainers is available in the current 
environment and that the
+   * specified image has a platform variant compatible with the current 
architecture (specifically
+   * verifying on s390x). If either check fails, the calling test is skipped 
via {@link Assume}.
+   *
+   * @param dockerImage the Docker image to check
+   */
+  public static void assumeContainerAvailable(String dockerImage) {
+    Assume.assumeTrue(
+        "Docker/Testcontainers not available; skipping test",
+        DockerClientFactory.instance().isDockerAvailable());
+    if (S390X.equalsIgnoreCase(System.getProperty("os.arch"))) {
+      Assume.assumeTrue(
+          dockerImage + " has no s390x variant; skipping test", 
hasS390xVariant(dockerImage));
+    }
+  }
+
+  /**
+   * Whether the image can be pulled for s390x, i.e. its registry manifest 
lists that platform.
+   *
+   * @param dockerImage the Docker image name
+   * @return true if the image can be pulled for s390x, false otherwise
+   */
+  public static boolean hasS390xVariant(String dockerImage) {
+    try {
+      return DockerClientFactory.instance()
+          .client()
+          .pullImageCmd(dockerImage)
+          .withPlatform("linux/" + S390X)
+          .exec(new PullImageResultCallback())
+          .awaitCompletion(S390X_PULL_TIMEOUT_MINUTES, TimeUnit.MINUTES);
+    } catch (InterruptedException e) {
+      Thread.currentThread().interrupt();
+      return false;
+    } catch (RuntimeException e) {
+      log.info("Could not pull {} for {}: {}", dockerImage, S390X, 
e.toString());
+      return false;
+    }
+  }
+}

Reply via email to