Răsfoiți Sursa

[8.19] [CI] Handle git snapshot BWC versions correctly when calculating jdk fallback (#135399) (#135411)

* [CI] Handle git snapshot BWC versions correctly when calculating jdk fallback (#135399)

In https://github.com/elastic/elasticsearch/pull/135300 we introduced a fallback to
use adoptopenjdk17 when running bwc tests with older distributions.
This fix handles the calculation of overriding requirement by taken 0.0.0 version into account
which is used to represent versions representing git snapshots.

(cherry picked from commit 6047a74b44ff49ba0e96d36eab9f39a0b6a42577)

# Conflicts:
#	build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionDownloadPlugin.java

* Fix typo
Rene Groeschke 2 săptămâni în urmă
părinte
comite
65a3e33518

+ 1 - 1
build-tools/src/main/java/org/elasticsearch/gradle/util/OsUtils.java

@@ -38,7 +38,7 @@ public final class OsUtils {
       * This method returns true if the given version of the JDK is known to be incompatible
       */
     public static boolean jdkIsIncompatibleWithOS(Version version) {
-        return version.onOrBefore("8.10.4") && isUbuntu2404OrLater();
+        return version.after("0.0.0") && version.onOrBefore("8.10.4") && isUbuntu2404OrLater();
     }
 
     private static boolean isUbuntu2404OrLater() {

+ 6 - 2
test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalClusterFactory.java

@@ -82,7 +82,7 @@ public abstract class AbstractLocalClusterFactory<S extends LocalClusterSpec, H
     private static final String ENABLE_DEBUG_JVM_ARGS = "-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=";
     private static final String ENTITLEMENT_POLICY_YAML = "entitlement-policy.yaml";
     private static final String PLUGIN_DESCRIPTOR_PROPERTIES = "plugin-descriptor.properties";
-    public static final String DISTRO_WITH_JDK_LOWER_21 = "8.11.0";
+    public static final String FIRST_DISTRO_WITH_JDK_21 = "8.11.0";
 
     private final DistributionResolver distributionResolver;
 
@@ -869,7 +869,7 @@ public abstract class AbstractLocalClusterFactory<S extends LocalClusterSpec, H
         private Map<String, String> getEnvironmentVariables() {
             Map<String, String> environment = new HashMap<>(spec.resolveEnvironment());
             String esFallbackJavaHome = System.getenv("ES_FALLBACK_JAVA_HOME");
-            if (spec.getVersion().before(DISTRO_WITH_JDK_LOWER_21) && esFallbackJavaHome != null && esFallbackJavaHome.isEmpty() == false) {
+            if (jdkIsIncompatible(spec.getVersion()) && esFallbackJavaHome != null && esFallbackJavaHome.isEmpty() == false) {
                 environment.put("ES_JAVA_HOME", esFallbackJavaHome);
             }
             environment.put("ES_PATH_CONF", configDir.toString());
@@ -922,6 +922,10 @@ public abstract class AbstractLocalClusterFactory<S extends LocalClusterSpec, H
             return environment;
         }
 
+        private boolean jdkIsIncompatible(Version version) {
+            return version.after("0.0.0") && version.before(FIRST_DISTRO_WITH_JDK_21);
+        }
+
         private record ReplacementKey(String key, String fallback) {
             ReplacementKey {
                 assert fallback == null || fallback.isEmpty() == false; // no empty fallback, which would match anything