diff --git a/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/InternalDistributionDownloadPluginFuncTest.groovy b/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/InternalDistributionDownloadPluginFuncTest.groovy index c7643da1c73b9..57f4fd6d7f625 100644 --- a/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/InternalDistributionDownloadPluginFuncTest.groovy +++ b/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/InternalDistributionDownloadPluginFuncTest.groovy @@ -51,7 +51,7 @@ class InternalDistributionDownloadPluginFuncTest extends AbstractGradleFuncTest def "resolves expanded bwc versions from source"() { given: internalBuild() - bwcMajor1ProjectSetup() + bwcProjectSetup("major1") buildFile << """ apply plugin: 'elasticsearch.internal-distribution-download' @@ -81,7 +81,7 @@ class InternalDistributionDownloadPluginFuncTest extends AbstractGradleFuncTest def "fails on resolving bwc versions with no bundled jdk"() { given: internalBuild() - bwcMajor1ProjectSetup() + bwcProjectSetup("major1") buildFile << """ apply plugin: 'elasticsearch.internal-distribution-download' @@ -105,12 +105,47 @@ class InternalDistributionDownloadPluginFuncTest extends AbstractGradleFuncTest "without a bundled JDK is not supported.") } - private void bwcMajor1ProjectSetup() { + def "resolves detached version from source"() { + given: + internalBuild() + bwcProjectSetup("main") + buildFile << """ + apply plugin: 'elasticsearch.internal-distribution-download' + + System.setProperty("tests.bwc.main.version", "9.2.0") + + elasticsearch_distributions { + test_distro { + version = "9.2.0" + type = "archive" + platform = "linux" + architecture = Architecture.current(); + detachedVersion = true + } + } + + tasks.register("setupDistro", Sync) { + from(elasticsearch_distributions.test_distro) + into("build/distro") + } + """ + + when: + def result = gradleRunner("setupDistro").build() + + then: + result.task(":distribution:bwc:main:buildBwcExpandedTask").outcome == TaskOutcome.SUCCESS + result.task(":setupDistro").outcome == TaskOutcome.SUCCESS + assertExtractedDistroIsCreated("distribution/bwc/main/build/install/elastic-distro", + 'bwc-marker.txt') + } + + private void bwcProjectSetup(String bwcProjectName) { settingsFile << """ - include ':distribution:bwc:major1' + include ':distribution:bwc:$bwcProjectName' """ - def bwcSubProjectFolder = testProjectDir.newFolder("distribution", "bwc", "major1") - new File(bwcSubProjectFolder, 'bwc-marker.txt') << "bwc=major1" + def bwcSubProjectFolder = testProjectDir.newFolder("distribution", "bwc", bwcProjectName) + new File(bwcSubProjectFolder, 'bwc-marker.txt') << "bwc=$bwcProjectName" new File(bwcSubProjectFolder, 'build.gradle') << """ apply plugin:'base' diff --git a/build-tools-internal/src/main/groovy/elasticsearch.bc-upgrade-test.gradle b/build-tools-internal/src/main/groovy/elasticsearch.bc-upgrade-test.gradle index 94702c840c745..568201ca11130 100644 --- a/build-tools-internal/src/main/groovy/elasticsearch.bc-upgrade-test.gradle +++ b/build-tools-internal/src/main/groovy/elasticsearch.bc-upgrade-test.gradle @@ -11,8 +11,18 @@ import org.elasticsearch.gradle.Version import org.elasticsearch.gradle.testclusters.StandaloneRestIntegTestTask tasks.register("bcUpgradeTest", StandaloneRestIntegTestTask) { - // We use a phony version here as the real version is provided via `tests.bwc.main.version` system property - usesBwcDistribution(Version.fromString("0.0.0")) - systemProperty("tests.old_cluster_version", "0.0.0") - onlyIf("tests.bwc.main.version system property exists") { System.getProperty("tests.bwc.main.version") != null } + project.gradle.taskGraph.whenReady { allTasks -> + if (allTasks.hasTask(getPath())) { + if (System.getProperty("tests.bwc.refspec.main") == null) { + throw new GradleException("You must set the `tests.bwc.refspec.main` system property to run bcUpgradeTest") + } + if (System.getProperty("tests.bwc.main.version") == null) { + throw new GradleException("You must set the `tests.bwc.main.version` system property to run bcUpgradeTest") + } + } + } + if (System.getProperty("tests.bwc.refspec.main") != null && System.getProperty("tests.bwc.main.version") != null) { + usesBwcDistributionFromRef(System.getProperty("tests.bwc.refspec.main"), Version.fromString(System.getProperty("tests.bwc.main.version"))) + systemProperty("tests.old_cluster_version", System.getProperty("tests.bwc.main.version")) + } } diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionDownloadPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionDownloadPlugin.java index f32afa1641e2e..809089c7b0b5c 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionDownloadPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/InternalDistributionDownloadPlugin.java @@ -74,7 +74,7 @@ public void apply(Project project) { */ private void registerInternalDistributionResolutions(List resolutions, Provider bwcVersions) { resolutions.add(new DistributionResolution("local-build", (project, distribution) -> { - if (isCurrentVersion(distribution)) { + if (isCurrentVersion(distribution) && distribution.isDetachedVersion() == false) { // non-external project, so depend on local build return new ProjectBasedDistributionDependency( config -> projectDependency(project.getDependencies(), distributionProjectPath(distribution), config) @@ -86,7 +86,7 @@ private void registerInternalDistributionResolutions(List { BwcVersions.UnreleasedVersionInfo unreleasedInfo = bwcVersions.get() .unreleasedInfo(Version.fromString(distribution.getVersion())); - if (unreleasedInfo != null) { + if (unreleasedInfo != null && distribution.isDetachedVersion() == false) { if (distribution.getBundledJdk() == false) { throw new GradleException( "Configuring a snapshot bwc distribution ('" @@ -103,21 +103,17 @@ private void registerInternalDistributionResolutions(List { - String versionProperty = System.getProperty("tests.bwc.main.version"); - // We use this phony version as a placeholder for the real version - if (distribution.getVersion().equals("0.0.0")) { - if (versionProperty == null) { - throw new GradleException("System property 'tests.bwc.main.version' expected for building bwc version."); - } + // The distribution version set by 'test.bwc.main.version' property should map to the version returned by the commit + // referenced in 'tests.bwc.refspec.main'. + resolutions.add(new DistributionResolution("detached", (project, distribution) -> { + if (distribution.isDetachedVersion()) { BwcVersions.UnreleasedVersionInfo unreleasedVersionInfo = new BwcVersions.UnreleasedVersionInfo( - Version.fromString(versionProperty), + Version.fromString(distribution.getVersion()), "main", ":distribution:bwc:main" ); diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java index b7d7ce62774ce..5e3b8edb912dd 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java @@ -106,13 +106,15 @@ public void apply(Project project) { ElasticsearchDistribution defaultDistro = createDistribution( project, DEFAULT_REST_INTEG_TEST_DISTRO, - VersionProperties.getElasticsearch() + VersionProperties.getElasticsearch(), + false ); ElasticsearchDistribution integTestDistro = createDistribution( project, INTEG_TEST_REST_INTEG_TEST_DISTRO, VersionProperties.getElasticsearch(), - ElasticsearchDistributionTypes.INTEG_TEST_ZIP + ElasticsearchDistributionTypes.INTEG_TEST_ZIP, + false ); // Create configures for module and plugin dependencies @@ -238,21 +240,11 @@ public Void call(Object... args) { } Version version = (Version) args[0]; - boolean isReleased = bwcVersions.unreleasedInfo(version) == null && version.toString().equals("0.0.0") == false; + boolean isReleased = bwcVersions.unreleasedInfo(version) == null; String versionString = version.toString(); - ElasticsearchDistribution bwcDistro = createDistribution(project, "bwc_" + versionString, versionString); - - if (jdkIsIncompatibleWithOS(Version.fromString(versionString))) { - var toolChainService = project.getExtensions().getByType(JavaToolchainService.class); - var fallbackJdk17Launcher = toolChainService.launcherFor(spec -> { - spec.getVendor().set(JvmVendorSpec.ADOPTIUM); - spec.getLanguageVersion().set(JavaLanguageVersion.of(17)); - }); - task.environment( - "ES_FALLBACK_JAVA_HOME", - fallbackJdk17Launcher.get().getMetadata().getInstallationPath().getAsFile().getPath() - ); - } + ElasticsearchDistribution bwcDistro = createDistribution(project, "bwc_" + versionString, versionString, false); + + handleJdkIncompatibleWithOS(version, project, task); task.dependsOn(bwcDistro); registerDistributionInputs(task, bwcDistro); @@ -261,16 +253,63 @@ public Void call(Object... args) { providerFactory.provider(() -> bwcDistro.getExtracted().getSingleFile().getPath()) ); - if (version.getMajor() > 0 && version.before(bwcVersions.getMinimumWireCompatibleVersion())) { + if (version.before(bwcVersions.getMinimumWireCompatibleVersion())) { // If we are upgrade testing older versions we also need to upgrade to 7.last this.call(bwcVersions.getMinimumWireCompatibleVersion()); } return null; } }); + + task.getExtensions().getExtraProperties().set("usesBwcDistributionFromRef", new Closure(task) { + @Override + public Void call(Object... args) { + if (args.length != 2 || args[0] instanceof String == false || args[1] instanceof Version == false) { + throw new IllegalArgumentException("Expected arguments (String refSpec, org.elasticsearch.gradle.Version version)"); + } + + String refSpec = (String) args[0]; + Version version = (Version) args[1]; + boolean isDetachedVersion = true; + String versionString = version.toString(); + + ElasticsearchDistribution bwcDistro = createDistribution(project, "bwc_" + refSpec, versionString, isDetachedVersion); + handleJdkIncompatibleWithOS(version, project, task); + + task.dependsOn(bwcDistro); + registerDistributionInputs(task, bwcDistro); + + nonInputSystemProperties.systemProperty( + BWC_SNAPSHOT_DISTRIBUTION_SYSPROP_PREFIX + versionString, + providerFactory.provider(() -> bwcDistro.getExtracted().getSingleFile().getPath()) + ); + return null; + } + }); }); } + /** + * Older distributions ship with openjdk versions that are not compatible with newer kernels of ubuntu 24.04 and later + * Therefore we pass explicitly the runtime java to use the adoptium jdk that is maintained longer and compatible + * with newer kernels. + * 8.10.4 is the last version shipped with jdk < 21. We configure these cluster to run with jdk 17 adoptium as 17 was + * the last LTS release before 21 + */ + private static void handleJdkIncompatibleWithOS(Version version, Project project, StandaloneRestIntegTestTask task) { + if (jdkIsIncompatibleWithOS(version)) { + var toolChainService = project.getExtensions().getByType(JavaToolchainService.class); + var fallbackJdk17Launcher = toolChainService.launcherFor(spec -> { + spec.getVendor().set(JvmVendorSpec.ADOPTIUM); + spec.getLanguageVersion().set(JavaLanguageVersion.of(17)); + }); + task.environment( + "ES_FALLBACK_JAVA_HOME", + fallbackJdk17Launcher.get().getMetadata().getInstallationPath().getAsFile().getPath() + ); + } + } + private void copyDependencies(Project project, DependencySet dependencies, Configuration configuration) { configuration.getDependencies() .stream() @@ -279,16 +318,23 @@ private void copyDependencies(Project project, DependencySet dependencies, Confi .forEach(dependencies::add); } - private ElasticsearchDistribution createDistribution(Project project, String name, String version) { - return createDistribution(project, name, version, null); + private ElasticsearchDistribution createDistribution(Project project, String name, String version, boolean detachedVersion) { + return createDistribution(project, name, version, null, detachedVersion); } - private ElasticsearchDistribution createDistribution(Project project, String name, String version, ElasticsearchDistributionType type) { + private ElasticsearchDistribution createDistribution( + Project project, + String name, + String version, + ElasticsearchDistributionType type, + boolean detachedVersion + ) { NamedDomainObjectContainer distributions = DistributionDownloadPlugin.getContainer(project); ElasticsearchDistribution maybeDistro = distributions.findByName(name); if (maybeDistro == null) { return distributions.create(name, distro -> { distro.setVersion(version); + distro.setDetachedVersion(detachedVersion); distro.setArchitecture(Architecture.current()); if (type != null) { distro.setType(type); diff --git a/build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java b/build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java index 3f9669af0568b..94d373cc59add 100644 --- a/build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java +++ b/build-tools/src/main/java/org/elasticsearch/gradle/ElasticsearchDistribution.java @@ -49,6 +49,7 @@ public String toString() { private final Property architecture; private final Property version; + private final Property detachedVersion; private final Property type; private final Property platform; private final Property bundledJdk; @@ -69,6 +70,7 @@ public String toString() { this.configuration = fileConfiguration; this.architecture = objectFactory.property(Architecture.class); this.version = objectFactory.property(String.class).convention(VersionProperties.getElasticsearch()); + this.detachedVersion = objectFactory.property(Boolean.class).convention(false); this.type = objectFactory.property(ElasticsearchDistributionType.class); this.type.convention(ElasticsearchDistributionTypes.ARCHIVE); this.platform = objectFactory.property(Platform.class); @@ -91,6 +93,19 @@ public void setVersion(String version) { this.version.set(version); } + /** + * Informs if the version is not tied to any Elasticsearch release and is a custom build. + * This is true when the distribution is not from HEAD but also not any known released version. + * In that case the detached source build needs to be prepared by `usedBwcDistributionFromRef(ref, version)`. + */ + public boolean isDetachedVersion() { + return detachedVersion.get(); + } + + public void setDetachedVersion(boolean detachedVersion) { + this.detachedVersion.set(detachedVersion); + } + public Platform getPlatform() { return platform.getOrNull(); } diff --git a/modules/ingest-geoip/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/ingest/geoip/FullClusterRestartIT.java b/modules/ingest-geoip/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/ingest/geoip/FullClusterRestartIT.java index a82b236c01aaa..0f68547ecbd76 100644 --- a/modules/ingest-geoip/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/ingest/geoip/FullClusterRestartIT.java +++ b/modules/ingest-geoip/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/ingest/geoip/FullClusterRestartIT.java @@ -17,7 +17,6 @@ import org.elasticsearch.test.cluster.ElasticsearchCluster; import org.elasticsearch.test.cluster.FeatureFlag; import org.elasticsearch.test.cluster.local.distribution.DistributionType; -import org.elasticsearch.test.cluster.util.Version; import org.elasticsearch.upgrades.FullClusterRestartUpgradeStatus; import org.elasticsearch.upgrades.ParameterizedFullClusterRestartTestCase; import org.junit.ClassRule; @@ -41,7 +40,7 @@ public class FullClusterRestartIT extends ParameterizedFullClusterRestartTestCas private static final ElasticsearchCluster cluster = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) - .version(Version.fromString(OLD_CLUSTER_VERSION)) + .version(OLD_CLUSTER_VERSION, isOldClusterDetachedVersion()) .nodes(2) .setting("ingest.geoip.downloader.endpoint", () -> fixture.getAddress(), s -> useFixture) .setting("xpack.security.enabled", "false") diff --git a/qa/full-cluster-restart/build.gradle b/qa/full-cluster-restart/build.gradle index 55881b7b29d20..26d51876b05ab 100644 --- a/qa/full-cluster-restart/build.gradle +++ b/qa/full-cluster-restart/build.gradle @@ -23,10 +23,20 @@ buildParams.bwcVersions.withIndexCompatible { bwcVersion, baseName -> } tasks.register("luceneBwcTest", StandaloneRestIntegTestTask) { - // We use a phony version here as the real version is provided via `tests.bwc.main.version` system property - usesBwcDistribution(Version.fromString("0.0.0")) - systemProperty("tests.old_cluster_version", "0.0.0") - onlyIf("tests.bwc.main.version system property exists") { System.getProperty("tests.bwc.main.version") != null } + project.gradle.taskGraph.whenReady { allTasks -> + if (allTasks.hasTask(getPath())) { + if (System.getProperty("tests.bwc.refspec.main") == null) { + throw new GradleException("You must set the `tests.bwc.refspec.main` system property to run luceneBwcTest") + } + if (System.getProperty("tests.bwc.main.version") == null) { + throw new GradleException("You must set the `tests.bwc.main.version` system property to run luceneBwcTest") + } + } + } + if (System.getProperty("tests.bwc.refspec.main") != null && System.getProperty("tests.bwc.main.version") != null) { + usesBwcDistributionFromRef(System.getProperty("tests.bwc.refspec.main"), Version.fromString(System.getProperty("tests.bwc.main.version"))) + systemProperty("tests.old_cluster_version", System.getProperty("tests.bwc.main.version")) + } } tasks.named("bcUpgradeTest").configure { diff --git a/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartArchivedSettingsIT.java b/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartArchivedSettingsIT.java index fe0a9f33cb226..d1781afa9dbea 100644 --- a/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartArchivedSettingsIT.java +++ b/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartArchivedSettingsIT.java @@ -21,7 +21,6 @@ import org.elasticsearch.test.cluster.FeatureFlag; import org.elasticsearch.test.cluster.local.LocalClusterConfigProvider; import org.elasticsearch.test.cluster.local.distribution.DistributionType; -import org.elasticsearch.test.cluster.util.Version; import org.elasticsearch.test.rest.ObjectPath; import org.junit.ClassRule; import org.junit.rules.RuleChain; @@ -45,7 +44,7 @@ public class FullClusterRestartArchivedSettingsIT extends ParameterizedFullClust private static ElasticsearchCluster cluster = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) - .version(Version.fromString(OLD_CLUSTER_VERSION)) + .version(OLD_CLUSTER_VERSION, isOldClusterDetachedVersion()) .nodes(2) .setting("path.repo", () -> repoDirectory.getRoot().getPath()) .setting("xpack.security.enabled", "false") diff --git a/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartDownsampleIT.java b/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartDownsampleIT.java index 71352355fb61e..10bbd3dc42e67 100644 --- a/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartDownsampleIT.java +++ b/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartDownsampleIT.java @@ -50,7 +50,7 @@ private static ElasticsearchCluster buildCluster() { Version oldVersion = Version.fromString(OLD_CLUSTER_VERSION); var cluster = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) - .version(Version.fromString(OLD_CLUSTER_VERSION)) + .version(OLD_CLUSTER_VERSION, isOldClusterDetachedVersion()) .nodes(2) .setting("xpack.security.enabled", "false") .setting("indices.lifecycle.poll_interval", "5s") diff --git a/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartIT.java b/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartIT.java index cbe383a7da550..b0fda4051bf4b 100644 --- a/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartIT.java +++ b/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/FullClusterRestartIT.java @@ -109,7 +109,7 @@ private static ElasticsearchCluster buildCluster() { Version oldVersion = Version.fromString(OLD_CLUSTER_VERSION); var cluster = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) - .version(Version.fromString(OLD_CLUSTER_VERSION)) + .version(OLD_CLUSTER_VERSION, isOldClusterDetachedVersion()) .nodes(2) .setting("path.repo", () -> repoDirectory.getRoot().getPath()) .setting("xpack.security.enabled", "false") diff --git a/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/LogsIndexModeFullClusterRestartIT.java b/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/LogsIndexModeFullClusterRestartIT.java index d677c6adf2459..7236bcba96b3f 100644 --- a/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/LogsIndexModeFullClusterRestartIT.java +++ b/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/LogsIndexModeFullClusterRestartIT.java @@ -39,7 +39,7 @@ private static ElasticsearchCluster buildCluster() { Version oldVersion = Version.fromString(OLD_CLUSTER_VERSION); var cluster = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) - .version(Version.fromString(OLD_CLUSTER_VERSION)) + .version(OLD_CLUSTER_VERSION, isOldClusterDetachedVersion()) .module("constant-keyword") .module("data-streams") .module("mapper-extras") diff --git a/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/QueryBuilderBWCIT.java b/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/QueryBuilderBWCIT.java index d336de92c3e93..701bf83e5e6eb 100644 --- a/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/QueryBuilderBWCIT.java +++ b/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/upgrades/QueryBuilderBWCIT.java @@ -73,7 +73,7 @@ public class QueryBuilderBWCIT extends ParameterizedFullClusterRestartTestCase { @ClassRule public static ElasticsearchCluster cluster = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) - .version(org.elasticsearch.test.cluster.util.Version.fromString(OLD_CLUSTER_VERSION)) + .version(OLD_CLUSTER_VERSION, isOldClusterDetachedVersion()) .nodes(2) .setting("xpack.security.enabled", "false") .apply(() -> clusterConfig) diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/AbstractRollingUpgradeTestCase.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/AbstractRollingUpgradeTestCase.java index 87096277cfce6..c702d82912aca 100644 --- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/AbstractRollingUpgradeTestCase.java +++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/AbstractRollingUpgradeTestCase.java @@ -30,11 +30,9 @@ public abstract class AbstractRollingUpgradeTestCase extends ParameterizedRollin private static final ElasticsearchCluster cluster = buildCluster(); private static ElasticsearchCluster buildCluster() { - // Note we need to use OLD_CLUSTER_VERSION directly here, as it may contain special values (e.g. 0.0.0) the ElasticsearchCluster - // builder uses to lookup a particular distribution var cluster = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) - .version(OLD_CLUSTER_VERSION) + .version(getOldClusterVersion(), isOldClusterDetachedVersion()) .nodes(NODE_NUM) .setting("path.repo", new Supplier<>() { @Override diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/AbstractRollingUpgradeWithSecurityTestCase.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/AbstractRollingUpgradeWithSecurityTestCase.java index 961e4a353df95..accbef575e923 100644 --- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/AbstractRollingUpgradeWithSecurityTestCase.java +++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/AbstractRollingUpgradeWithSecurityTestCase.java @@ -35,11 +35,9 @@ public abstract class AbstractRollingUpgradeWithSecurityTestCase extends Paramet private static final ElasticsearchCluster cluster = buildCluster(); private static ElasticsearchCluster buildCluster() { - // Note we need to use OLD_CLUSTER_VERSION directly here, as it may contain special values (e.g. 0.0.0) the ElasticsearchCluster - // builder uses to lookup a particular distribution var cluster = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) - .version(OLD_CLUSTER_VERSION) + .version(getOldClusterVersion(), isOldClusterDetachedVersion()) .nodes(NODE_NUM) .user(USER, PASS) .setting("xpack.security.autoconfiguration.enabled", "false") diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FileSettingsUpgradeIT.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FileSettingsUpgradeIT.java index 6d16714cc67bb..9ac2d39ee2ef4 100644 --- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FileSettingsUpgradeIT.java +++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/FileSettingsUpgradeIT.java @@ -57,11 +57,9 @@ public class FileSettingsUpgradeIT extends ParameterizedRollingUpgradeTestCase { private static final TemporaryFolder repoDirectory = new TemporaryFolder(); - // Note we need to use OLD_CLUSTER_VERSION directly here, as it may contain special values (e.g. 0.0.0) the ElasticsearchCluster - // builder uses to lookup a particular distribution private static final ElasticsearchCluster cluster = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) - .version(OLD_CLUSTER_VERSION) + .version(getOldClusterVersion(), isOldClusterDetachedVersion()) .nodes(NODE_NUM) .setting("path.repo", new Supplier<>() { @Override diff --git a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedRollingUpgradeTestCase.java b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedRollingUpgradeTestCase.java index 41a60a2880afb..af2beef5f6c8a 100644 --- a/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedRollingUpgradeTestCase.java +++ b/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/ParameterizedRollingUpgradeTestCase.java @@ -36,7 +36,7 @@ public abstract class ParameterizedRollingUpgradeTestCase extends ESRestTestCase { protected static final int NODE_NUM = 3; - protected static final String OLD_CLUSTER_VERSION = System.getProperty("tests.old_cluster_version"); + private static final String OLD_CLUSTER_VERSION = System.getProperty("tests.old_cluster_version"); private static final Set upgradedNodes = new HashSet<>(); private static TestFeatureService oldClusterTestFeatureService = null; private static boolean upgradeFailed = false; @@ -158,9 +158,8 @@ protected static String getOldClusterVersion() { } protected static boolean isOldClusterVersion(String nodeVersion, String buildHash) { - String bwcRefSpec = System.getProperty("tests.bwc.refspec.main"); - if (bwcRefSpec != null) { - return bwcRefSpec.equals(buildHash); + if (isOldClusterDetachedVersion()) { + return System.getProperty("tests.bwc.refspec.main").equals(buildHash); } return getOldClusterVersion().equals(nodeVersion); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java index 1572c82510202..db1f50b9a30b4 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java @@ -364,6 +364,14 @@ protected static boolean testFeatureServiceInitialized() { return testFeatureService != ALL_FEATURES; } + /** + * Whether the old cluster version is not of the released versions, but a detached build. + * In that case the Git ref has to be specified via {@code tests.bwc.refspec.main} system property. + */ + protected static boolean isOldClusterDetachedVersion() { + return System.getProperty("tests.bwc.refspec.main") != null; + } + @BeforeClass public static void initializeProjectIds() { // The active project-id is slightly longer, and has a fixed prefix so that it's easier to pick in error messages etc. diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalClusterFactory.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalClusterFactory.java index 0b3361065857d..1d52d305c18e3 100644 --- a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalClusterFactory.java +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalClusterFactory.java @@ -923,7 +923,7 @@ private Map getEnvironmentVariables() { } private boolean jdkIsIncompatible(Version version) { - return version.after("0.0.0") && version.before(FIRST_DISTRO_WITH_JDK_21); + return version.before(FIRST_DISTRO_WITH_JDK_21); } private record ReplacementKey(String key, String fallback) { diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalSpecBuilder.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalSpecBuilder.java index 3deadf49cca30..ea5c76bd551c8 100644 --- a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalSpecBuilder.java +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/AbstractLocalSpecBuilder.java @@ -305,6 +305,12 @@ public Version getVersion() { return inherit(() -> parent.getVersion(), version); } + @Override + public T version(String version, boolean detachedVersion) { + this.version = Version.fromString(version, detachedVersion); + return cast(this); + } + private List inherit(Supplier> parent, List child) { List combinedList = new ArrayList<>(); if (this.parent != null) { diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterSpec.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterSpec.java index 633381cefbbbb..cccf2a95234c9 100644 --- a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterSpec.java +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalClusterSpec.java @@ -212,12 +212,7 @@ public Path getConfigDir() { } public boolean isSecurityEnabled() { - return Boolean.parseBoolean( - getSetting( - "xpack.security.enabled", - getVersion().equals(Version.fromString("0.0.0")) || getVersion().onOrAfter("8.0.0") ? "true" : "false" - ) - ); + return Boolean.parseBoolean(getSetting("xpack.security.enabled", getVersion().onOrAfter("8.0.0") ? "true" : "false")); } public boolean isRemoteClusterServerEnabled() { diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalSpecBuilder.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalSpecBuilder.java index 53d283224b26f..5be15687459e2 100644 --- a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalSpecBuilder.java +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/LocalSpecBuilder.java @@ -136,6 +136,16 @@ interface LocalSpecBuilder> { */ T version(String version); + /** + * Sets the version of Elasticsearch and whether it is a detached version. + * If not set, then defaults to {@link Version#CURRENT} and {@code false}. + * + * @param version the ES cluster version string + * @param detachedVersion true if using unreleased version of Elasticsearch that is also different from the local current HEAD. + * Defaults to false. + */ + T version(String version, boolean detachedVersion); + /** * Adds a system property to node JVM arguments. */ diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/LocalDistributionResolver.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/LocalDistributionResolver.java index a853576d9b371..b42b5da249645 100644 --- a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/LocalDistributionResolver.java +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/LocalDistributionResolver.java @@ -26,7 +26,7 @@ public LocalDistributionResolver(DistributionResolver delegate) { @Override public DistributionDescriptor resolve(Version version, DistributionType type) { - if (version.equals(Version.CURRENT)) { + if (version.equals(Version.CURRENT) && version.isDetached() == false) { String testDistributionPath = System.getProperty(type.getSystemProperty()); if (testDistributionPath == null) { diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/SnapshotDistributionResolver.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/SnapshotDistributionResolver.java index db71f8cec9ab4..f57f36460b627 100644 --- a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/SnapshotDistributionResolver.java +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/local/distribution/SnapshotDistributionResolver.java @@ -38,9 +38,8 @@ public DistributionDescriptor resolve(Version version, DistributionType type) { } // Snapshot distributions are never release builds and always use the default distribution - Version realVersion = Version.fromString(System.getProperty("tests.bwc.main.version", version.toString())); boolean isSnapshot = System.getProperty("tests.bwc.snapshot", "true").equals("false") == false; - return new DefaultDistributionDescriptor(realVersion, isSnapshot, distributionDir, DistributionType.DEFAULT); + return new DefaultDistributionDescriptor(version, isSnapshot, distributionDir, DistributionType.DEFAULT); } return delegate.resolve(version, type); diff --git a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/Version.java b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/Version.java index 2136d88a9e2aa..9115537c24204 100644 --- a/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/Version.java +++ b/test/test-clusters/src/main/java/org/elasticsearch/test/cluster/util/Version.java @@ -33,6 +33,7 @@ public class Version implements Comparable, Serializable { private final int revision; private final int id; private final String qualifier; + private final boolean detached; static { Properties versionProperties = new Properties(); @@ -65,6 +66,10 @@ public Version(int major, int minor, int revision) { } public Version(int major, int minor, int revision, String qualifier) { + this(major, minor, revision, qualifier, false); + } + + protected Version(int major, int minor, int revision, String qualifier, boolean detached) { this.major = major; this.minor = minor; this.revision = revision; @@ -73,6 +78,7 @@ public Version(int major, int minor, int revision, String qualifier) { this.id = major * 10000000 + minor * 100000 + revision * 1000; this.qualifier = qualifier; + this.detached = detached; } public static Version fromString(final String s) { @@ -80,6 +86,14 @@ public static Version fromString(final String s) { } public static Version fromString(final String s, final Mode mode) { + return fromString(s, mode, false); + } + + public static Version fromString(final String s, final boolean detached) { + return fromString(s, Mode.STRICT, detached); + } + + private static Version fromString(final String s, final Mode mode, final boolean detached) { Objects.requireNonNull(s); Matcher matcher = mode == Mode.STRICT ? pattern.matcher(s) : relaxedPattern.matcher(s); if (matcher.matches() == false) { @@ -94,7 +108,13 @@ public static Version fromString(final String s, final Mode mode) { String revision = matcher.group(3); String qualifier = matcher.group(4); - return new Version(Integer.parseInt(major), Integer.parseInt(minor), revision == null ? 0 : Integer.parseInt(revision), qualifier); + return new Version( + Integer.parseInt(major), + Integer.parseInt(minor), + revision == null ? 0 : Integer.parseInt(revision), + qualifier, + detached + ); } public static Optional tryParse(final String s) { @@ -160,12 +180,12 @@ public boolean equals(Object o) { return false; } Version version = (Version) o; - return major == version.major && minor == version.minor && revision == version.revision; + return major == version.major && minor == version.minor && revision == version.revision && detached == version.detached; } @Override public int hashCode() { - return Objects.hash(major, minor, revision, id); + return Objects.hash(major, minor, revision, id, detached); } public int getMajor() { @@ -188,6 +208,15 @@ public String getQualifier() { return qualifier; } + /** + * Informs if the version is not tied to any Elasticsearch release and is a custom build. + * This is true when the distribution is not from HEAD but also not any known released version. + * In that case the detached source build needs to be prepared by `usedBwcDistributionFromRef(ref, version)`. + */ + public boolean isDetached() { + return detached; + } + @Override public int compareTo(Version other) { return Integer.compare(getId(), other.getId()); diff --git a/x-pack/plugin/ent-search/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/xpack/application/FullClusterRestartIT.java b/x-pack/plugin/ent-search/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/xpack/application/FullClusterRestartIT.java index 7bebd8fe05a54..a536998635d63 100644 --- a/x-pack/plugin/ent-search/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/xpack/application/FullClusterRestartIT.java +++ b/x-pack/plugin/ent-search/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/xpack/application/FullClusterRestartIT.java @@ -41,7 +41,7 @@ public class FullClusterRestartIT extends ParameterizedFullClusterRestartTestCas @ClassRule public static final ElasticsearchCluster cluster = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) - .version(org.elasticsearch.test.cluster.util.Version.fromString(OLD_CLUSTER_VERSION)) + .version(OLD_CLUSTER_VERSION, isOldClusterDetachedVersion()) .nodes(2) .setting("xpack.security.enabled", "false") .setting("xpack.license.self_generated.type", "trial") diff --git a/x-pack/plugin/esql/qa/server/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/mixed/Clusters.java b/x-pack/plugin/esql/qa/server/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/mixed/Clusters.java index 9d4043dccab6a..c68561b3b3594 100644 --- a/x-pack/plugin/esql/qa/server/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/mixed/Clusters.java +++ b/x-pack/plugin/esql/qa/server/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/mixed/Clusters.java @@ -13,12 +13,14 @@ public class Clusters { public static ElasticsearchCluster mixedVersionCluster() { - Version oldVersion = Version.fromString(System.getProperty("tests.old_cluster_version")); + String oldVersionString = System.getProperty("tests.old_cluster_version"); + Version oldVersion = Version.fromString(oldVersionString); + boolean isDetachedVersion = System.getProperty("tests.bwc.refspec.main") != null; var cluster = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) - .withNode(node -> node.version(oldVersion)) + .withNode(node -> node.version(oldVersionString, isDetachedVersion)) .withNode(node -> node.version(Version.CURRENT)) - .withNode(node -> node.version(oldVersion)) + .withNode(node -> node.version(oldVersionString, isDetachedVersion)) .withNode(node -> node.version(Version.CURRENT)) .setting("xpack.security.enabled", "false") .setting("xpack.license.self_generated.type", "trial"); diff --git a/x-pack/plugin/esql/qa/server/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/mixed/MixedClusterEsqlSpecIT.java b/x-pack/plugin/esql/qa/server/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/mixed/MixedClusterEsqlSpecIT.java index 93e2ecb14c2ff..c35ba5b92b65b 100644 --- a/x-pack/plugin/esql/qa/server/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/mixed/MixedClusterEsqlSpecIT.java +++ b/x-pack/plugin/esql/qa/server/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/mixed/MixedClusterEsqlSpecIT.java @@ -32,7 +32,11 @@ protected String getTestRestCluster() { return cluster.getHttpAddresses(); } - static final Version bwcVersion = Version.fromString(System.getProperty("tests.old_cluster_version")); + static final Version bwcVersion = Version.fromString( + System.getProperty("tests.old_cluster_version") != null + ? System.getProperty("tests.old_cluster_version").replace("-SNAPSHOT", "") + : null + ); private static TestFeatureService oldClusterTestFeatureService = null; diff --git a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/CohereServiceMixedIT.java b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/CohereServiceMixedIT.java index c16271ed44083..961c36efac3b3 100644 --- a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/CohereServiceMixedIT.java +++ b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/CohereServiceMixedIT.java @@ -7,9 +7,9 @@ package org.elasticsearch.xpack.inference.qa.mixed; -import org.elasticsearch.Version; import org.elasticsearch.common.Strings; import org.elasticsearch.inference.TaskType; +import org.elasticsearch.test.cluster.util.Version; import org.elasticsearch.test.http.MockResponse; import org.elasticsearch.test.http.MockWebServer; import org.elasticsearch.xpack.inference.services.cohere.embeddings.CohereEmbeddingType; @@ -21,7 +21,6 @@ import java.util.List; import java.util.Map; -import static org.elasticsearch.xpack.inference.qa.mixed.MixedClusterSpecTestCase.bwcVersion; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.empty; import static org.hamcrest.Matchers.hasEntry; diff --git a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/HuggingFaceServiceMixedIT.java b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/HuggingFaceServiceMixedIT.java index 457ae525b7f4b..63cffb6fdee33 100644 --- a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/HuggingFaceServiceMixedIT.java +++ b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/HuggingFaceServiceMixedIT.java @@ -7,9 +7,9 @@ package org.elasticsearch.xpack.inference.qa.mixed; -import org.elasticsearch.Version; import org.elasticsearch.common.Strings; import org.elasticsearch.inference.TaskType; +import org.elasticsearch.test.cluster.util.Version; import org.elasticsearch.test.http.MockResponse; import org.elasticsearch.test.http.MockWebServer; import org.junit.AfterClass; diff --git a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/MixedClusterSpecTestCase.java b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/MixedClusterSpecTestCase.java index 45cd3716f21df..172d52bd1a8db 100644 --- a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/MixedClusterSpecTestCase.java +++ b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/MixedClusterSpecTestCase.java @@ -7,9 +7,9 @@ package org.elasticsearch.xpack.inference.qa.mixed; -import org.elasticsearch.Version; import org.elasticsearch.features.NodeFeature; import org.elasticsearch.test.cluster.ElasticsearchCluster; +import org.elasticsearch.test.cluster.util.Version; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.test.rest.TestFeatureService; import org.junit.AfterClass; diff --git a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/MixedClustersSpec.java b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/MixedClustersSpec.java index 7802c2e966e01..00203d4b1261d 100644 --- a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/MixedClustersSpec.java +++ b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/MixedClustersSpec.java @@ -13,10 +13,11 @@ public class MixedClustersSpec { public static ElasticsearchCluster mixedVersionCluster() { - Version oldVersion = Version.fromString(System.getProperty("tests.old_cluster_version")); + String oldVersion = System.getProperty("tests.old_cluster_version"); + boolean isDetachedVersion = System.getProperty("tests.bwc.refspec.main") != null; return ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) - .withNode(node -> node.version(oldVersion)) + .withNode(node -> node.version(oldVersion, isDetachedVersion)) .withNode(node -> node.version(Version.CURRENT)) .setting("xpack.security.enabled", "false") .setting("xpack.license.self_generated.type", "trial") diff --git a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/OpenAIServiceMixedIT.java b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/OpenAIServiceMixedIT.java index b37bd1801b331..749684db43aac 100644 --- a/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/OpenAIServiceMixedIT.java +++ b/x-pack/plugin/inference/qa/mixed-cluster/src/javaRestTest/java/org/elasticsearch/xpack/inference/qa/mixed/OpenAIServiceMixedIT.java @@ -7,9 +7,9 @@ package org.elasticsearch.xpack.inference.qa.mixed; -import org.elasticsearch.Version; import org.elasticsearch.common.Strings; import org.elasticsearch.inference.TaskType; +import org.elasticsearch.test.cluster.util.Version; import org.elasticsearch.test.http.MockResponse; import org.elasticsearch.test.http.MockWebServer; import org.junit.AfterClass; diff --git a/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/InferenceUpgradeTestCase.java b/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/InferenceUpgradeTestCase.java index 7b28c562b13fc..7e80e8643d4cc 100644 --- a/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/InferenceUpgradeTestCase.java +++ b/x-pack/plugin/inference/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/xpack/application/InferenceUpgradeTestCase.java @@ -35,12 +35,10 @@ public InferenceUpgradeTestCase(@Name("upgradedNodes") int upgradedNodes) { super(upgradedNodes); } - // Note we need to use OLD_CLUSTER_VERSION directly here, as it may contain special values (e.g. 0.0.0) the ElasticsearchCluster - // builder uses to lookup a particular distribution @ClassRule public static ElasticsearchCluster cluster = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) - .version(OLD_CLUSTER_VERSION) + .version(getOldClusterVersion(), isOldClusterDetachedVersion()) .nodes(NODE_NUM) .setting("xpack.security.enabled", "false") .setting("xpack.license.self_generated.type", "trial") diff --git a/x-pack/plugin/logsdb/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/StandardToLogsDbIndexModeRollingUpgradeIT.java b/x-pack/plugin/logsdb/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/StandardToLogsDbIndexModeRollingUpgradeIT.java index e8cf3027ac067..bf969736e6c01 100644 --- a/x-pack/plugin/logsdb/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/StandardToLogsDbIndexModeRollingUpgradeIT.java +++ b/x-pack/plugin/logsdb/qa/rolling-upgrade/src/javaRestTest/java/org/elasticsearch/upgrades/StandardToLogsDbIndexModeRollingUpgradeIT.java @@ -46,7 +46,7 @@ public class StandardToLogsDbIndexModeRollingUpgradeIT extends AbstractRollingUp @ClassRule() public static final ElasticsearchCluster cluster = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) - .version(OLD_CLUSTER_VERSION) + .version(getOldClusterVersion(), isOldClusterDetachedVersion()) .nodes(NODE_NUM) .user(USER, PASS) .module("constant-keyword") diff --git a/x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/RemoteClusterSecurityBWCToRCS1ClusterRestIT.java b/x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/RemoteClusterSecurityBWCToRCS1ClusterRestIT.java index 73e0f096039f9..2de7a4be792db 100644 --- a/x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/RemoteClusterSecurityBWCToRCS1ClusterRestIT.java +++ b/x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/RemoteClusterSecurityBWCToRCS1ClusterRestIT.java @@ -26,11 +26,11 @@ */ public class RemoteClusterSecurityBWCToRCS1ClusterRestIT extends AbstractRemoteClusterSecurityBWCRestIT { - private static final Version OLD_CLUSTER_VERSION = Version.fromString(System.getProperty("tests.old_cluster_version")); + private static final String OLD_CLUSTER_VERSION = System.getProperty("tests.old_cluster_version"); static { fulfillingCluster = ElasticsearchCluster.local() - .version(OLD_CLUSTER_VERSION) + .version(OLD_CLUSTER_VERSION, isOldClusterDetachedVersion()) .distribution(DistributionType.DEFAULT) .name("fulfilling-cluster") .apply(commonClusterConfig) diff --git a/x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/RemoteClusterSecurityBWCToRCS2ClusterRestIT.java b/x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/RemoteClusterSecurityBWCToRCS2ClusterRestIT.java index 5e173b72c66de..c53cca6054fce 100644 --- a/x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/RemoteClusterSecurityBWCToRCS2ClusterRestIT.java +++ b/x-pack/plugin/security/qa/multi-cluster/src/javaRestTest/java/org/elasticsearch/xpack/remotecluster/RemoteClusterSecurityBWCToRCS2ClusterRestIT.java @@ -9,7 +9,6 @@ import org.elasticsearch.test.cluster.ElasticsearchCluster; import org.elasticsearch.test.cluster.local.distribution.DistributionType; -import org.elasticsearch.test.cluster.util.Version; import org.junit.Before; import org.junit.ClassRule; import org.junit.rules.RuleChain; @@ -27,14 +26,14 @@ */ public class RemoteClusterSecurityBWCToRCS2ClusterRestIT extends AbstractRemoteClusterSecurityBWCRestIT { - private static final Version OLD_CLUSTER_VERSION = Version.fromString(System.getProperty("tests.old_cluster_version")); + private static final String OLD_CLUSTER_VERSION = System.getProperty("tests.old_cluster_version"); private static final AtomicReference> API_KEY_MAP_REF = new AtomicReference<>(); static { fulfillingCluster = ElasticsearchCluster.local() .name("fulfilling-cluster") - .version(OLD_CLUSTER_VERSION) + .version(OLD_CLUSTER_VERSION, isOldClusterDetachedVersion()) .distribution(DistributionType.DEFAULT) .apply(commonClusterConfig) .setting("xpack.ml.enabled", "false") diff --git a/x-pack/plugin/shutdown/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java b/x-pack/plugin/shutdown/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java index d04560a2f47b2..3df11ac6661d7 100644 --- a/x-pack/plugin/shutdown/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java +++ b/x-pack/plugin/shutdown/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java @@ -17,7 +17,6 @@ import org.elasticsearch.test.cluster.ElasticsearchCluster; import org.elasticsearch.test.cluster.FeatureFlag; import org.elasticsearch.test.cluster.local.distribution.DistributionType; -import org.elasticsearch.test.cluster.util.Version; import org.elasticsearch.test.cluster.util.resource.Resource; import org.elasticsearch.test.rest.ESRestTestCase; import org.elasticsearch.upgrades.FullClusterRestartUpgradeStatus; @@ -46,7 +45,7 @@ public class FullClusterRestartIT extends ParameterizedFullClusterRestartTestCas @ClassRule public static ElasticsearchCluster cluster = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) - .version(Version.fromString(OLD_CLUSTER_VERSION)) + .version(OLD_CLUSTER_VERSION, isOldClusterDetachedVersion()) .nodes(2) // some tests rely on the translog not being flushed .setting("indices.memory.shard_inactive_time", "60m") diff --git a/x-pack/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/xpack/restart/AbstractXpackFullClusterRestartTestCase.java b/x-pack/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/xpack/restart/AbstractXpackFullClusterRestartTestCase.java index 2c3e2e1ee69a3..9b209da0033f7 100644 --- a/x-pack/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/xpack/restart/AbstractXpackFullClusterRestartTestCase.java +++ b/x-pack/qa/full-cluster-restart/src/javaRestTest/java/org/elasticsearch/xpack/restart/AbstractXpackFullClusterRestartTestCase.java @@ -10,7 +10,6 @@ import org.elasticsearch.test.cluster.ElasticsearchCluster; import org.elasticsearch.test.cluster.FeatureFlag; import org.elasticsearch.test.cluster.local.distribution.DistributionType; -import org.elasticsearch.test.cluster.util.Version; import org.elasticsearch.test.cluster.util.resource.Resource; import org.elasticsearch.upgrades.FullClusterRestartUpgradeStatus; import org.elasticsearch.upgrades.ParameterizedFullClusterRestartTestCase; @@ -21,7 +20,7 @@ public abstract class AbstractXpackFullClusterRestartTestCase extends Parameteri @ClassRule public static ElasticsearchCluster cluster = ElasticsearchCluster.local() .distribution(DistributionType.DEFAULT) - .version(Version.fromString(OLD_CLUSTER_VERSION)) + .version(OLD_CLUSTER_VERSION, isOldClusterDetachedVersion()) .nodes(2) // some tests rely on the translog not being flushed .setting("indices.memory.shard_inactive_time", "60m")