-
Notifications
You must be signed in to change notification settings - Fork 25.5k
[Test] Replace 0.0.0 version with "detached" property on ElasticsearchDistibution #134584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d058b7e
fd5b457
8da8b0f
2d30bbb
6f687c0
3da46f9
264f7bb
28b4a02
fb561bf
f2820f6
90052f8
62d7bd2
ff0faea
ebc9f89
d87ab1e
ed1f0bf
f792528
0e831f6
4417727
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<Void>(task) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice |
||
@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<ElasticsearchDistribution> 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); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,7 @@ public String toString() { | |
|
||
private final Property<Architecture> architecture; | ||
private final Property<String> version; | ||
private final Property<Boolean> detachedVersion; | ||
private final Property<ElasticsearchDistributionType> type; | ||
private final Property<Platform> platform; | ||
private final Property<Boolean> 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); | ||
} | ||
|
||
Comment on lines
+96
to
+108
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I refrained from using "snapshot" and used "detached" instead, because "snapshot" seems to be overloaded term. However, I'm interested in your opinion on that and any suggestions for better naming. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like the term |
||
public Platform getPlatform() { | ||
return platform.getOrNull(); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above
usesBwcDistribution
is now simplified, because handling of0.0.0
(now "detached") has been moved to theusesBwcDistributionFromRef
implementation below.