Skip to content

Commit 8fa2983

Browse files
authored
Merge branch 'main' into fix_testCancelUnnecessaryRequests
2 parents 430c283 + 65dfaf1 commit 8fa2983

File tree

1,285 files changed

+23646
-10901
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,285 files changed

+23646
-10901
lines changed

Could

Whitespace-only changes.

benchmarks/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ base {
2525
archivesName = 'elasticsearch-benchmarks'
2626
}
2727

28-
tasks.named("test").configure { enabled = false }
2928
tasks.named("javadoc").configure { enabled = false }
3029

3130
configurations {
@@ -52,8 +51,10 @@ dependencies {
5251
api "org.openjdk.jmh:jmh-core:$versions.jmh"
5352
annotationProcessor "org.openjdk.jmh:jmh-generator-annprocess:$versions.jmh"
5453
// Dependencies of JMH
55-
runtimeOnly 'net.sf.jopt-simple:jopt-simple:5.0.4'
54+
runtimeOnly 'net.sf.jopt-simple:jopt-simple:5.0.2'
5655
runtimeOnly 'org.apache.commons:commons-math3:3.6.1'
56+
57+
testImplementation(project(':test:framework'))
5758
}
5859

5960
// enable the JMH's BenchmarkProcessor to generate the final benchmark classes

benchmarks/src/main/java/org/elasticsearch/benchmark/compute/operator/EvalBenchmark.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import org.apache.lucene.util.BytesRef;
1313
import org.elasticsearch.common.breaker.NoopCircuitBreaker;
14+
import org.elasticsearch.common.logging.LogConfigurator;
1415
import org.elasticsearch.common.settings.Settings;
1516
import org.elasticsearch.common.util.BigArrays;
1617
import org.elasticsearch.compute.data.Block;
@@ -28,6 +29,8 @@
2829
import org.elasticsearch.compute.operator.EvalOperator;
2930
import org.elasticsearch.compute.operator.Operator;
3031
import org.elasticsearch.core.TimeValue;
32+
import org.elasticsearch.logging.LogManager;
33+
import org.elasticsearch.logging.Logger;
3134
import org.elasticsearch.xpack.esql.core.expression.Expression;
3235
import org.elasticsearch.xpack.esql.core.expression.FieldAttribute;
3336
import org.elasticsearch.xpack.esql.core.expression.FoldContext;
@@ -89,9 +92,16 @@ public class EvalBenchmark {
8992
static final DriverContext driverContext = new DriverContext(BigArrays.NON_RECYCLING_INSTANCE, blockFactory);
9093

9194
static {
95+
LogConfigurator.configureESLogging();
9296
// Smoke test all the expected values and force loading subclasses more like prod
97+
selfTest();
98+
}
99+
100+
static void selfTest() {
101+
Logger log = LogManager.getLogger(EvalBenchmark.class);
93102
try {
94103
for (String operation : EvalBenchmark.class.getField("operation").getAnnotationsByType(Param.class)[0].value()) {
104+
log.info("self testing {}", operation);
95105
run(operation);
96106
}
97107
} catch (NoSuchFieldException e) {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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.benchmark.compute.operator;
11+
12+
import org.elasticsearch.test.ESTestCase;
13+
14+
public class EvalBenchmarkTests extends ESTestCase {
15+
public void testSelfTest() {
16+
EvalBenchmark.selfTest();
17+
}
18+
}

build-tools-internal/src/main/groovy/elasticsearch.bwc-test.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ plugins.withType(InternalJavaRestTestPlugin) {
4747
tasks.withType(StandaloneRestIntegTestTask).configureEach {
4848
testClassesDirs = sourceSets.javaRestTest.output.classesDirs
4949
classpath = sourceSets.javaRestTest.runtimeClasspath
50-
usesDefaultDistribution()
50+
usesDefaultDistribution("BWC tests require full distribution for now")
5151
}
5252
}
5353

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

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
import org.elasticsearch.gradle.internal.test.ClusterFeaturesMetadataPlugin;
1818
import org.elasticsearch.gradle.plugin.PluginBuildPlugin;
1919
import org.elasticsearch.gradle.plugin.PluginPropertiesExtension;
20-
import org.elasticsearch.gradle.testclusters.ElasticsearchCluster;
21-
import org.elasticsearch.gradle.testclusters.TestClustersPlugin;
2220
import org.elasticsearch.gradle.util.GradleUtils;
23-
import org.gradle.api.NamedDomainObjectContainer;
2421
import org.gradle.api.Plugin;
2522
import org.gradle.api.Project;
2623

@@ -81,29 +78,6 @@ public void doCall() {
8178
if (isModule == false || isXPackModule) {
8279
addNoticeGeneration(project, extension);
8380
}
84-
project.afterEvaluate(p -> {
85-
@SuppressWarnings("unchecked")
86-
NamedDomainObjectContainer<ElasticsearchCluster> testClusters = (NamedDomainObjectContainer<ElasticsearchCluster>) project
87-
.getExtensions()
88-
.getByName(TestClustersPlugin.EXTENSION_NAME);
89-
p.getExtensions().getByType(PluginPropertiesExtension.class).getExtendedPlugins().forEach(pluginName -> {
90-
// Auto add any dependent modules
91-
findModulePath(project, pluginName).ifPresent(
92-
path -> testClusters.configureEach(elasticsearchCluster -> elasticsearchCluster.module(path))
93-
);
94-
});
95-
});
96-
}
97-
98-
Optional<String> findModulePath(Project project, String pluginName) {
99-
return project.getRootProject()
100-
.getAllprojects()
101-
.stream()
102-
.filter(p -> GradleUtils.isModuleProject(p.getPath()))
103-
.filter(p -> p.getPlugins().hasPlugin(PluginBuildPlugin.class))
104-
.filter(p -> p.getExtensions().getByType(PluginPropertiesExtension.class).getName().equals(pluginName))
105-
.findFirst()
106-
.map(Project::getPath);
10781
}
10882

10983
/**

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

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import org.gradle.api.Task;
2020
import org.gradle.api.file.ArchiveOperations;
2121
import org.gradle.api.plugins.BasePlugin;
22+
import org.gradle.api.provider.ListProperty;
23+
import org.gradle.api.provider.Provider;
2224
import org.gradle.api.tasks.Copy;
2325
import org.gradle.api.tasks.TaskProvider;
2426

@@ -103,22 +105,26 @@ private static TaskProvider<Task> registerCheckMlCppNoticeTask(
103105
) {
104106
TaskProvider<Task> checkMlCppNoticeTask = project.getTasks().register("checkMlCppNotice", task -> {
105107
task.dependsOn(checkExtraction);
108+
final Provider<Path> noticePath = checkExtraction.map(
109+
c -> c.getDestinationDir()
110+
.toPath()
111+
.resolve("elasticsearch-" + VersionProperties.getElasticsearch() + "/modules/x-pack-ml/NOTICE.txt")
112+
);
113+
ListProperty<String> expectedMlLicenses = extension.expectedMlLicenses;
106114
task.doLast(new Action<Task>() {
107115
@Override
108116
public void execute(Task task) {
109117
// this is just a small sample from the C++ notices,
110118
// the idea being that if we've added these lines we've probably added all the required lines
111-
final List<String> expectedLines = extension.expectedMlLicenses.get();
112-
final Path noticePath = checkExtraction.get()
113-
.getDestinationDir()
114-
.toPath()
115-
.resolve("elasticsearch-" + VersionProperties.getElasticsearch() + "/modules/x-pack-ml/NOTICE.txt");
119+
final List<String> expectedLines = expectedMlLicenses.get();
116120
final List<String> actualLines;
117121
try {
118-
actualLines = Files.readAllLines(noticePath);
122+
actualLines = Files.readAllLines(noticePath.get());
119123
for (final String expectedLine : expectedLines) {
120124
if (actualLines.contains(expectedLine) == false) {
121-
throw new GradleException("expected [" + noticePath + " to contain [" + expectedLine + "] but it did not");
125+
throw new GradleException(
126+
"expected [" + noticePath.get() + " to contain [" + expectedLine + "] but it did not"
127+
);
122128
}
123129
}
124130
} catch (IOException ioException) {
@@ -133,43 +139,37 @@ public void execute(Task task) {
133139
private TaskProvider<Task> registerCheckNoticeTask(Project project, TaskProvider<Copy> checkExtraction) {
134140
return project.getTasks().register("checkNotice", task -> {
135141
task.dependsOn(checkExtraction);
136-
task.doLast(new Action<Task>() {
137-
@Override
138-
public void execute(Task task) {
139-
final List<String> noticeLines = Arrays.asList("Elasticsearch", "Copyright 2009-2024 Elasticsearch");
140-
final Path noticePath = checkExtraction.get()
141-
.getDestinationDir()
142-
.toPath()
143-
.resolve("elasticsearch-" + VersionProperties.getElasticsearch() + "/NOTICE.txt");
144-
assertLinesInFile(noticePath, noticeLines);
145-
}
142+
var noticePath = checkExtraction.map(
143+
copy -> copy.getDestinationDir().toPath().resolve("elasticsearch-" + VersionProperties.getElasticsearch() + "/NOTICE.txt")
144+
);
145+
task.doLast(t -> {
146+
final List<String> noticeLines = Arrays.asList("Elasticsearch", "Copyright 2009-2024 Elasticsearch");
147+
assertLinesInFile(noticePath.get(), noticeLines);
146148
});
147149
});
148150
}
149151

150152
private TaskProvider<Task> registerCheckLicenseTask(Project project, TaskProvider<Copy> checkExtraction) {
151153
TaskProvider<Task> checkLicense = project.getTasks().register("checkLicense", task -> {
152154
task.dependsOn(checkExtraction);
153-
task.doLast(new Action<Task>() {
154-
@Override
155-
public void execute(Task task) {
156-
String licenseFilename = null;
157-
if (project.getName().contains("oss-") || project.getName().equals("integ-test-zip")) {
158-
licenseFilename = "AGPL-3.0+SSPL-1.0+ELASTIC-LICENSE-2.0.txt";
159-
} else {
160-
licenseFilename = "ELASTIC-LICENSE-2.0.txt";
161-
}
162-
final List<String> licenseLines;
163-
try {
164-
licenseLines = Files.readAllLines(project.getRootDir().toPath().resolve("licenses/" + licenseFilename));
165-
final Path licensePath = checkExtraction.get()
166-
.getDestinationDir()
167-
.toPath()
168-
.resolve("elasticsearch-" + VersionProperties.getElasticsearch() + "/LICENSE.txt");
169-
assertLinesInFile(licensePath, licenseLines);
170-
} catch (IOException ioException) {
171-
ioException.printStackTrace();
172-
}
155+
String projectName = project.getName();
156+
Provider<Path> licensePathProvider = checkExtraction.map(
157+
copy -> copy.getDestinationDir().toPath().resolve("elasticsearch-" + VersionProperties.getElasticsearch() + "/LICENSE.txt")
158+
);
159+
File rootDir = project.getLayout().getSettingsDirectory().getAsFile();
160+
task.doLast(t -> {
161+
String licenseFilename = null;
162+
if (projectName.contains("oss-") || projectName.equals("integ-test-zip")) {
163+
licenseFilename = "AGPL-3.0+SSPL-1.0+ELASTIC-LICENSE-2.0.txt";
164+
} else {
165+
licenseFilename = "ELASTIC-LICENSE-2.0.txt";
166+
}
167+
final List<String> licenseLines;
168+
try {
169+
licenseLines = Files.readAllLines(rootDir.toPath().resolve("licenses/" + licenseFilename));
170+
assertLinesInFile(licensePathProvider.get(), licenseLines);
171+
} catch (IOException ioException) {
172+
ioException.printStackTrace();
173173
}
174174
});
175175
});

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
4949
map.put(LegacyRestTestBasePlugin.class, ":plugins:discovery-ec2");
5050
map.put(LegacyRestTestBasePlugin.class, ":plugins:discovery-gce");
5151
map.put(LegacyRestTestBasePlugin.class, ":plugins:mapper-annotated-text");
52-
map.put(LegacyRestTestBasePlugin.class, ":plugins:mapper-murmur3");
53-
map.put(LegacyRestTestBasePlugin.class, ":plugins:repository-hdfs");
5452
map.put(LegacyRestTestBasePlugin.class, ":plugins:store-smb");
5553
map.put(LegacyRestTestBasePlugin.class, ":qa:ccs-rolling-upgrade-remote-cluster");
5654
map.put(LegacyRestTestBasePlugin.class, ":qa:mixed-cluster");
@@ -74,11 +72,7 @@ private static ListMultimap<Class<?>, String> createLegacyRestTestBasePluginUsag
7472
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:ent-search");
7573
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:fleet");
7674
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:logstash");
77-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:mapper-constant-keyword");
78-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:mapper-unsigned-long");
79-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:mapper-version");
8075
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:vector-tile");
81-
map.put(LegacyRestTestBasePlugin.class, ":x-pack:plugin:wildcard");
8276
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:mixed-tier-cluster");
8377
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:repository-old-versions");
8478
map.put(LegacyRestTestBasePlugin.class, ":x-pack:qa:rolling-upgrade");

build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/test/rest/RestTestBasePlugin.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ public void apply(Project project) {
198198
task.getExtensions().getExtraProperties().set("usesDefaultDistribution", new Closure<Void>(task) {
199199
@Override
200200
public Void call(Object... args) {
201+
if (reasonForUsageProvided(args) == false) {
202+
throw new IllegalArgumentException(
203+
"Reason for using `usesDefaultDistribution` required.\nUse usesDefaultDistribution(\"reason why default distro is required here\")."
204+
);
205+
}
201206
task.dependsOn(defaultDistro);
202207
registerDistributionInputs(task, defaultDistro);
203208

@@ -212,6 +217,10 @@ public Void call(Object... args) {
212217

213218
return null;
214219
}
220+
221+
private static boolean reasonForUsageProvided(Object[] args) {
222+
return args.length == 1 && args[0] instanceof String && ((String) args[0]).isBlank() == false;
223+
}
215224
});
216225

217226
// Add `usesBwcDistribution(version)` extension method to test tasks to indicate they require a BWC distribution

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
*/
3030
public abstract class ArchivedOracleJdkToolchainResolver extends AbstractCustomJavaToolchainResolver {
3131

32-
private static final Map<Integer, String> ARCHIVED_BASE_VERSIONS = Maps.of(20, "20.0.2", 19, "19.0.2", 18, "18.0.2.1");
32+
private static final Map<Integer, String> ARCHIVED_BASE_VERSIONS = Maps.of(21, "21.0.6", 20, "20.0.2", 19, "19.0.2", 18, "18.0.2.1");
3333

3434
@Override
3535
public Optional<JavaToolchainDownload> resolve(JavaToolchainRequest request) {

0 commit comments

Comments
 (0)