Skip to content

Commit 93013ff

Browse files
committed
Merge remote-tracking branch 'es/main' into tests/TSDBDocValuesFormatSingleNodeTests
2 parents a9f6ac8 + a894551 commit 93013ff

File tree

359 files changed

+18460
-2215
lines changed

Some content is hidden

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

359 files changed

+18460
-2215
lines changed

AGENTS.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
- **Cursor/Copilot rules**: None provided in repo; follow this guide plus CONTRIBUTING.md.
99

1010
## Build & Run Commands
11-
- Refer to CONTRIBUTING.md & TESTING.asciidoc for comprehensive build/test instructions.
11+
- Refer to BUILDING.md, CONTRIBUTING.md & TESTING.asciidoc for comprehensive build/test instructions.
1212

1313
## Verification & Lint Tasks
1414
- `./gradlew spotlessJavaCheck` / `spotlessApply` (or `:server:spotlessJavaCheck`): enforce formatter profile in `build-conventions/formatterConfig.xml`.
@@ -23,7 +23,7 @@ The repository is organized into several key directories:
2323
* `docs`: Project documentation.
2424
* `distribution`: Logic for building distribution packages.
2525
* `x-pack`: Additional code modules and plugins under Elastic License.
26-
* `build-conventions`, `build-tools`, `build-tools-internal`: Gradle build logic.
26+
* `build-conventions`, `build-tools`, `build-tools-internal`: Gradle build logic. Refer to BUILDING.md for details on how these are structured and used.
2727

2828
## Testing Cheatsheet
2929
- Standard suite: `./gradlew test` (respects cached results; add `-Dtests.timestamp=$(date +%s)` to bypass caches when reusing seeds).
@@ -38,7 +38,7 @@ The repository is organized into several key directories:
3838
- Yaml REST tests: `./gradlew ":rest-api-spec:yamlRestTest" --tests "org.elasticsearch.test.rest.ClientYamlTestSuiteIT.test {yaml=<relative_test_file_path>}"`
3939
- Use the Elasticsearch testing framework where possible for unit and yaml tests and be consistent in style with other elasticsearch tests.
4040
- Use real classes over mocks or stubs for unit tests, unless the real class is complex then either a simplified subclass should be created within the test or, as a last resort, a mock or stub can be used. Unit tests must be as close to real-world scenarios as possible.
41-
- Ensure mocks or stubs are well-documented and clearly indicate why they were necessary.
41+
- Ensure mocks or stubs are well-documented and clearly indicate why they were necessary.
4242

4343
### Test Types
4444
- Unit Tests: Preferred. Extend `ESTestCase`.

BUILDING.md

Lines changed: 132 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,60 @@ These build tools are also used by the `elasticsearch-hadoop` project maintained
2727

2828
### `build-tools-internal`
2929

30-
This project contains all Elasticsearch project specific build logic that is not meant to be shared
30+
This project contains all Elasticsearch project specific build logic not meant to be shared
3131
with other internal or external projects.
3232

33+
## Third-Party Gradle Plugins
34+
35+
The Elasticsearch build uses several third-party Gradle plugins. All versions are centralized in
36+
`/gradle/build.versions.toml` (version catalog).
37+
38+
### Build Infrastructure Plugins
39+
40+
| Plugin ID | Purpose |
41+
|-----------|---------|
42+
| `com.gradle.develocity` | Enables build scans and integration with Gradle Enterprise at `gradle-enterprise.elastic.co`. Provides build performance metrics, failure diagnostics, and CI integration for Buildkite. |
43+
| `com.gradleup.nmcp.aggregation` | Aggregates all Maven artifacts from projects applying `elasticsearch.publish` for publishing to Maven Central via DRA infrastructure. |
44+
45+
### Packaging & Distribution Plugins
46+
47+
| Plugin ID | Purpose |
48+
|-----------|---------|
49+
| `com.netflix.nebula.ospackage-base` | Creates DEB and RPM Linux packages for Elasticsearch distribution. Handles package metadata, install/remove scripts, file permissions, and package signing. |
50+
| `com.gradleup.shadow` | Creates fat JARs (uber-jars) by merging dependencies into a single JAR. Used for standalone CLI tools (`plugin-cli`, `sql-cli`) and the JDBC driver. |
51+
52+
### Code Quality & Precommit Plugins
53+
54+
| Plugin ID | Purpose |
55+
|-----------|---------|
56+
| `de.thetaphi:forbiddenapis` | Static bytecode analysis that detects invocations of forbidden API methods. Ensures code doesn't use unsafe or deprecated JDK APIs. Integrated via `ForbiddenApisPrecommitPlugin`. |
57+
| `org.apache.rat:apache-rat` | License header validation (Apache RAT - Release Audit Tool). Ensures all source files have proper license headers. |
58+
| `com.diffplug.spotless` | Code formatting enforcement using Eclipse JDT formatter. Provides `spotlessJavaCheck` and `spotlessApply` tasks. Configuration in `build-conventions/formatterConfig.xml`. |
59+
60+
### Build Metadata & Tooling Plugins
61+
62+
| Plugin ID | Purpose |
63+
|-----------|---------|
64+
| `com.netflix.nebula:gradle-info-plugin` | Automatically includes build metadata (git info, build time, Java version) in JAR manifests. Applied as `nebula.info-broker`, `nebula.info-basic`, `nebula.info-java`, `nebula.info-jar`. |
65+
| `com.avast.gradle:docker-compose` | Manages Docker Compose environments for integration testing fixtures. Used by `TestFixturesPlugin` for test infrastructure (AWS, Azure, GCS, HDFS mocks). |
66+
| `org.jetbrains.gradle.plugin.idea-ext` | Enhanced IntelliJ IDEA project configuration. Customizes IDE settings, JUnit configurations, and post-sync tasks. |
67+
68+
## Internal Plugin Selection Guide
69+
70+
When creating a new subproject, choose the appropriate Elasticsearch plugin based on your project type:
71+
72+
| Project Type | Plugin to Apply | Example Projects |
73+
|--------------|-----------------|------------------|
74+
| Core library | `elasticsearch.build` | `server`, `libs/*` |
75+
| Module shipped with ES | `elasticsearch.internal-es-plugin` | `modules/*` |
76+
| External plugin | `elasticsearch.internal-es-plugin` + `elasticsearch.publish` | `plugins/*` |
77+
| X-Pack plugin | `elasticsearch.internal-es-plugin` + `elasticsearch.publish` | `x-pack/plugin/*` |
78+
| YAML REST tests | `elasticsearch.internal-yaml-rest-test` | modules/plugins with REST APIs |
79+
| Java REST tests | `elasticsearch.internal-java-rest-test` | modules/plugins needing Java test flexibility |
80+
| Cluster integration tests | `elasticsearch.internal-cluster-test` | Projects testing cluster behavior |
81+
| BWC/upgrade tests | `elasticsearch.bwc-test` or `elasticsearch.fwc-test` | `qa/rolling-upgrade`, `qa/full-cluster-restart` |
82+
| Standalone QA project | `elasticsearch.standalone-rest-test` | `qa/*` subprojects |
83+
3384
## Build guidelines
3485

3586
This is an intentionally small set of guidelines to build users and authors
@@ -161,16 +212,25 @@ When adding or updating dependencies, ensure that any required transitive depend
161212
2. Added as direct dependencies if they're actually used by our code
162213
3. Properly excluded if they're not needed
163214

164-
#### Custom plugin and task implementations
215+
#### Custom Gradle plugin and Gradle task implementations
165216

166-
Build logic that is used across multiple subprojects should be considered to be moved into a Gradle plugin with according Gradle task implementation.
167-
Elasticsearch specific build logic is located in the `build-tools-internal` subproject including integration tests.
217+
Build logic that is used across multiple subprojects should be considered to be
218+
moved into a Gradle plugin with according Gradle task implementation.
219+
Elasticsearch specific build logic is located in the `build-tools-internal`
220+
subproject including integration tests.
168221

169222
- Gradle plugins and Tasks should be written in Java
170223
- We use a groovy and spock for setting up Gradle integration tests.
171-
(see https://github.com/elastic/elasticsearch/blob/main/build-tools/src/testFixtures/groovy/org/elasticsearch/gradle/fixtures/AbstractGradleFuncTest.groovy)
224+
- For each Gradle Plugin and Gradle Task implementation (e.g.
225+
org.elasticsearch.gradle.internal.info.GlobalBuildInfoPlugin) we aim for
226+
a dedicated
227+
- unit test class containing all relaed unit tests in src/test (e.g. GlobalBuildInfoPluginSpec) for basic unit testing of
228+
the plugin logic and
229+
- integration test containing all related Gradle TestKit based integration tests in src/integTest (e.g. GlobalBuildInfoPluginFuncTest) for testing the
230+
plugin in a real Gradle build based on
231+
src/main/build-tools/src/testFixtures/groovy/org/elasticsearch/gradle/fixtures/AbstractGradleFuncTest.groovy)
172232

173-
#### Declaring tasks
233+
#### Declaring Gradle tasks
174234

175235
The Elasticsearch build makes use of the [task avoidance API](https://docs.gradle.org/current/userguide/task_configuration_avoidance.html) to keep the configuration time of the build low.
176236

@@ -244,6 +304,69 @@ dependencies {
244304
}
245305
```
246306

307+
#### Configuring precommit tasks
308+
309+
Several precommit tasks support project-specific configuration. Use the task avoidance API when configuring them.
310+
311+
##### thirdPartyAudit
312+
313+
Configure missing class and violation ignores when third-party dependencies use optional APIs:
314+
315+
```groovy
316+
tasks.named("thirdPartyAudit").configure {
317+
// Ignore classes that are optional dependencies of our dependencies
318+
ignoreMissingClasses(
319+
'javax.servlet.ServletContextEvent',
320+
'org.apache.log.Logger'
321+
)
322+
323+
// Ignore known-safe internal API usage in dependencies
324+
ignoreViolations(
325+
'com.google.common.hash.Striped64'
326+
)
327+
}
328+
```
329+
330+
##### dependencyLicenses
331+
332+
Map related artifacts to a single license when dependencies are published as multiple JARs:
333+
334+
```groovy
335+
tasks.named("dependencyLicenses").configure {
336+
mapping from: /lucene-.*/, to: 'lucene'
337+
mapping from: /netty-.*/, to: 'netty'
338+
mapping from: /jackson-.*/, to: 'jackson'
339+
}
340+
```
341+
342+
##### forbiddenPatterns
343+
344+
Exclude files that legitimately contain patterns detected as forbidden:
345+
346+
```groovy
347+
tasks.named("forbiddenPatterns").configure {
348+
exclude '**/*.key' // Test certificates
349+
exclude '**/*.p12' // PKCS12 keystores
350+
exclude '**/*.json' // Test data files
351+
}
352+
```
353+
354+
#### Configuring REST resources
355+
356+
Projects with REST APIs should declare which specs and tests they need:
357+
358+
```groovy
359+
restResources {
360+
restApi {
361+
include '_common', 'cluster', 'indices', 'your_api_name'
362+
}
363+
restTests {
364+
includeCore 'your_api_tests' // For core APIs
365+
includeXpack 'your_xpack_tests' // For X-Pack APIs
366+
}
367+
}
368+
```
369+
247370
## FAQ
248371

249372
### How do I test a development version of a third party dependency?
@@ -314,7 +437,7 @@ by JitPack in the background before we can resolve the adhoc built dependency.
314437

315438
> [!Note]
316439
> You should only use that approach locally or on a developer branch for production dependencies as we do
317-
not want to ship unreleased libraries into our releases.
440+
> not want to ship unreleased libraries into our releases.
318441
319442
#### How to use a custom third party artifact?
320443

@@ -352,7 +475,7 @@ allprojects {
352475

353476
> [!Note]
354477
> As Gradle prefers to use modules whose descriptor has been created from real meta-data rather than being generated,
355-
flat directory repositories cannot be used to override artifacts with real meta-data from other repositories declared in the build.
478+
> flat directory repositories cannot be used to override artifacts with real meta-data from other repositories declared in the build.
356479
> For example, if Gradle finds only `jmxri-1.2.1.jar` in a flat directory repository, but `jmxri-1.2.1.pom` in another repository
357-
that supports meta-data, it will use the second repository to provide the module.
480+
> that supports meta-data, it will use the second repository to provide the module.
358481
> Therefore, it is recommended to declare a version that is not resolvable from public repositories we use (e.g. Maven Central)
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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;
11+
12+
import org.elasticsearch.common.logging.LogConfigurator;
13+
import org.elasticsearch.common.logging.NodeNamePatternConverter;
14+
15+
public final class Utils {
16+
17+
private Utils() {
18+
// utility class
19+
}
20+
21+
static {
22+
LogConfigurator.setClusterName("elasticsearch-benchmark");
23+
LogConfigurator.setNodeName("test");
24+
}
25+
26+
public static void configureBenchmarkLogging() {
27+
LogConfigurator.loadLog4jPlugins();
28+
NodeNamePatternConverter.setGlobalNodeName("benchmark");
29+
LogConfigurator.configureESLogging();
30+
}
31+
32+
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
package org.elasticsearch.benchmark._nightly.esql;
1111

1212
import org.elasticsearch.TransportVersion;
13-
import org.elasticsearch.common.logging.LogConfigurator;
13+
import org.elasticsearch.benchmark.Utils;
1414
import org.elasticsearch.common.settings.Settings;
1515
import org.elasticsearch.index.IndexMode;
1616
import org.elasticsearch.license.XPackLicenseState;
@@ -70,7 +70,7 @@
7070
public class QueryPlanningBenchmark {
7171

7272
static {
73-
LogConfigurator.configureESLogging();
73+
Utils.configureBenchmarkLogging();
7474
}
7575

7676
private PlanTelemetry telemetry;

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
package org.elasticsearch.benchmark._nightly.esql;
1111

1212
import org.apache.lucene.util.BytesRef;
13+
import org.elasticsearch.benchmark.Utils;
1314
import org.elasticsearch.common.breaker.CircuitBreaker;
1415
import org.elasticsearch.common.breaker.NoopCircuitBreaker;
15-
import org.elasticsearch.common.logging.LogConfigurator;
1616
import org.elasticsearch.common.settings.ClusterSettings;
1717
import org.elasticsearch.common.settings.Settings;
1818
import org.elasticsearch.common.util.BigArrays;
@@ -57,9 +57,6 @@
5757
@State(Scope.Thread)
5858
@Fork(1)
5959
public class TopNBenchmark {
60-
static {
61-
LogConfigurator.configureESLogging();
62-
}
6360

6461
private static final BlockFactory blockFactory = BlockFactory.getInstance(
6562
new NoopCircuitBreaker("noop"),
@@ -80,7 +77,7 @@ public class TopNBenchmark {
8077
private static final String AND = "_and_";
8178

8279
static {
83-
LogConfigurator.configureESLogging();
80+
Utils.configureBenchmarkLogging();
8481
// Smoke test all the expected values and force loading subclasses more like prod
8582
selfTest();
8683
}
@@ -159,6 +156,7 @@ private static Operator operator(String data, int topCount, boolean sortedInput)
159156
encoders,
160157
sortOrders,
161158
8 * 1024,
159+
Long.MAX_VALUE,
162160
sortedInput ? TopNOperator.InputOrdering.SORTED : TopNOperator.InputOrdering.NOT_SORTED,
163161
minCompetitive // This is optional, but doesn't add much overhead either way
164162
);

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
import org.apache.lucene.store.Directory;
2424
import org.apache.lucene.util.BytesRef;
2525
import org.apache.lucene.util.NumericUtils;
26+
import org.elasticsearch.benchmark.Utils;
2627
import org.elasticsearch.cluster.metadata.IndexMetadata;
2728
import org.elasticsearch.common.breaker.NoopCircuitBreaker;
28-
import org.elasticsearch.common.logging.LogConfigurator;
2929
import org.elasticsearch.common.settings.Settings;
3030
import org.elasticsearch.common.unit.ByteSizeValue;
3131
import org.elasticsearch.common.util.BigArrays;
@@ -93,8 +93,9 @@
9393
@State(Scope.Thread)
9494
@Fork(1)
9595
public class ValuesSourceReaderBenchmark {
96+
9697
static {
97-
LogConfigurator.configureESLogging();
98+
Utils.configureBenchmarkLogging();
9899
}
99100

100101
private static final String[] SUPPORTED_LAYOUTS = new String[] { "in_order", "shuffled", "shuffled_singles" };
@@ -317,7 +318,8 @@ public void benchmark() {
317318
throw new UnsupportedOperationException("can't load _source here");
318319
}, EsqlPlugin.STORED_FIELDS_SEQUENTIAL_PROPORTION.getDefault(Settings.EMPTY))),
319320
reuseColumnLoaders,
320-
0
321+
0,
322+
PlannerSettings.SOURCE_RESERVATION_FACTOR.getDefault(Settings.EMPTY)
321323
);
322324
long sum = 0;
323325
for (Page page : pages) {

benchmarks/src/main/java/org/elasticsearch/benchmark/bytes/BytesArrayIndexOfBenchmark.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
*/
99
package org.elasticsearch.benchmark.bytes;
1010

11+
import org.elasticsearch.benchmark.Utils;
1112
import org.elasticsearch.common.bytes.BytesArray;
12-
import org.elasticsearch.common.logging.LogConfigurator;
1313
import org.openjdk.jmh.annotations.Benchmark;
1414
import org.openjdk.jmh.annotations.BenchmarkMode;
1515
import org.openjdk.jmh.annotations.Fork;
@@ -33,7 +33,7 @@
3333
public class BytesArrayIndexOfBenchmark {
3434

3535
static {
36-
LogConfigurator.configureESLogging(); // native access requires logging to be initialized
36+
Utils.configureBenchmarkLogging();
3737
}
3838

3939
static final byte MARKER = (byte) '\n';

benchmarks/src/main/java/org/elasticsearch/benchmark/common/util/CodePointCountBenchmark.java

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

1212
import org.apache.lucene.util.BytesRef;
1313
import org.apache.lucene.util.UnicodeUtil;
14-
import org.elasticsearch.common.logging.LogConfigurator;
14+
import org.elasticsearch.benchmark.Utils;
1515
import org.elasticsearch.simdvec.ESVectorUtil;
1616
import org.openjdk.jmh.annotations.Benchmark;
1717
import org.openjdk.jmh.annotations.BenchmarkMode;
@@ -37,7 +37,7 @@
3737
public class CodePointCountBenchmark {
3838

3939
static {
40-
LogConfigurator.configureESLogging(); // native access requires logging to be initialized
40+
Utils.configureBenchmarkLogging();
4141
}
4242

4343
@Param({ "1", "5", "10", "20", "50", "100", "1000" })

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
package org.elasticsearch.benchmark.compute.operator;
1111

1212
import org.apache.lucene.util.BytesRef;
13+
import org.elasticsearch.benchmark.Utils;
1314
import org.elasticsearch.common.breaker.NoopCircuitBreaker;
14-
import org.elasticsearch.common.logging.LogConfigurator;
1515
import org.elasticsearch.common.util.BigArrays;
1616
import org.elasticsearch.compute.aggregation.AggregatorFunctionSupplier;
1717
import org.elasticsearch.compute.aggregation.AggregatorMode;
@@ -115,7 +115,7 @@ public class AggregatorBenchmark {
115115
private static final String CONSTANT_FALSE = "constant_false";
116116

117117
static {
118-
LogConfigurator.configureESLogging(); // native access requires logging to be initialized
118+
Utils.configureBenchmarkLogging();
119119

120120
// Smoke test all the expected values and force loading subclasses more like prod
121121
if (false == "true".equals(System.getProperty("skipSelfTest"))) {

0 commit comments

Comments
 (0)