From 2fbeccb03b37ca72666c59b4718b71c2e6edb0a6 Mon Sep 17 00:00:00 2001 From: elasticsearchmachine <58790826+elasticsearchmachine@users.noreply.github.com> Date: Fri, 27 Dec 2024 08:25:44 +1100 Subject: [PATCH 1/5] Mute org.elasticsearch.index.mapper.AbstractShapeGeometryFieldMapperTests testCartesianBoundsBlockLoader #119201 --- muted-tests.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/muted-tests.yml b/muted-tests.yml index cbf6c87fa0a53..a61ebd5446ce0 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -241,6 +241,9 @@ tests: - class: org.elasticsearch.smoketest.SmokeTestMultiNodeClientYamlTestSuiteIT method: test {yaml=indices.create/20_synthetic_source/create index with use_synthetic_source} issue: https://github.com/elastic/elasticsearch/issues/119191 +- class: org.elasticsearch.index.mapper.AbstractShapeGeometryFieldMapperTests + method: testCartesianBoundsBlockLoader + issue: https://github.com/elastic/elasticsearch/issues/119201 # Examples: # From c98d8bb50e4fa618ea84d33268252a167c6d9d41 Mon Sep 17 00:00:00 2001 From: Mark Vieira Date: Thu, 26 Dec 2024 13:30:38 -0800 Subject: [PATCH 2/5] Limit concurrency of third party xpack tests (#119297) --- x-pack/qa/third-party/active-directory/build.gradle | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/x-pack/qa/third-party/active-directory/build.gradle b/x-pack/qa/third-party/active-directory/build.gradle index 5156d20dd1d12..92dbc8b9a8aba 100644 --- a/x-pack/qa/third-party/active-directory/build.gradle +++ b/x-pack/qa/third-party/active-directory/build.gradle @@ -29,4 +29,8 @@ tasks.named("test").configure { systemProperty 'tests.security.manager', 'false' include '**/*IT.class' include '**/*Tests.class' + + // Limit how many concurrent docker test fixtures we are running + maxParallelForks = 1 + forkEvery = 1 } From 9d0f08bedf831432a0eba4a5833f353e09325695 Mon Sep 17 00:00:00 2001 From: Mark Vieira Date: Thu, 26 Dec 2024 15:05:53 -0800 Subject: [PATCH 3/5] Revert "[Build] Do not invalidate configuration cache when branch is switched (#118894)" (#119300) This reverts commit f9c6a6c0b2d7184cc817431282253d54bf78b3b4. --- .../internal/conventions/GitInfoPlugin.java | 25 ++++++++----- .../internal/conventions/LicensingPlugin.java | 36 +++++++------------ .../internal/conventions/PublishPlugin.java | 7 ++-- .../internal/conventions/info/GitInfo.java | 12 ------- .../conventions/info/GitInfoValueSource.java | 22 ------------ .../internal/PublishPluginFuncTest.groovy | 34 ++++++++---------- .../internal/ElasticsearchJavaPlugin.java | 9 +++-- .../info/BuildParameterExtension.java | 4 +-- .../info/DefaultBuildParameterExtension.java | 14 ++++---- .../internal/info/GlobalBuildInfoPlugin.java | 9 +++-- .../info/BuildParameterExtensionSpec.groovy | 4 +-- client/rest/build.gradle | 2 +- client/sniffer/build.gradle | 2 +- client/test/build.gradle | 2 +- libs/h3/build.gradle | 2 +- libs/tdigest/build.gradle | 2 +- rest-api-spec/build.gradle | 2 +- x-pack/build.gradle | 2 +- 18 files changed, 73 insertions(+), 117 deletions(-) delete mode 100644 build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/info/GitInfoValueSource.java diff --git a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/GitInfoPlugin.java b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/GitInfoPlugin.java index 538008d1dcac1..28b90714508bd 100644 --- a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/GitInfoPlugin.java +++ b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/GitInfoPlugin.java @@ -10,7 +10,6 @@ package org.elasticsearch.gradle.internal.conventions; import org.elasticsearch.gradle.internal.conventions.info.GitInfo; -import org.elasticsearch.gradle.internal.conventions.info.GitInfoValueSource; import org.elasticsearch.gradle.internal.conventions.util.Util; import org.gradle.api.Plugin; import org.gradle.api.Project; @@ -19,28 +18,38 @@ import org.gradle.api.provider.Provider; import org.gradle.api.provider.ProviderFactory; -import java.io.File; - import javax.inject.Inject; +import java.io.File; -public abstract class GitInfoPlugin implements Plugin { +class GitInfoPlugin implements Plugin { private ProviderFactory factory; + private ObjectFactory objectFactory; + private Provider revision; + private Property gitInfo; @Inject - public GitInfoPlugin(ProviderFactory factory) { + GitInfoPlugin(ProviderFactory factory, ObjectFactory objectFactory) { this.factory = factory; + this.objectFactory = objectFactory; } @Override public void apply(Project project) { File rootDir = Util.locateElasticsearchWorkspace(project.getGradle()); - getGitInfo().convention(factory.of(GitInfoValueSource.class, spec -> { spec.getParameters().getPath().set(rootDir); })); - revision = getGitInfo().map(info -> info.getRevision() == null ? info.getRevision() : "main"); + gitInfo = objectFactory.property(GitInfo.class).value(factory.provider(() -> + GitInfo.gitInfo(rootDir) + )); + gitInfo.disallowChanges(); + gitInfo.finalizeValueOnRead(); + + revision = gitInfo.map(info -> info.getRevision() == null ? info.getRevision() : "main"); } - public abstract Property getGitInfo(); + public Property getGitInfo() { + return gitInfo; + } public Provider getRevision() { return revision; diff --git a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/LicensingPlugin.java b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/LicensingPlugin.java index 63514ae671bf3..ba170d083c886 100644 --- a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/LicensingPlugin.java +++ b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/LicensingPlugin.java @@ -15,9 +15,8 @@ import org.gradle.api.provider.Provider; import org.gradle.api.provider.ProviderFactory; -import java.util.Map; - import javax.inject.Inject; +import java.util.Map; public class LicensingPlugin implements Plugin { static final String ELASTIC_LICENSE_URL_PREFIX = "https://raw.githubusercontent.com/elastic/elasticsearch/"; @@ -34,33 +33,24 @@ public LicensingPlugin(ProviderFactory providerFactory) { @Override public void apply(Project project) { Provider revision = project.getRootProject().getPlugins().apply(GitInfoPlugin.class).getRevision(); - Provider licenseCommitProvider = providerFactory.provider( - () -> isSnapshotVersion(project) ? revision.get() : "v" + project.getVersion() + Provider licenseCommitProvider = providerFactory.provider(() -> + isSnapshotVersion(project) ? revision.get() : "v" + project.getVersion() ); - Provider elasticLicenseURL = licenseCommitProvider.map( - licenseCommit -> ELASTIC_LICENSE_URL_PREFIX + licenseCommit + ELASTIC_LICENSE_URL_POSTFIX - ); - Provider agplLicenseURL = licenseCommitProvider.map( - licenseCommit -> ELASTIC_LICENSE_URL_PREFIX + licenseCommit + AGPL_ELASTIC_LICENSE_URL_POSTFIX - ); + Provider elasticLicenseURL = licenseCommitProvider.map(licenseCommit -> ELASTIC_LICENSE_URL_PREFIX + + licenseCommit + ELASTIC_LICENSE_URL_POSTFIX); + Provider agplLicenseURL = licenseCommitProvider.map(licenseCommit -> ELASTIC_LICENSE_URL_PREFIX + + licenseCommit + AGPL_ELASTIC_LICENSE_URL_POSTFIX); // But stick the Elastic license url in project.ext so we can get it if we need to switch to it project.getExtensions().getExtraProperties().set("elasticLicenseUrl", elasticLicenseURL); - MapProperty> licensesProperty = project.getObjects() - .mapProperty(String.class, (Class>) (Class) Provider.class) - .convention( - providerFactory.provider( - () -> Map.of( - "Server Side Public License, v 1", - providerFactory.provider(() -> "https://www.mongodb.com/licensing/server-side-public-license"), - "Elastic License 2.0", - elasticLicenseURL, - "GNU Affero General Public License Version 3", - agplLicenseURL - ) + MapProperty licensesProperty = project.getObjects().mapProperty(String.class, String.class).convention( + providerFactory.provider(() -> Map.of( + "Server Side Public License, v 1", "https://www.mongodb.com/licensing/server-side-public-license", + "Elastic License 2.0", elasticLicenseURL.get(), + "GNU Affero General Public License Version 3", agplLicenseURL.get()) ) - ); + ); // Default to the SSPL+Elastic dual license project.getExtensions().getExtraProperties().set("projectLicenses", licensesProperty); diff --git a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/PublishPlugin.java b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/PublishPlugin.java index 22b0ab1918024..c3124812e5089 100644 --- a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/PublishPlugin.java +++ b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/PublishPlugin.java @@ -28,7 +28,6 @@ import org.gradle.api.plugins.JavaLibraryPlugin; import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.provider.MapProperty; -import org.gradle.api.provider.Provider; import org.gradle.api.provider.ProviderFactory; import org.gradle.api.publish.PublishingExtension; import org.gradle.api.publish.maven.MavenPublication; @@ -43,7 +42,6 @@ import java.io.File; import java.util.Map; import java.util.concurrent.Callable; - import javax.inject.Inject; public class PublishPlugin implements Plugin { @@ -83,7 +81,7 @@ private void configurePublications(Project project) { } }); @SuppressWarnings("unchecked") - var projectLicenses = (MapProperty>) project.getExtensions().getExtraProperties().get("projectLicenses"); + var projectLicenses = (MapProperty) project.getExtensions().getExtraProperties().get("projectLicenses"); publication.getPom().withXml(xml -> { var node = xml.asNode(); node.appendNode("inceptionYear", "2009"); @@ -91,7 +89,7 @@ private void configurePublications(Project project) { projectLicenses.get().entrySet().stream().sorted(Map.Entry.comparingByKey()).forEach(entry -> { Node license = licensesNode.appendNode("license"); license.appendNode("name", entry.getKey()); - license.appendNode("url", entry.getValue().get()); + license.appendNode("url", entry.getValue()); license.appendNode("distribution", "repo"); }); var developer = node.appendNode("developers").appendNode("developer"); @@ -196,6 +194,7 @@ static void configureSourcesJar(Project project) { }); } + /** * Format the generated pom files to be in a sort of reproducible order. */ diff --git a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/info/GitInfo.java b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/info/GitInfo.java index e6a41093205cc..dbd3b3f9c48ad 100644 --- a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/info/GitInfo.java +++ b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/info/GitInfo.java @@ -22,7 +22,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -191,15 +190,4 @@ public String urlFromOrigin() { } } - @Override - public boolean equals(Object o) { - if (o == null || getClass() != o.getClass()) return false; - GitInfo gitInfo = (GitInfo) o; - return Objects.equals(revision, gitInfo.revision) && Objects.equals(origin, gitInfo.origin); - } - - @Override - public int hashCode() { - return Objects.hash(revision, origin); - } } diff --git a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/info/GitInfoValueSource.java b/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/info/GitInfoValueSource.java deleted file mode 100644 index c422c2eb74e39..0000000000000 --- a/build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/info/GitInfoValueSource.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.elasticsearch.gradle.internal.conventions.info; - -import org.gradle.api.provider.Property; -import org.gradle.api.provider.ValueSource; -import org.gradle.api.provider.ValueSourceParameters; -import org.jetbrains.annotations.Nullable; - -import java.io.File; - -public abstract class GitInfoValueSource implements ValueSource { - - @Nullable - @Override - public GitInfo obtain() { - File path = getParameters().getPath().get(); - return GitInfo.gitInfo(path); - } - - public interface Parameters extends ValueSourceParameters { - Property getPath(); - } -} diff --git a/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/PublishPluginFuncTest.groovy b/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/PublishPluginFuncTest.groovy index 18b681ef5a9ef..65f124e5f88e8 100644 --- a/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/PublishPluginFuncTest.groovy +++ b/build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/PublishPluginFuncTest.groovy @@ -45,8 +45,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest { file("build/distributions/hello-world-1.0-javadoc.jar").exists() file("build/distributions/hello-world-1.0-sources.jar").exists() file("build/distributions/hello-world-1.0.pom").exists() - assertXmlEquals( - file("build/distributions/hello-world-1.0.pom").text, """ + assertXmlEquals(file("build/distributions/hello-world-1.0.pom").text, """ @@ -131,8 +130,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest { file("build/distributions/hello-world-1.0-javadoc.jar").exists() file("build/distributions/hello-world-1.0-sources.jar").exists() file("build/distributions/hello-world-1.0.pom").exists() - assertXmlEquals( - file("build/distributions/hello-world-1.0.pom").text, """ + assertXmlEquals(file("build/distributions/hello-world-1.0.pom").text, """ 4.0.0 org.acme @@ -221,8 +219,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest { file("build/distributions/hello-world-1.0-javadoc.jar").exists() file("build/distributions/hello-world-1.0-sources.jar").exists() file("build/distributions/hello-world-1.0.pom").exists() - assertXmlEquals( - file("build/distributions/hello-world-1.0.pom").text, """ + assertXmlEquals(file("build/distributions/hello-world-1.0.pom").text, """ 4.0.0 org.acme @@ -315,8 +312,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest { file("build/distributions/hello-world-plugin-1.0-javadoc.jar").exists() file("build/distributions/hello-world-plugin-1.0-sources.jar").exists() file("build/distributions/hello-world-plugin-1.0.pom").exists() - assertXmlEquals( - file("build/distributions/hello-world-plugin-1.0.pom").text, """ + assertXmlEquals(file("build/distributions/hello-world-plugin-1.0.pom").text, """ @@ -393,8 +389,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest { then: result.task(":generatePom").outcome == TaskOutcome.SUCCESS file("build/distributions/hello-world-plugin-2.0.pom").exists() - assertXmlEquals( - file("build/distributions/hello-world-plugin-2.0.pom").text, """ + assertXmlEquals(file("build/distributions/hello-world-plugin-2.0.pom").text, """ @@ -444,7 +439,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest { // scm info only added for internal builds internalBuild() buildFile << """ - buildParams.setGitOrigin(project.providers.provider(() -> "https://some-repo.com/repo.git")) + buildParams.setGitOrigin("https://some-repo.com/repo.git") apply plugin:'elasticsearch.java' apply plugin:'elasticsearch.publish' @@ -452,7 +447,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest { group = 'org.acme' description = "just a test project" - ext.projectLicenses.set(['The Apache Software License, Version 2.0': project.providers.provider(() -> 'http://www.apache.org/licenses/LICENSE-2.0')]) + ext.projectLicenses.set(['The Apache Software License, Version 2.0': 'http://www.apache.org/licenses/LICENSE-2.0']) """ when: @@ -461,8 +456,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest { then: result.task(":generatePom").outcome == TaskOutcome.SUCCESS file("build/distributions/hello-world-1.0.pom").exists() - assertXmlEquals( - file("build/distributions/hello-world-1.0.pom").text, """ + assertXmlEquals(file("build/distributions/hello-world-1.0.pom").text, """ @@ -499,15 +493,15 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest { private boolean assertXmlEquals(String toTest, String expected) { def diff = DiffBuilder.compare(Input.fromString(expected)) - .ignoreWhitespace() - .ignoreComments() - .normalizeWhitespace() - .withTest(Input.fromString(toTest)) - .build() + .ignoreWhitespace() + .ignoreComments() + .normalizeWhitespace() + .withTest(Input.fromString(toTest)) + .build() diff.differences.each { difference -> println difference } - if (diff.differences.size() > 0) { + if(diff.differences.size() > 0) { println """ given: $toTest """ diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchJavaPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchJavaPlugin.java index a4477d049460c..3ab85ba69dc80 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchJavaPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/ElasticsearchJavaPlugin.java @@ -27,7 +27,6 @@ import org.gradle.api.plugins.JavaLibraryPlugin; import org.gradle.api.plugins.JavaPlugin; import org.gradle.api.provider.Property; -import org.gradle.api.provider.Provider; import org.gradle.api.tasks.TaskProvider; import org.gradle.api.tasks.bundling.Jar; import org.gradle.api.tasks.javadoc.Javadoc; @@ -121,12 +120,12 @@ public void execute(Task task) { } private static void configureJarManifest(Project project, BuildParameterExtension buildParams) { - Provider gitOrigin = buildParams.getGitOrigin(); - Provider gitRevision = buildParams.getGitRevision(); + String gitOrigin = buildParams.getGitOrigin(); + String gitRevision = buildParams.getGitRevision(); project.getPlugins().withType(InfoBrokerPlugin.class).whenPluginAdded(manifestPlugin -> { - manifestPlugin.add("Module-Origin", toStringable(() -> gitOrigin.get())); - manifestPlugin.add("Change", toStringable(() -> gitRevision.get())); + manifestPlugin.add("Module-Origin", toStringable(() -> gitOrigin)); + manifestPlugin.add("Change", toStringable(() -> gitRevision)); manifestPlugin.add("X-Compile-Elasticsearch-Version", toStringable(VersionProperties::getElasticsearch)); manifestPlugin.add("X-Compile-Lucene-Version", toStringable(VersionProperties::getLucene)); manifestPlugin.add( diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/BuildParameterExtension.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/BuildParameterExtension.java index ef9055b3728d3..e80dc6ef1b44c 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/BuildParameterExtension.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/BuildParameterExtension.java @@ -46,9 +46,9 @@ public interface BuildParameterExtension { Provider getRuntimeJavaDetails(); - Provider getGitRevision(); + String getGitRevision(); - Provider getGitOrigin(); + String getGitOrigin(); ZonedDateTime getBuildDate(); diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/DefaultBuildParameterExtension.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/DefaultBuildParameterExtension.java index 283c02428e4e6..faac406d974c6 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/DefaultBuildParameterExtension.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/DefaultBuildParameterExtension.java @@ -36,7 +36,7 @@ public abstract class DefaultBuildParameterExtension implements BuildParameterEx private final Provider runtimeJavaVersion; private final Provider> javaToolChainSpec; private final Provider runtimeJavaDetails; - private final Provider gitRevision; + private final String gitRevision; private transient AtomicReference buildDate = new AtomicReference<>(); private final String testSeed; @@ -46,7 +46,7 @@ public abstract class DefaultBuildParameterExtension implements BuildParameterEx // not final for testing private Provider bwcVersions; - private Provider gitOrigin; + private String gitOrigin; public DefaultBuildParameterExtension( ProviderFactory providers, @@ -59,8 +59,8 @@ public DefaultBuildParameterExtension( JavaVersion minimumCompilerVersion, JavaVersion minimumRuntimeVersion, JavaVersion gradleJavaVersion, - Provider gitRevision, - Provider gitOrigin, + String gitRevision, + String gitOrigin, String testSeed, boolean isCi, int defaultParallel, @@ -155,12 +155,12 @@ public Provider getRuntimeJavaDetails() { } @Override - public Provider getGitRevision() { + public String getGitRevision() { return gitRevision; } @Override - public Provider getGitOrigin() { + public String getGitOrigin() { return gitOrigin; } @@ -239,7 +239,7 @@ public void setBwcVersions(Provider bwcVersions) { } // for testing; not part of public api - public void setGitOrigin(Provider gitOrigin) { + public void setGitOrigin(String gitOrigin) { this.gitOrigin = gitOrigin; } } diff --git a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/GlobalBuildInfoPlugin.java b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/GlobalBuildInfoPlugin.java index 675f1198b2a7d..86f59aa0ab41e 100644 --- a/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/GlobalBuildInfoPlugin.java +++ b/build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/info/GlobalBuildInfoPlugin.java @@ -14,7 +14,6 @@ import org.apache.commons.io.IOUtils; import org.elasticsearch.gradle.VersionProperties; import org.elasticsearch.gradle.internal.BwcVersions; -import org.elasticsearch.gradle.internal.conventions.GitInfoPlugin; import org.elasticsearch.gradle.internal.conventions.info.GitInfo; import org.elasticsearch.gradle.internal.conventions.info.ParallelDetector; import org.elasticsearch.gradle.internal.conventions.util.Util; @@ -97,8 +96,6 @@ public void apply(Project project) { } this.project = project; project.getPlugins().apply(JvmToolchainsPlugin.class); - Provider gitInfo = project.getPlugins().apply(GitInfoPlugin.class).getGitInfo(); - toolChainService = project.getExtensions().getByType(JavaToolchainService.class); GradleVersion minimumGradleVersion = GradleVersion.version(getResourceContents("/minimumGradleVersion")); if (GradleVersion.current().compareTo(minimumGradleVersion) < 0) { @@ -114,6 +111,8 @@ public void apply(Project project) { ? explicitRuntimeJavaHome : resolveJavaHomeFromToolChainService(VersionProperties.getBundledJdkMajorVersion()); + GitInfo gitInfo = GitInfo.gitInfo(project.getRootDir()); + Provider runtimeJdkMetaData = actualRuntimeJavaHome.map( runtimeJavaHome -> metadataDetector.getMetadata(getJavaInstallation(runtimeJavaHome)) ); @@ -144,8 +143,8 @@ public void apply(Project project) { minimumCompilerVersion, minimumRuntimeVersion, Jvm.current().getJavaVersion(), - gitInfo.map(g -> g.getRevision()), - gitInfo.map(g -> g.getOrigin()), + gitInfo.getRevision(), + gitInfo.getOrigin(), getTestSeed(), System.getenv("JENKINS_URL") != null || System.getenv("BUILDKITE_BUILD_URL") != null || System.getProperty("isCI") != null, ParallelDetector.findDefaultParallel(project), diff --git a/build-tools-internal/src/test/groovy/org/elasticsearch/gradle/internal/info/BuildParameterExtensionSpec.groovy b/build-tools-internal/src/test/groovy/org/elasticsearch/gradle/internal/info/BuildParameterExtensionSpec.groovy index ce63069a873ab..627a5e6920240 100644 --- a/build-tools-internal/src/test/groovy/org/elasticsearch/gradle/internal/info/BuildParameterExtensionSpec.groovy +++ b/build-tools-internal/src/test/groovy/org/elasticsearch/gradle/internal/info/BuildParameterExtensionSpec.groovy @@ -86,8 +86,8 @@ class BuildParameterExtensionSpec extends Specification { JavaVersion.VERSION_11, JavaVersion.VERSION_11, JavaVersion.VERSION_11, - providerMock(), - providerMock(), + "gitRevision", + "gitOrigin", "testSeed", false, 5, diff --git a/client/rest/build.gradle b/client/rest/build.gradle index 3fb2aa6595869..003c251186510 100644 --- a/client/rest/build.gradle +++ b/client/rest/build.gradle @@ -36,7 +36,7 @@ base { } // LLRC is licenses under Apache 2.0 -projectLicenses.set(['The Apache Software License, Version 2.0': providers.provider(() -> 'http://www.apache.org/licenses/LICENSE-2.0')]) +projectLicenses.set(['The Apache Software License, Version 2.0': 'http://www.apache.org/licenses/LICENSE-2.0']) licenseFile.set(rootProject.file('licenses/APACHE-LICENSE-2.0.txt')) dependencies { diff --git a/client/sniffer/build.gradle b/client/sniffer/build.gradle index 9b1cb1140311b..f6f26c8f7c0d5 100644 --- a/client/sniffer/build.gradle +++ b/client/sniffer/build.gradle @@ -32,7 +32,7 @@ base { } // rest client sniffer is licenses under Apache 2.0 -projectLicenses.set(['The Apache Software License, Version 2.0': providers.provider(() -> 'http://www.apache.org/licenses/LICENSE-2.0')]) +projectLicenses.set(['The Apache Software License, Version 2.0': 'http://www.apache.org/licenses/LICENSE-2.0']) licenseFile.set(rootProject.file('licenses/APACHE-LICENSE-2.0.txt')) dependencies { diff --git a/client/test/build.gradle b/client/test/build.gradle index e39b7587b69d5..8de6b3dbf92be 100644 --- a/client/test/build.gradle +++ b/client/test/build.gradle @@ -18,7 +18,7 @@ java { group = "${group}.client.test" // rest client sniffer is licenses under Apache 2.0 -projectLicenses.set(['The Apache Software License, Version 2.0': providers.provider(() -> 'http://www.apache.org/licenses/LICENSE-2.0')]) +projectLicenses.set(['The Apache Software License, Version 2.0': 'http://www.apache.org/licenses/LICENSE-2.0']) licenseFile.set(rootProject.file('licenses/APACHE-LICENSE-2.0.txt')) dependencies { diff --git a/libs/h3/build.gradle b/libs/h3/build.gradle index 6036323e160fc..81a0d56ed4606 100644 --- a/libs/h3/build.gradle +++ b/libs/h3/build.gradle @@ -35,7 +35,7 @@ tasks.named('forbiddenApisMain').configure { replaceSignatureFiles 'jdk-signatures' } -ext.projectLicenses.set(['The Apache Software License, Version 2.0': providers.provider(() -> 'http://www.apache.org/licenses/LICENSE-2.0')]) +ext.projectLicenses.set(['The Apache Software License, Version 2.0': 'http://www.apache.org/licenses/LICENSE-2.0']) licenseFile.set(rootProject.file('licenses/APACHE-LICENSE-2.0.txt')) tasks.withType(LicenseHeadersTask.class).configureEach { diff --git a/libs/tdigest/build.gradle b/libs/tdigest/build.gradle index b79a6ce0a486a..2713df701fb44 100644 --- a/libs/tdigest/build.gradle +++ b/libs/tdigest/build.gradle @@ -36,7 +36,7 @@ tasks.named('forbiddenApisMain').configure { replaceSignatureFiles 'jdk-signatures' } -ext.projectLicenses.set(['The Apache Software License, Version 2.0': providers.provider(() -> 'http://www.apache.org/licenses/LICENSE-2.0')]) +ext.projectLicenses.set(['The Apache Software License, Version 2.0': 'http://www.apache.org/licenses/LICENSE-2.0']) licenseFile.set(rootProject.file('licenses/APACHE-LICENSE-2.0.txt')) tasks.withType(LicenseHeadersTask.class).configureEach { diff --git a/rest-api-spec/build.gradle b/rest-api-spec/build.gradle index 147b04ccd6722..fab47c5b05006 100644 --- a/rest-api-spec/build.gradle +++ b/rest-api-spec/build.gradle @@ -13,7 +13,7 @@ restResources { } // REST API specifications are published under the Apache 2.0 License -ext.projectLicenses.set(['The Apache Software License, Version 2.0': providers.provider(() -> 'http://www.apache.org/licenses/LICENSE-2.0')]) +ext.projectLicenses.set(['The Apache Software License, Version 2.0': 'http://www.apache.org/licenses/LICENSE-2.0']) licenseFile.set(rootProject.file('licenses/APACHE-LICENSE-2.0.txt')) configurations { diff --git a/x-pack/build.gradle b/x-pack/build.gradle index 86d56ef569adb..e79d2fe0e9899 100644 --- a/x-pack/build.gradle +++ b/x-pack/build.gradle @@ -36,7 +36,7 @@ subprojects { } project.pluginManager.withPlugin("elasticsearch.licensing") { - ext.projectLicenses.set(['Elastic License 2.0': ext.elasticLicenseUrl]) + ext.projectLicenses.set(['Elastic License 2.0': ext.elasticLicenseUrl.get()]) } project.pluginManager.withPlugin("elasticsearch.build") { From 41a4660f9a0f6ad6e8944ed15474627474dfc833 Mon Sep 17 00:00:00 2001 From: David Turner Date: Fri, 27 Dec 2024 09:26:06 +0000 Subject: [PATCH 4/5] Fix `MasterServiceTests#testThreadContext` (#118926) This test would fail to see the expected response headers if the task timed out before it started executing, which could happen very rarely. It's also not a very good test because it never actually executed any of the paths involving acking. This commit fixes the rare failure and tightens up the assertions to verify that it does indeed see the right thread context while handling the end of the acking process, and indeed that it always completes the acking process. Closes #118914 --- .../cluster/service/MasterServiceTests.java | 93 +++++++++++++------ 1 file changed, 63 insertions(+), 30 deletions(-) diff --git a/server/src/test/java/org/elasticsearch/cluster/service/MasterServiceTests.java b/server/src/test/java/org/elasticsearch/cluster/service/MasterServiceTests.java index f9d8173e15be4..0fecccc3cb5e6 100644 --- a/server/src/test/java/org/elasticsearch/cluster/service/MasterServiceTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/service/MasterServiceTests.java @@ -46,6 +46,8 @@ import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; import org.elasticsearch.common.util.concurrent.StoppableExecutorServiceWrapper; import org.elasticsearch.common.util.concurrent.ThreadContext; +import org.elasticsearch.core.Releasable; +import org.elasticsearch.core.Releasables; import org.elasticsearch.core.SuppressForbidden; import org.elasticsearch.core.TimeValue; import org.elasticsearch.core.Tuple; @@ -259,9 +261,42 @@ public void clusterStatePublished(ClusterState newClusterState) { assertThat(registeredActions.toString(), registeredActions, contains(MasterService.STATE_UPDATE_ACTION_NAME)); } - public void testThreadContext() throws InterruptedException { + public void testThreadContext() { try (var master = createMasterService(true)) { - final CountDownLatch latch = new CountDownLatch(1); + + master.setClusterStatePublisher((clusterStatePublicationEvent, publishListener, ackListener) -> { + ClusterServiceUtils.setAllElapsedMillis(clusterStatePublicationEvent); + try (var ignored = threadPool.getThreadContext().newEmptyContext()) { + if (randomBoolean()) { + randomExecutor(threadPool).execute(() -> publishListener.onResponse(null)); + randomExecutor(threadPool).execute(() -> ackListener.onCommit(TimeValue.timeValueMillis(randomInt(10000)))); + randomExecutor(threadPool).execute( + () -> ackListener.onNodeAck( + clusterStatePublicationEvent.getNewState().nodes().getMasterNode(), + randomBoolean() ? null : new RuntimeException("simulated ack failure") + ) + ); + } else { + randomExecutor(threadPool).execute( + () -> publishListener.onFailure(new FailedToCommitClusterStateException("simulated publish failure")) + ); + } + } + }); + + final Releasable onPublishComplete; + final Releasable onAckingComplete; + final Runnable awaitComplete; + { + final var publishLatch = new CountDownLatch(1); + final var ackingLatch = new CountDownLatch(1); + onPublishComplete = Releasables.assertOnce(publishLatch::countDown); + onAckingComplete = Releasables.assertOnce(ackingLatch::countDown); + awaitComplete = () -> { + safeAwait(publishLatch); + safeAwait(ackingLatch); + }; + } try (ThreadContext.StoredContext ignored = threadPool.getThreadContext().stashContext()) { @@ -272,15 +307,12 @@ public void testThreadContext() throws InterruptedException { expectedHeaders.put(copiedHeader, randomIdentifier()); } } - - final Map> expectedResponseHeaders = Collections.singletonMap( - "testResponse", - Collections.singletonList("testResponse") - ); threadPool.getThreadContext().putHeader(expectedHeaders); - final TimeValue ackTimeout = randomBoolean() ? TimeValue.ZERO : TimeValue.timeValueMillis(randomInt(10000)); - final TimeValue masterTimeout = randomBoolean() ? TimeValue.ZERO : TimeValue.timeValueMillis(randomInt(10000)); + final Map> expectedResponseHeaders = Map.of("testResponse", List.of(randomIdentifier())); + + final TimeValue ackTimeout = randomBoolean() ? TimeValue.MINUS_ONE : TimeValue.timeValueMillis(randomInt(10000)); + final TimeValue masterTimeout = randomBoolean() ? TimeValue.MINUS_ONE : TimeValue.timeValueMillis(randomInt(10000)); master.submitUnbatchedStateUpdateTask( "test", @@ -289,8 +321,9 @@ public void testThreadContext() throws InterruptedException { public ClusterState execute(ClusterState currentState) { assertTrue(threadPool.getThreadContext().isSystemContext()); assertEquals(Collections.emptyMap(), threadPool.getThreadContext().getHeaders()); - threadPool.getThreadContext().addResponseHeader("testResponse", "testResponse"); - assertEquals(expectedResponseHeaders, threadPool.getThreadContext().getResponseHeaders()); + expectedResponseHeaders.forEach( + (name, values) -> values.forEach(v -> threadPool.getThreadContext().addResponseHeader(name, v)) + ); if (randomBoolean()) { return ClusterState.builder(currentState).build(); @@ -303,44 +336,44 @@ public ClusterState execute(ClusterState currentState) { @Override public void onFailure(Exception e) { - assertFalse(threadPool.getThreadContext().isSystemContext()); - assertEquals(expectedHeaders, threadPool.getThreadContext().getHeaders()); - assertEquals(expectedResponseHeaders, threadPool.getThreadContext().getResponseHeaders()); - latch.countDown(); + assertExpectedThreadContext( + e instanceof ProcessClusterEventTimeoutException ? Map.of() : expectedResponseHeaders + ); + onPublishComplete.close(); + onAckingComplete.close(); // no acking takes place if publication failed } @Override public void clusterStateProcessed(ClusterState oldState, ClusterState newState) { - assertFalse(threadPool.getThreadContext().isSystemContext()); - assertEquals(expectedHeaders, threadPool.getThreadContext().getHeaders()); - assertEquals(expectedResponseHeaders, threadPool.getThreadContext().getResponseHeaders()); - latch.countDown(); + assertExpectedThreadContext(expectedResponseHeaders); + onPublishComplete.close(); } @Override public void onAllNodesAcked() { - assertFalse(threadPool.getThreadContext().isSystemContext()); - assertEquals(expectedHeaders, threadPool.getThreadContext().getHeaders()); - assertEquals(expectedResponseHeaders, threadPool.getThreadContext().getResponseHeaders()); - latch.countDown(); + onAckCompletion(); } @Override public void onAckFailure(Exception e) { - assertFalse(threadPool.getThreadContext().isSystemContext()); - assertEquals(expectedHeaders, threadPool.getThreadContext().getHeaders()); - assertEquals(expectedResponseHeaders, threadPool.getThreadContext().getResponseHeaders()); - latch.countDown(); + onAckCompletion(); } @Override public void onAckTimeout() { + onAckCompletion(); + } + + private void onAckCompletion() { + assertExpectedThreadContext(expectedResponseHeaders); + onAckingComplete.close(); + } + + private void assertExpectedThreadContext(Map> expectedResponseHeaders) { assertFalse(threadPool.getThreadContext().isSystemContext()); assertEquals(expectedHeaders, threadPool.getThreadContext().getHeaders()); assertEquals(expectedResponseHeaders, threadPool.getThreadContext().getResponseHeaders()); - latch.countDown(); } - } ); @@ -349,7 +382,7 @@ public void onAckTimeout() { assertEquals(Collections.emptyMap(), threadPool.getThreadContext().getResponseHeaders()); } - assertTrue(latch.await(10, TimeUnit.SECONDS)); + awaitComplete.run(); } } From fe64ae0e087666f787a4bf9dafefdaf6a5ba9473 Mon Sep 17 00:00:00 2001 From: David Turner Date: Fri, 27 Dec 2024 09:26:38 +0000 Subject: [PATCH 5/5] Fix `DiscoveryEc2AvailabilityZoneAttributeNoImdsIT` (#118821) This test asserts that no AZ attribute is set, assuming that the current AZ is unavailable, but in fact that's not true when running these tests in EC2. With this commit we override the IMDS endpoint address to one that definitely does not exist. Relates #118675 Closes #118564 --- ...coveryEc2AvailabilityZoneAttributeNoImdsIT.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/plugins/discovery-ec2/src/javaRestTest/java/org/elasticsearch/discovery/ec2/DiscoveryEc2AvailabilityZoneAttributeNoImdsIT.java b/plugins/discovery-ec2/src/javaRestTest/java/org/elasticsearch/discovery/ec2/DiscoveryEc2AvailabilityZoneAttributeNoImdsIT.java index 73213090b6f93..af3b3d67951dd 100644 --- a/plugins/discovery-ec2/src/javaRestTest/java/org/elasticsearch/discovery/ec2/DiscoveryEc2AvailabilityZoneAttributeNoImdsIT.java +++ b/plugins/discovery-ec2/src/javaRestTest/java/org/elasticsearch/discovery/ec2/DiscoveryEc2AvailabilityZoneAttributeNoImdsIT.java @@ -9,30 +9,24 @@ package org.elasticsearch.discovery.ec2; -import com.amazonaws.util.EC2MetadataUtils; - import org.elasticsearch.client.Request; import org.elasticsearch.test.cluster.ElasticsearchCluster; -import org.elasticsearch.test.rest.ESRestTestCase; import org.junit.ClassRule; import java.io.IOException; -public class DiscoveryEc2AvailabilityZoneAttributeNoImdsIT extends ESRestTestCase { +public class DiscoveryEc2AvailabilityZoneAttributeNoImdsIT extends DiscoveryEc2AvailabilityZoneAttributeTestCase { @ClassRule - public static ElasticsearchCluster cluster = ElasticsearchCluster.local() - .plugin("discovery-ec2") - .setting(AwsEc2Service.AUTO_ATTRIBUTE_SETTING.getKey(), "true") - .build(); + // use an address which definitely isn't running an IMDS, just in case we're running these tests in EC2 + public static ElasticsearchCluster cluster = DiscoveryEc2AvailabilityZoneAttributeTestCase.buildCluster(() -> "http://127.0.0.1:1"); @Override protected String getTestRestCluster() { return cluster.getHttpAddresses(); } + @Override // the base class asserts that the attribute is set, but we don't want that here public void testAvailabilityZoneAttribute() throws IOException { - assumeTrue("test only in non-AWS environment", EC2MetadataUtils.getInstanceId() == null); - final var nodesInfoResponse = assertOKAndCreateObjectPath(client().performRequest(new Request("GET", "/_nodes/_all/_none"))); for (final var nodeId : nodesInfoResponse.evaluateMapKeys("nodes")) { assertNull(nodesInfoResponse.evaluateExact("nodes", nodeId, "attributes", "aws_availability_zone"));