Skip to content

Commit 47efc35

Browse files
committed
[CI] Handle git snapshot BWC versions correctly when calculating jdk fallback (elastic#135399)
In elastic#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 6047a74) # Conflicts: # build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionDownloadPlugin.java
1 parent 35a8c5d commit 47efc35

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

build-tools/src/integTest/groovy/org/elasticsearch/gradle/TestClustersPluginFuncTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ class TestClustersPluginFuncTest extends AbstractGradleFuncTest {
250250

251251
buildFile << """
252252
testClusters {
253-
myCluster {
253+
myCluster1 {
254254
testDistribution = 'default'
255255
version = '8.10.4'
256256
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ private OsUtils() {}
3838
* This method returns true if the given version of the JDK is known to be incompatible
3939
*/
4040
public static boolean jdkIsIncompatibleWithOS(Version version) {
41-
return version.onOrBefore("8.10.4") && isUbuntu2404OrLater();
41+
return version.after("0.0.0") && version.onOrBefore("8.10.4") && isUbuntu2404OrLater();
4242
}
4343

4444
private static boolean isUbuntu2404OrLater() {

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public abstract class AbstractLocalClusterFactory<S extends LocalClusterSpec, H
8282
private static final String ENABLE_DEBUG_JVM_ARGS = "-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=";
8383
private static final String ENTITLEMENT_POLICY_YAML = "entitlement-policy.yaml";
8484
private static final String PLUGIN_DESCRIPTOR_PROPERTIES = "plugin-descriptor.properties";
85-
public static final String DISTRO_WITH_JDK_LOWER_21 = "8.11.0";
85+
public static final String FIRST_DISTRO_WITH_JDK_21 = "8.11.0";
8686

8787
private final DistributionResolver distributionResolver;
8888

@@ -869,7 +869,7 @@ private void startElasticsearch() {
869869
private Map<String, String> getEnvironmentVariables() {
870870
Map<String, String> environment = new HashMap<>(spec.resolveEnvironment());
871871
String esFallbackJavaHome = System.getenv("ES_FALLBACK_JAVA_HOME");
872-
if (spec.getVersion().before(DISTRO_WITH_JDK_LOWER_21) && esFallbackJavaHome != null && esFallbackJavaHome.isEmpty() == false) {
872+
if (jdkIsIncompatible(spec.getVersion()) && esFallbackJavaHome != null && esFallbackJavaHome.isEmpty() == false) {
873873
environment.put("ES_JAVA_HOME", esFallbackJavaHome);
874874
}
875875
environment.put("ES_PATH_CONF", configDir.toString());
@@ -922,6 +922,10 @@ private Map<String, String> getEnvironmentVariables() {
922922
return environment;
923923
}
924924

925+
private boolean jdkIsIncompatible(Version version) {
926+
return version.after("0.0.0") && version.before(FIRST_DISTRO_WITH_JDK_21);
927+
}
928+
925929
private record ReplacementKey(String key, String fallback) {
926930
ReplacementKey {
927931
assert fallback == null || fallback.isEmpty() == false; // no empty fallback, which would match anything

0 commit comments

Comments
 (0)