Skip to content

Commit e3b7256

Browse files
committed
Merge branch 'upstream/master' into tsdb-deal-timestreamp
* upstream/master: (521 commits) Migrate custom role providers to licensed feature (elastic#79127) Remove stale AwaitsFix in InternalEngineTests (elastic#79323) Fix errors in RefreshListenersTests (elastic#79324) Reeable BwC Tests after elastic#79318 (elastic#79320) Mute BwC Tests for elastic#79318 (elastic#79319) Reenable BwC Tests after elastic#79308 (elastic#79313) Disable BwC Tests for elastic#79308 (elastic#79310) Adjust BWC for node-level field cap requests (elastic#79301) Allow total memory to be overridden (elastic#78750) Fix SnapshotBasedIndexRecoveryIT#testRecoveryIsCancelledAfterDeletingTheIndex (elastic#79269) Disable BWC tests Mute GeoIpDownloaderCliIT.testStartWithNoDatabases (elastic#79299) Add alias support to fleet search API (elastic#79285) Create a coordinating node level reader for tsdb (elastic#79197) Route documents to the correct shards in tsdb (elastic#77731) Inject migrate action regardless of allocate action (elastic#79090) Migrate to data tiers should always ensure a TIER_PREFERENCE is set (elastic#79100) Skip building of BWC distributions when building release artifacts (elastic#79180) Default ENFORCE_DEFAULT_TIER_PREFERENCE to true (elastic#79275) Deprecation of transient cluster settings (elastic#78794) ... # Conflicts: # rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/tsdb/10_settings.yml # server/src/main/java/org/elasticsearch/common/settings/IndexScopedSettings.java # server/src/main/java/org/elasticsearch/common/settings/Setting.java # server/src/main/java/org/elasticsearch/index/IndexMode.java # server/src/test/java/org/elasticsearch/index/TimeSeriesModeTests.java
2 parents 0e67726 + fceacfe commit e3b7256

File tree

7,220 files changed

+96176
-52750
lines changed

Some content is hidden

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

7,220 files changed

+96176
-52750
lines changed

.ci/bwcVersions

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ BWC_VERSION:
4141
- "7.14.0"
4242
- "7.14.1"
4343
- "7.14.2"
44-
- "7.14.3"
4544
- "7.15.0"
45+
- "7.15.1"
46+
- "7.15.2"
4647
- "7.16.0"
4748
- "8.0.0"

.ci/jobs.t/defaults.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
concurrent: true
1616
logrotate:
1717
daysToKeep: 30
18-
numToKeep: 90
18+
numToKeep: 500
1919
artifactDaysToKeep: 7
2020
parameters:
2121
- string:

.idea/eclipseCodeFormatter.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations/Debug_Elasticsearch.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

BUILDING.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,23 @@ The major difference between these two syntaxes is, that the configuration block
7878

7979
By actually doing less in the gradle configuration time as only creating tasks that are requested as part of the build and by only running the configurations for those requested tasks, using the task avoidance api contributes a major part in keeping our build fast.
8080

81+
#### Registering test clusters
82+
83+
When using the elasticsearch test cluster plugin we want to use (similar to the task avoidance API) a Gradle API to create domain objects lazy or only if required by the build.
84+
Therefore we register test cluster by using the following syntax:
85+
86+
def someClusterProvider = testClusters.register('someCluster') { ... }
87+
88+
This registers a potential testCluster named `somecluster` and provides a provider instance, but doesn't create it yet nor configures it. This makes the gradle configuration phase more efficient by
89+
doing less.
90+
91+
To wire this registered cluster into a `TestClusterAware` task (e.g. `RestIntegTest`) you can resolve the actual cluster from the provider instance:
92+
93+
tasks.register('someClusterTest', RestIntegTestTask) {
94+
useCluster someClusterProvider
95+
nonInputProperties.systemProperty 'tests.leader_host', "${-> someClusterProvider.get().getAllHttpSocketURI().get(0)}"
96+
}
97+
8198
#### Adding additional integration tests
8299

83100
Additional integration tests for a certain elasticsearch modules that are specific to certain cluster configuration can be declared in a separate so called `qa` subproject of your module.
@@ -118,3 +135,99 @@ dependencies {
118135
}
119136
}
120137
```
138+
139+
## FAQ
140+
141+
### How do I test a development version of a third party dependency?
142+
143+
To test an unreleased development version of a third party dependency you have several options.
144+
145+
#### How to use a maven based third party dependency via mavenlocal?
146+
147+
1. Clone the third party repository locally
148+
2. Run `mvn install` to install copy into your `~/.m2/repository` folder.
149+
3. Add this to the root build script:
150+
151+
```
152+
allprojects {
153+
repositories {
154+
mavenLocal()
155+
}
156+
}
157+
```
158+
4. Update the version in your dependency declaration accordingly (likely a snapshot version)
159+
5. Run the gradle build as needed
160+
161+
#### How to use a maven built based third party dependency with jitpack repository?
162+
163+
https://jitpack.io is an adhoc repository that supports building maven projects transparently in the background when
164+
resolving unreleased snapshots from a github repository. This approach also works as temporally solution
165+
and is compliant with our CI builds.
166+
167+
1. Add the JitPack repository to the root build file:
168+
169+
```
170+
allprojects {
171+
repositories {
172+
maven { url "https://jitpack.io" }
173+
}
174+
}
175+
```
176+
2. Add the dependency in the following format
177+
```
178+
dependencies {
179+
implementation 'com.github.User:Repo:Tag'
180+
}
181+
```
182+
183+
As version you could also use a certain short commit hash or `master-SNAPSHOT`.
184+
In addition to snapshot builds JitPack supports building Pull Requests. Simply use PR<NR>-SNAPSHOT as the version.
185+
186+
3. Run the gradle build as needed. Keep in mind the initial resolution might take a bit longer as this needs to be built
187+
by JitPack in the background before we can resolve the adhoc built dependency.
188+
189+
---
190+
191+
**NOTE**
192+
193+
You should only use that approach locally or on a developer branch for for production dependencies as we do
194+
not want to ship unreleased libraries into our releases.
195+
---
196+
197+
#### How to use a custom third party artifact?
198+
199+
For third party libraries that are not built with maven (e.g. ant) or provided as a plain jar artifact we can leverage
200+
a flat directory repository that resolves artifacts from a flat directory on your filesystem.
201+
202+
1. Put the jar artifact with the format `artifactName-version.jar` into a directory named `localRepo` (you have to create this manually)
203+
2. Declare a flatDir repository in your root build.gradle file
204+
205+
```
206+
allprojects {
207+
repositories {
208+
flatDir {
209+
dirs 'localRepo'
210+
}
211+
}
212+
}
213+
```
214+
215+
3. Update the dependency declaration of the artifact in question to match the custom build version. For a file named e.g. `jmxri-1.2.1.jar` the
216+
dependency definition would be `:jmxri:1.2.1` as it comes with no group information:
217+
218+
```
219+
dependencies {
220+
implementation ':jmxri:1.2.1'
221+
}
222+
```
223+
4. Run the gradle build as needed.
224+
225+
---
226+
**NOTE**
227+
228+
As Gradle prefers to use modules whose descriptor has been created from real meta-data rather than being generated,
229+
flat directory repositories cannot be used to override artifacts with real meta-data from other repositories declared in the build.
230+
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
231+
that supports meta-data, it will use the second repository to provide the module.
232+
Therefore it is recommended to declare a version that is not resolveable from public repositories we use (e.g. maven central)
233+
---

CONTRIBUTING.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,14 @@ need them.
193193
2. Click "Use the Eclipse Code Formatter"
194194
3. Under "Eclipse formatter config", select "Eclipse workspace/project
195195
folder or config file"
196-
4. Click "Browse", and navigate to the file `build-tools-internal/formatterConfig.xml`
196+
4. Click "Browse", and navigate to the file `build-conventions/formatterConfig.xml`
197197
5. **IMPORTANT** - make sure "Optimize Imports" is **NOT** selected.
198198
6. Click "OK"
199199

200200
Note that only some sub-projects in the Elasticsearch project are currently
201201
fully-formatted. You can see a list of project that **are not**
202202
automatically formatted in
203-
[build-tools-internal/src/main/groovy/elasticsearch.formatting.gradle](build-tools-internal/src/main/groovy/elasticsearch.formatting.gradle).
203+
[FormattingPrecommitPlugin.java](build-conventions/src/main/java/org/elasticsearch/gradle/internal/conventions/precommit/FormattingPrecommitPlugin.java).
204204

205205
### Importing the project into Eclipse
206206

@@ -234,15 +234,15 @@ Next you'll want to import our auto-formatter:
234234
- Select **Window > Preferences**
235235
- Select **Java > Code Style > Formatter**
236236
- Click **Import**
237-
- Import the file at **build-tools-internal/formatterConfig.xml**
237+
- Import the file at **build-conventions/formatterConfig.xml**
238238
- Make sure it is the **Active profile**
239239

240240
Finally, set up import order:
241241

242242
- Select **Window > Preferences**
243243
- Select **Java > Code Style > Organize Imports**
244244
- Click **Import...**
245-
- Import the file at **build-tools-internal/elastic.importorder**
245+
- Import the file at **build-conventions/elastic.importorder**
246246
- Set the **Number of imports needed for `.*`** to ***9999***
247247
- Set the **Number of static imports needed for `.*`** to ***9999*** as well
248248
- Apply that
@@ -279,11 +279,12 @@ form.
279279
Java files in the Elasticsearch codebase are automatically formatted using
280280
the [Spotless Gradle] plugin. All new projects are automatically formatted,
281281
while existing projects are gradually being opted-in. The formatting check
282-
can be run explicitly with:
282+
is run automatically via the `precommit` task, but it can be run explicitly with:
283283

284284
./gradlew spotlessJavaCheck
285285

286-
The code can be formatted with:
286+
It is usually more useful, and just as fast, to just reformat the project. You
287+
can do this with:
287288

288289
./gradlew spotlessApply
289290

@@ -304,10 +305,9 @@ Please follow these formatting guidelines:
304305
* Wildcard imports (`import foo.bar.baz.*`) are forbidden and will cause
305306
the build to fail.
306307
* If *absolutely* necessary, you can disable formatting for regions of code
307-
with the `// tag::NAME` and `// end::NAME` directives, but note that
308-
these are intended for use in documentation, so please make it clear what
309-
you have done, and only do this where the benefit clearly outweighs the
310-
decrease in consistency.
308+
with the `// @formatter:off` and `// @formatter:on` directives, but
309+
only do this where the benefit clearly outweighs the decrease in formatting
310+
consistency.
311311
* Note that Javadoc and block comments i.e. `/* ... */` are not formatted,
312312
but line comments i.e `// ...` are.
313313
* Negative boolean expressions must use the form `foo == false` instead of

NOTICE.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,3 @@ Copyright 2009-2021 Elasticsearch
33

44
This product includes software developed by The Apache Software
55
Foundation (http://www.apache.org/).
6-
7-
This product includes software developed by
8-
Joda.org (http://www.joda.org/).

TESTING.asciidoc

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,36 @@ memory or some of the containers will fail to start. You can tell that you
283283
are short of memory if containers are exiting quickly after starting with
284284
code 137 (128 + 9, where 9 means SIGKILL).
285285

286+
== Debugging tests
287+
288+
If you would like to debug your tests themselves, simply pass the `--debug-jvm`
289+
flag to the testing task and connect a debugger on the default port of `5005`.
290+
291+
---------------------------------------------------------------------------
292+
./gradlew :server:test --debug-jvm
293+
---------------------------------------------------------------------------
294+
295+
For REST tests, if you'd like to debug the Elasticsearch server itself, and
296+
not your test code, use the `--debug-server-jvm` flag and use the
297+
"Debug Elasticsearch" run configuration in IntelliJ to listen on the default
298+
port of `5007`.
299+
300+
---------------------------------------------------------------------------
301+
./gradlew :rest-api-spec:yamlRestTest --debug-server-jvm
302+
---------------------------------------------------------------------------
303+
304+
NOTE: In the case of test clusters using multiple nodes, multiple debuggers
305+
will need to be attached on incrementing ports. For example, for a 3 node
306+
cluster ports `5007`, `5008`, and `5009` will attempt to attach to a listening
307+
debugger.
308+
309+
You can also use a combination of both flags to debug both tests and server.
310+
This is only applicable to Java REST tests.
311+
312+
---------------------------------------------------------------------------
313+
./gradlew :modules:kibana:javaRestTest --debug-jvm --debug-server-jvm
314+
---------------------------------------------------------------------------
315+
286316
== Testing the REST layer
287317

288318
The REST layer is tested through specific tests that are executed against
@@ -324,7 +354,7 @@ A specific test case can be run with the following command:
324354
---------------------------------------------------------------------------
325355
./gradlew ':rest-api-spec:yamlRestTest' \
326356
--tests "org.elasticsearch.test.rest.ClientYamlTestSuiteIT" \
327-
-Dtests.method="test {p0=cat.segments/10_basic/Help}"
357+
-Dtests.method="test {yaml=cat.segments/10_basic/Help}"
328358
---------------------------------------------------------------------------
329359

330360
The YAML REST tests support all the options provided by the randomized runner, plus the following:

benchmarks/src/main/java/org/elasticsearch/benchmark/fs/AvailableIndexFoldersBenchmark.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ public class AvailableIndexFoldersBenchmark {
4444
@Setup
4545
public void setup() throws IOException {
4646
Path path = Files.createTempDirectory("test");
47+
String[] paths = new String[] { path.toString() };
4748
nodePath = new NodeEnvironment.NodePath(path);
4849

4950
LogConfigurator.setNodeName("test");
5051
Settings settings = Settings.builder()
5152
.put(Environment.PATH_HOME_SETTING.getKey(), path)
52-
.put(Environment.PATH_DATA_SETTING.getKey(), path.resolve("data"))
53+
.putList(Environment.PATH_DATA_SETTING.getKey(), paths)
5354
.build();
5455
nodeEnv = new NodeEnvironment(settings, new Environment(settings, null));
5556

benchmarks/src/main/java/org/elasticsearch/benchmark/routing/allocation/AllocationBenchmark.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import org.elasticsearch.cluster.metadata.Metadata;
1515
import org.elasticsearch.cluster.node.DiscoveryNodes;
1616
import org.elasticsearch.cluster.routing.RoutingTable;
17-
import org.elasticsearch.cluster.routing.ShardRoutingState;
17+
import org.elasticsearch.cluster.routing.ShardRouting;
1818
import org.elasticsearch.cluster.routing.allocation.AllocationService;
1919
import org.elasticsearch.common.settings.Settings;
2020
import org.openjdk.jmh.annotations.Benchmark;
@@ -31,6 +31,8 @@
3131

3232
import java.util.Collections;
3333
import java.util.concurrent.TimeUnit;
34+
import java.util.stream.Collectors;
35+
import java.util.stream.StreamSupport;
3436

3537
@Fork(3)
3638
@Warmup(iterations = 10)
@@ -154,7 +156,10 @@ public ClusterState measureAllocation() {
154156
while (clusterState.getRoutingNodes().hasUnassignedShards()) {
155157
clusterState = strategy.applyStartedShards(
156158
clusterState,
157-
clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.INITIALIZING)
159+
StreamSupport.stream(clusterState.getRoutingNodes().spliterator(), false)
160+
.flatMap(shardRoutings -> StreamSupport.stream(shardRoutings.spliterator(), false))
161+
.filter(ShardRouting::initializing)
162+
.collect(Collectors.toList())
158163
);
159164
clusterState = strategy.reroute(clusterState, "reroute");
160165
}

0 commit comments

Comments
 (0)