Skip to content

Commit e590964

Browse files
Merge remote-tracking branch 'upstream/main' into ES-12677
# Conflicts: # server/src/main/resources/transport/upper_bounds/9.3.csv
2 parents 4bd5039 + 5b01230 commit e590964

File tree

1,114 files changed

+16841
-8107
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,114 files changed

+16841
-8107
lines changed

.buildkite/scripts/generate-pr-performance-benchmark.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ steps:
4646
CONFIGURATION_NAME: ${GITHUB_PR_COMMENT_VAR_BENCHMARK}
4747
ENV_ID: ${env_id_baseline}
4848
REVISION: ${merge_base}
49+
BENCHMARK_TYPE: baseline
4950
- label: Trigger contender benchmark with ${GITHUB_PR_TRIGGERED_SHA:0:7}
5051
trigger: elasticsearch-performance-esbench-pr
5152
build:
@@ -56,6 +57,7 @@ steps:
5657
ENV_ID: ${env_id_contender}
5758
ES_REPO_URL: https://github.com/${GITHUB_PR_OWNER}/${GITHUB_PR_REPO}.git
5859
REVISION: ${GITHUB_PR_TRIGGERED_SHA}
60+
BENCHMARK_TYPE: contender
5961
- wait: ~
6062
- label: Update PR comment and Buildkite annotation
6163
command: |

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ build/
4646
**/.local*
4747
.vagrant/
4848
/logs/
49+
**/target/
4950

5051
# osx stuff
5152
.DS_Store

benchmarks/src/main/java/org/elasticsearch/benchmark/_nightly/esql/QueryPlanningBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public void setup() {
119119
}
120120

121121
private LogicalPlan plan(EsqlParser parser, Analyzer analyzer, LogicalPlanOptimizer optimizer, String query) {
122-
var parsed = parser.createStatement(query, new QueryParams(), telemetry, config);
122+
var parsed = parser.createStatement(query, new QueryParams(), telemetry);
123123
var analyzed = analyzer.analyze(parsed);
124124
var optimized = optimizer.optimize(analyzed);
125125
return optimized;

build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/BuildPluginFuncTest.groovy

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ class BuildPluginFuncTest extends AbstractGradleFuncTest {
151151
tasks.named('checkstyleMain').configure { enabled = false }
152152
tasks.named('loggerUsageCheck').configure { enabled = false }
153153
// tested elsewhere
154-
tasks.named('thirdPartyAudit').configure { enabled = false }
154+
tasks.named('thirdPartyAudit').configure {
155+
getRuntimeJavaVersion().set(JavaVersion.VERSION_21)
156+
getTargetCompatibility().set(JavaVersion.VERSION_21)
157+
enabled = false
158+
}
155159
"""
156160
when:
157161
def result = gradleRunner("check").build()
@@ -167,6 +171,25 @@ class BuildPluginFuncTest extends AbstractGradleFuncTest {
167171
result.task(":loggerUsageCheck").outcome == TaskOutcome.SKIPPED
168172
}
169173

174+
def "can generate dependency infos file"() {
175+
given:
176+
repository.generateJar("junit", "junit", "4.12", 'org.acme.JunitMock')
177+
repository.configureBuild(buildFile)
178+
file("licenses/junit-4.12.jar.sha1").text = "2973d150c0dc1fefe998f834810d68f278ea58ec"
179+
file("licenses/junit-LICENSE.txt").text = EXAMPLE_LICENSE
180+
file("licenses/junit-NOTICE.txt").text = "mock notice"
181+
buildFile << """
182+
dependencies {
183+
api "junit:junit:4.12"
184+
}
185+
"""
186+
when:
187+
def result = gradleRunner("dependenciesInfo").build()
188+
then:
189+
result.task(":dependenciesInfo").outcome == TaskOutcome.SUCCESS
190+
file("build/reports/dependencies/dependencies.csv").text == "junit:junit,4.12,https://repo1.maven.org/maven2/junit/junit/4.12,BSD-3-Clause,\n"
191+
}
192+
170193
def assertValidJar(File jar) {
171194
try (ZipFile zipFile = new ZipFile(jar)) {
172195
ZipEntry licenseEntry = zipFile.getEntry("META-INF/LICENSE.txt")

build-tools-internal/src/integTest/groovy/org/elasticsearch/gradle/internal/transport/TransportVersionValidationFuncTest.groovy

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,4 +311,43 @@ class TransportVersionValidationFuncTest extends AbstractTransportVersionFuncTes
311311
then:
312312
result.task(":myserver:validateTransportVersionResources").outcome == TaskOutcome.SUCCESS
313313
}
314+
315+
def "modification checks use PR base branch in CI"() {
316+
given:
317+
// create 9.1 branch
318+
execute("git checkout -b 9.1")
319+
// setup 9.1 upper bound as if 9.2 was just branched, so no patches yet
320+
unreferableTransportVersion("initial_9.1.0", "8013000")
321+
transportVersionUpperBound("9.1", "initial_9.1.0", "8013000")
322+
execute("git add .")
323+
execute("git commit -m initial")
324+
325+
// advance main branch
326+
execute("git checkout main")
327+
unreferableTransportVersion("initial_9.1.0", "8013000")
328+
referableAndReferencedTransportVersion("new_tv", "8124000,8013001")
329+
transportVersionUpperBound("9.2", "new_tv", "8124000")
330+
transportVersionUpperBound("9.1", "new_tv", "8013001")
331+
execute("git add .")
332+
execute("git commit -m update")
333+
334+
// create a 9.1 backport
335+
execute("git checkout 9.1")
336+
execute("git checkout -b test_9.1")
337+
referableAndReferencedTransportVersion("new_tv", "8124000,8013001")
338+
transportVersionUpperBound("9.2", "new_tv", "8124000")
339+
transportVersionUpperBound("9.1", "new_tv", "8013001")
340+
file("myserver/build.gradle") << """
341+
tasks.named('validateTransportVersionResources') {
342+
currentUpperBoundName = '9.1'
343+
}
344+
"""
345+
346+
when:
347+
def result = gradleRunner("validateTransportVersionResources")
348+
.withEnvironment(Map.of("BUILDKITE_PULL_REQUEST_BASE_BRANCH", "9.1")).build()
349+
350+
then:
351+
result.task(":myserver:validateTransportVersionResources").outcome == TaskOutcome.SUCCESS
352+
}
314353
}

build-tools-internal/src/main/groovy/elasticsearch.build-scan.gradle

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@
77
* License v3.0 only", or the "Server Side Public License, v 1".
88
*/
99

10-
import java.lang.management.ManagementFactory;
11-
import java.time.LocalDateTime;
1210

13-
import org.elasticsearch.gradle.Architecture
1411
import org.elasticsearch.gradle.OS
15-
import static org.elasticsearch.gradle.internal.util.CiUtils.safeName
16-
1712
import java.lang.management.ManagementFactory
1813
import java.time.LocalDateTime
14+
import org.elasticsearch.gradle.Architecture
15+
16+
import static org.elasticsearch.gradle.internal.util.CiUtils.safeName
1917

2018
// Resolving this early to avoid issues with the build scan plugin in combination with the configuration cache usage
2119
def taskNames = gradle.startParameter.taskNames.join(' ')
@@ -32,10 +30,10 @@ develocity {
3230
// Automatically publish scans from Elasticsearch CI
3331
if (onCI) {
3432
publishing.onlyIf { true }
35-
if(server.isPresent() == false) {
33+
if (server.isPresent() == false) {
3634
server = 'https://gradle-enterprise.elastic.co'
3735
}
38-
} else if( server.isPresent() == false) {
36+
} else if (server.isPresent() == false) {
3937
publishing.onlyIf { false }
4038
}
4139

@@ -99,6 +97,15 @@ develocity {
9997
tag 'pull-request'
10098
link 'Source', "${prBaseUrl}/tree/${System.getenv('BUILDKITE_COMMIT')}"
10199
link 'Pull Request', "https://github.com/${repository}/pull/${prId}"
100+
} else if (System.getenv('ELASTICSEARCH_PR_NUMBER')) {
101+
// For tracking es-pr-check failures in the serverless repo caused by elasticsearch PRs
102+
def esPr = System.getenv('ELASTICSEARCH_PR_NUMBER')
103+
def esCommit = System.getenv('ELASTICSEARCH_SUBMODULE_COMMIT')
104+
value 'Git Commit ID', esCommit
105+
tag "pr/${esPr}"
106+
tag 'pull-request'
107+
link 'Source', "https://github.com/elastic/elasticsearch/pull/${esPr}/commits/${esCommit}"
108+
link 'Pull Request', "https://github.com/elastic/elasticsearch/pull/${esPr}"
102109
} else {
103110
value 'Git Commit ID', gitRevision.get()
104111
link 'Source', "https://github.com/${repository}/tree/${gitRevision.get()}"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.gradle.internal;
11+
12+
import org.gradle.api.DefaultTask;
13+
import org.gradle.api.InvalidUserDataException;
14+
import org.gradle.api.provider.MapProperty;
15+
import org.gradle.api.tasks.Input;
16+
import org.gradle.api.tasks.Optional;
17+
18+
import java.util.Map;
19+
20+
public abstract class AbstractDependenciesTask extends DefaultTask {
21+
22+
@Input
23+
@Optional
24+
public abstract MapProperty<String, String> getMappings();
25+
26+
/**
27+
* Add a mapping from a regex pattern for the jar name, to a prefix to find
28+
* the LICENSE and NOTICE file for that jar.
29+
*/
30+
public void mapping(Map<String, String> props) {
31+
String from = props.get("from");
32+
if (from == null) {
33+
throw new InvalidUserDataException("Missing \"from\" setting for license name mapping");
34+
}
35+
String to = props.get("to");
36+
if (to == null) {
37+
throw new InvalidUserDataException("Missing \"to\" setting for license name mapping");
38+
}
39+
if (props.size() > 2) {
40+
throw new InvalidUserDataException("Unknown properties for mapping on dependencyLicenses: " + props.keySet());
41+
}
42+
getMappings().put(from, to);
43+
}
44+
}

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/DependenciesInfoPlugin.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import org.gradle.api.attributes.Usage;
1818
import org.gradle.api.plugins.JavaPlugin;
1919

20+
import static org.elasticsearch.gradle.internal.util.DependenciesUtils.createNonTransitiveArtifactsView;
21+
2022
public class DependenciesInfoPlugin implements Plugin<Project> {
2123

2224
public static String USAGE_ATTRIBUTE = "DependenciesInfo";
@@ -25,16 +27,15 @@ public class DependenciesInfoPlugin implements Plugin<Project> {
2527
public void apply(final Project project) {
2628
project.getPlugins().apply(CompileOnlyResolvePlugin.class);
2729
var depsInfo = project.getTasks().register("dependenciesInfo", DependenciesInfoTask.class);
28-
2930
depsInfo.configure(t -> {
3031
var runtimeConfiguration = project.getConfigurations().getByName(JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME);
31-
t.getRuntimeArtifacts().set(project.getProviders().provider(() -> runtimeConfiguration.getIncoming().getArtifacts()));
32+
t.getRuntimeArtifacts()
33+
.set(project.getProviders().provider(() -> createNonTransitiveArtifactsView(runtimeConfiguration).getArtifacts()));
3234
t.getClasspath().from(runtimeConfiguration);
3335
var compileOnlyConfiguration = project.getConfigurations()
3436
.getByName(CompileOnlyResolvePlugin.RESOLVEABLE_COMPILE_ONLY_CONFIGURATION_NAME);
3537
t.getCompileOnlyArtifacts().set(project.getProviders().provider(() -> compileOnlyConfiguration.getIncoming().getArtifacts()));
3638
t.getClasspath().from(compileOnlyConfiguration);
37-
3839
});
3940
Configuration dependenciesInfoFilesConfiguration = project.getConfigurations().create("dependenciesInfoFiles");
4041
dependenciesInfoFilesConfiguration.setCanBeResolved(false);

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/DependenciesInfoTask.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,21 @@
1717
import org.gradle.api.file.ConfigurableFileCollection;
1818
import org.gradle.api.file.DirectoryProperty;
1919
import org.gradle.api.file.ProjectLayout;
20-
import org.gradle.api.internal.ConventionTask;
2120
import org.gradle.api.model.ObjectFactory;
22-
import org.gradle.api.provider.MapProperty;
2321
import org.gradle.api.provider.Property;
2422
import org.gradle.api.provider.Provider;
2523
import org.gradle.api.provider.ProviderFactory;
24+
import org.gradle.api.tasks.CacheableTask;
25+
import org.gradle.api.tasks.Classpath;
2626
import org.gradle.api.tasks.Input;
2727
import org.gradle.api.tasks.InputDirectory;
28-
import org.gradle.api.tasks.InputFiles;
2928
import org.gradle.api.tasks.Internal;
3029
import org.gradle.api.tasks.Optional;
3130
import org.gradle.api.tasks.OutputFile;
31+
import org.gradle.api.tasks.PathSensitive;
32+
import org.gradle.api.tasks.PathSensitivity;
3233
import org.gradle.api.tasks.TaskAction;
34+
import org.gradle.internal.component.external.model.ModuleComponentArtifactIdentifier;
3335

3436
import java.io.File;
3537
import java.io.IOException;
@@ -55,7 +57,8 @@
5557
* <li>license: <a href="https://spdx.org/licenses/">SPDX license</a> identifier, custom license or UNKNOWN.</li>
5658
* </ul>
5759
*/
58-
public abstract class DependenciesInfoTask extends ConventionTask {
60+
@CacheableTask
61+
public abstract class DependenciesInfoTask extends AbstractDependenciesTask {
5962

6063
@Inject
6164
public abstract ProviderFactory getProviderFactory();
@@ -86,16 +89,17 @@ public Provider<Set<ModuleComponentIdentifier>> getCompileOnlyModules() {
8689
* artifact transforms that might be applied and fail due to missing task dependency to jar
8790
* generating tasks.
8891
* */
89-
@InputFiles
92+
@Classpath
9093
abstract ConfigurableFileCollection getClasspath();
9194

9295
private Provider<Set<ModuleComponentIdentifier>> mapToModuleComponentIdentifiers(ArtifactCollection artifacts) {
9396
return getProviderFactory().provider(
9497
() -> artifacts.getArtifacts()
9598
.stream()
9699
.map(r -> r.getId())
97-
.filter(id -> id instanceof ModuleComponentIdentifier)
98-
.map(id -> (ModuleComponentIdentifier) id)
100+
.filter(mcaId -> mcaId instanceof ModuleComponentArtifactIdentifier)
101+
.map(mcaId -> (ModuleComponentArtifactIdentifier) mcaId)
102+
.map(it -> it.getComponentIdentifier())
99103
.collect(Collectors.toSet())
100104
);
101105
}
@@ -111,6 +115,7 @@ private Provider<Set<ModuleComponentIdentifier>> mapToModuleComponentIdentifiers
111115
* Directory to read license files
112116
*/
113117
@Optional
118+
@PathSensitive(PathSensitivity.RELATIVE)
114119
@InputDirectory
115120
public File getLicensesDir() {
116121
File asFile = licensesDir.get().getAsFile();
@@ -143,7 +148,6 @@ public DependenciesInfoTask(ProjectLayout projectLayout, ObjectFactory objectFac
143148

144149
@TaskAction
145150
public void generateDependenciesInfo() throws IOException {
146-
147151
final Set<String> compileOnlyIds = getCompileOnlyModules().map(
148152
set -> set.stream()
149153
.map(id -> id.getModuleIdentifier().getGroup() + ":" + id.getModuleIdentifier().getName() + ":" + id.getVersion())
@@ -166,18 +170,13 @@ public void generateDependenciesInfo() throws IOException {
166170
final String url = createURL(dep.getGroup(), moduleName, dep.getVersion());
167171
final String dependencyName = DependencyLicensesTask.getDependencyName(mappings, moduleName);
168172
getLogger().info("mapped dependency " + dep.getGroup() + ":" + moduleName + " to " + dependencyName + " for license info");
169-
170173
final String licenseType = getLicenseType(dep.getGroup(), dependencyName);
171174
output.append(dep.getGroup() + ":" + moduleName + "," + dep.getVersion() + "," + url + "," + licenseType + "\n");
172175
}
173176

174177
Files.writeString(outputFile.toPath(), output.toString(), StandardOpenOption.CREATE);
175178
}
176179

177-
@Input
178-
@Optional
179-
public abstract MapProperty<String, String> getMappings();
180-
181180
/**
182181
* Create an URL on <a href="https://repo1.maven.org/maven2/">Maven Central</a>
183182
* based on dependency coordinates.

0 commit comments

Comments
 (0)