Skip to content

Commit 4b9591c

Browse files
committed
Merge remote-tracking branch 'elastic/master' into geoshape-doc-values
2 parents d960712 + 8bf265e commit 4b9591c

File tree

595 files changed

+10858
-4440
lines changed

Some content is hidden

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

595 files changed

+10858
-4440
lines changed

.ci/dockerOnLinuxExclusions

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
debian-8
88
opensuse-15-1
99
ol-7.7
10-
sles-12
10+
sles-12.3 # older version used in Vagrant image
11+
sles-12.4
12+
sles-15.1
1113

12-
# These OSes are deprecated and filtered starting with 8.0.0, but need to be excluded
14+
# These OSes are deprecated and filtered starting with 8.0.0, but need to be excluded
1315
# for PR checks
1416
centos-6
1517
ol-6.10
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: "Validate Gradle Wrapper"
2+
on: [push]
3+
4+
jobs:
5+
validation:
6+
name: "Validation"
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v2
10+
- uses: gradle/wrapper-validation-action@v1

TESTING.asciidoc

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -270,34 +270,49 @@ code 137 (128 + 9, where 9 means SIGKILL).
270270

271271
== Testing the REST layer
272272

273-
The available integration tests make use of the java API to communicate with
274-
the elasticsearch nodes, using the internal binary transport (port 9300 by
275-
default).
276-
The REST layer is tested through specific tests that are shared between all
277-
the elasticsearch official clients and consist of YAML files that describe the
273+
The REST layer is tested through specific tests that are executed against
274+
a cluster that is configured and initialized via Gradle. The tests
275+
themselves can be written in either Java or with a YAML based DSL.
276+
277+
YAML based REST tests should be preferred since these are shared between all
278+
the elasticsearch official clients. The YAML based tests describe the
278279
operations to be executed and the obtained results that need to be tested.
279280

280-
The YAML files support various operators defined in the link:/rest-api-spec/src/main/resources/rest-api-spec/test/README.asciidoc[rest-api-spec] and adhere to the link:/rest-api-spec/README.markdown[Elasticsearch REST API JSON specification]
281+
The YAML tests support various operators defined in the link:/rest-api-spec/src/main/resources/rest-api-spec/test/README.asciidoc[rest-api-spec] and adhere to the link:/rest-api-spec/README.markdown[Elasticsearch REST API JSON specification]
282+
In order to run the the YAML tests, the relevant API specification needs
283+
to be on the test classpath. Any gradle project that has support for REST
284+
tests will get the primary API on it's class path. However, to better support
285+
Gradle incremental builds, it is recommended to explicitly declare which
286+
parts of the API the tests depend upon.
287+
288+
For example:
289+
---------------------------------------------------------------------------
290+
restResources {
291+
restApi {
292+
includeCore '_common', 'indices', 'index', 'cluster', 'nodes', 'get', 'ingest'
293+
}
294+
}
295+
---------------------------------------------------------------------------
296+
297+
YAML tests that include x-pack specific APIs need to explicitly declare
298+
which APIs are required through a similar `includeXpack` configuration.
281299

282300
The REST tests are run automatically when executing the "./gradlew check" command. To run only the
283301
REST tests use the following command:
284302

285303
---------------------------------------------------------------------------
286-
./gradlew :distribution:archives:integ-test-zip:integTest \
287-
-Dtests.class="org.elasticsearch.test.rest.*Yaml*IT"
304+
./gradlew :distribution:archives:integ-test-zip:integTestRunner \
305+
--tests "org.elasticsearch.test.rest.IntegTestZipClientYamlTestSuiteIT"
288306
---------------------------------------------------------------------------
289307

290-
A specific test case can be run with
308+
A specific test case can be run with the following command:
291309

292310
---------------------------------------------------------------------------
293-
./gradlew :distribution:archives:integ-test-zip:integTest \
294-
-Dtests.class="org.elasticsearch.test.rest.*Yaml*IT" \
295-
-Dtests.method="test {p0=cat.shards/10_basic/Help}"
311+
./gradlew ':distribution:archives:integ-test-zip:integTestRunner' \
312+
--tests "org.elasticsearch.test.rest.IntegTestZipClientYamlTestSuiteIT" \
313+
-Dtests.method="test {p0=cat.segments/10_basic/Help}"
296314
---------------------------------------------------------------------------
297315

298-
`*Yaml*IT` are the executable test classes that runs all the
299-
yaml suites available within the `rest-api-spec` folder.
300-
301316
The REST tests support all the options provided by the randomized runner, plus the following:
302317

303318
* `tests.rest[true|false]`: determines whether the REST tests need to be run (default) or not.
@@ -459,6 +474,14 @@ version 5.3.2 run:
459474
./gradlew v5.3.2#bwcTest
460475
-------------------------------------------------
461476

477+
Use -Dtest.class and -Dtests.method to run a specific bwcTest test.
478+
For example to run a specific tests from the x-pack rolling upgrade from 7.7.0:
479+
-------------------------------------------------
480+
./gradlew :x-pack:qa:rolling-upgrade:v7.7.0#bwcTest \
481+
-Dtests.class=org.elasticsearch.upgrades.UpgradeClusterClientYamlTestSuiteIT \
482+
-Dtests.method="test {p0=*/40_ml_datafeed_crud/*}"
483+
-------------------------------------------------
484+
462485
Tests are ran for versions that are not yet released but with which the current version will be compatible with.
463486
These are automatically checked out and built from source.
464487
See link:./buildSrc/src/main/java/org/elasticsearch/gradle/VersionCollection.java[VersionCollection]
@@ -512,8 +535,9 @@ There are multiple base classes for tests:
512535
* **`ESIntegTestCase`**: An integration test case that creates a cluster that
513536
might have multiple nodes.
514537
* **`ESRestTestCase`**: An integration tests that interacts with an external
515-
cluster via the REST API. For instance, YAML tests run via sub classes of
516-
`ESRestTestCase`.
538+
cluster via the REST API. This is used for Java based REST tests.
539+
* **`ESClientYamlSuiteTestCase` **: A subclass of `ESRestTestCase` used to run
540+
YAML based REST tests.
517541

518542
=== Good practices
519543

@@ -643,4 +667,4 @@ please see https://esrally.readthedocs.io/en/stable/[Rally's documentation].
643667

644668
The Elasticsearch docs are in AsciiDoc format. You can test and build the docs
645669
locally using the Elasticsearch documentation build process. See
646-
https://github.com/elastic/docs.
670+
https://github.com/elastic/docs.

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@ public class AvailableIndexFoldersBenchmark {
5555
@Setup
5656
public void setup() throws IOException {
5757
Path path = Files.createTempDirectory("test");
58-
String[] paths = new String[] {path.toString()};
58+
String[] paths = new String[] { path.toString() };
5959
nodePath = new NodeEnvironment.NodePath(path);
6060

6161
LogConfigurator.setNodeName("test");
6262
Settings settings = Settings.builder()
6363
.put(Environment.PATH_HOME_SETTING.getKey(), path)
64-
.putList(Environment.PATH_DATA_SETTING.getKey(), paths).build();
64+
.putList(Environment.PATH_DATA_SETTING.getKey(), paths)
65+
.build();
6566
nodeEnv = new NodeEnvironment(settings, new Environment(settings, null));
6667

6768
Files.createDirectories(nodePath.indicesPath);
@@ -80,7 +81,6 @@ public void setup() throws IOException {
8081
}
8182
}
8283

83-
8484
@Benchmark
8585
public Set<String> availableIndexFolderNaive() throws IOException {
8686
return nodeEnv.availableIndexFoldersForPath(nodePath);

benchmarks/src/main/java/org/elasticsearch/benchmark/indices/breaker/MemoryStatsBenchmark.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@
4141
@BenchmarkMode(Mode.AverageTime)
4242
@OutputTimeUnit(TimeUnit.MICROSECONDS)
4343
@State(Scope.Benchmark)
44-
@SuppressWarnings("unused") //invoked by benchmarking framework
44+
@SuppressWarnings("unused") // invoked by benchmarking framework
4545
public class MemoryStatsBenchmark {
4646
private static final MemoryMXBean MEMORY_MX_BEAN = ManagementFactory.getMemoryMXBean();
4747

48-
@Param({"0", "16", "256", "4096"})
48+
@Param({ "0", "16", "256", "4096" })
4949
private int tokens;
5050

5151
@Benchmark
@@ -102,4 +102,3 @@ public long getMemoryStats_64() {
102102
return MEMORY_MX_BEAN.getHeapMemoryUsage().getUsed();
103103
}
104104
}
105-

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
@BenchmarkMode(Mode.AverageTime)
5050
@OutputTimeUnit(TimeUnit.MILLISECONDS)
5151
@State(Scope.Benchmark)
52-
@SuppressWarnings("unused") //invoked by benchmarking framework
52+
@SuppressWarnings("unused") // invoked by benchmarking framework
5353
public class AllocationBenchmark {
5454
// Do NOT make any field final (even if it is not annotated with @Param)! See also
5555
// http://hg.openjdk.java.net/code-tools/jmh/file/tip/jmh-samples/src/main/java/org/openjdk/jmh/samples/JMHSample_10_ConstantFold.java
@@ -106,8 +106,7 @@ public class AllocationBenchmark {
106106
" 10| 10| 2| 50",
107107
" 100| 1| 2| 50",
108108
" 100| 3| 2| 50",
109-
" 100| 10| 2| 50"
110-
})
109+
" 100| 10| 2| 50" })
111110
public String indicesShardsReplicasNodes = "10|1|0|1";
112111

113112
public int numTags = 2;
@@ -124,13 +123,14 @@ public void setUp() throws Exception {
124123
int numReplicas = toInt(params[2]);
125124
int numNodes = toInt(params[3]);
126125

127-
strategy = Allocators.createAllocationService(Settings.builder()
128-
.put("cluster.routing.allocation.awareness.attributes", "tag")
129-
.build());
126+
strategy = Allocators.createAllocationService(
127+
Settings.builder().put("cluster.routing.allocation.awareness.attributes", "tag").build()
128+
);
130129

131130
MetaData.Builder mb = MetaData.builder();
132131
for (int i = 1; i <= numIndices; i++) {
133-
mb.put(IndexMetaData.builder("test_" + i)
132+
mb.put(
133+
IndexMetaData.builder("test_" + i)
134134
.settings(Settings.builder().put("index.version.created", Version.CURRENT))
135135
.numberOfShards(numShards)
136136
.numberOfReplicas(numReplicas)
@@ -147,8 +147,10 @@ public void setUp() throws Exception {
147147
nb.add(Allocators.newNode("node" + i, Collections.singletonMap("tag", "tag_" + (i % numTags))));
148148
}
149149
initialClusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
150-
.metaData(metaData).routingTable(routingTable).nodes
151-
(nb).build();
150+
.metaData(metaData)
151+
.routingTable(routingTable)
152+
.nodes(nb)
153+
.build();
152154
}
153155

154156
private int toInt(String v) {
@@ -159,8 +161,10 @@ private int toInt(String v) {
159161
public ClusterState measureAllocation() {
160162
ClusterState clusterState = initialClusterState;
161163
while (clusterState.getRoutingNodes().hasUnassignedShards()) {
162-
clusterState = strategy.applyStartedShards(clusterState, clusterState.getRoutingNodes()
163-
.shardsWithState(ShardRoutingState.INITIALIZING));
164+
clusterState = strategy.applyStartedShards(
165+
clusterState,
166+
clusterState.getRoutingNodes().shardsWithState(ShardRoutingState.INITIALIZING)
167+
);
164168
clusterState = strategy.reroute(clusterState, "reroute");
165169
}
166170
return clusterState;

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import org.elasticsearch.common.util.set.Sets;
3737
import org.elasticsearch.gateway.GatewayAllocator;
3838

39-
import java.lang.reflect.InvocationTargetException;
4039
import java.util.Collection;
4140
import java.util.Collections;
4241
import java.util.List;
@@ -67,33 +66,34 @@ private Allocators() {
6766
throw new AssertionError("Do not instantiate");
6867
}
6968

70-
71-
public static AllocationService createAllocationService(Settings settings) throws NoSuchMethodException, InstantiationException,
72-
IllegalAccessException, InvocationTargetException {
73-
return createAllocationService(settings, new ClusterSettings(Settings.EMPTY, ClusterSettings
74-
.BUILT_IN_CLUSTER_SETTINGS));
69+
public static AllocationService createAllocationService(Settings settings) {
70+
return createAllocationService(settings, new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS));
7571
}
7672

77-
public static AllocationService createAllocationService(Settings settings, ClusterSettings clusterSettings) throws
78-
InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
73+
public static AllocationService createAllocationService(Settings settings, ClusterSettings clusterSettings) {
7974
return new AllocationService(
8075
defaultAllocationDeciders(settings, clusterSettings),
81-
NoopGatewayAllocator.INSTANCE, new BalancedShardsAllocator(settings), EmptyClusterInfoService.INSTANCE);
76+
NoopGatewayAllocator.INSTANCE,
77+
new BalancedShardsAllocator(settings),
78+
EmptyClusterInfoService.INSTANCE
79+
);
8280
}
8381

84-
public static AllocationDeciders defaultAllocationDeciders(Settings settings, ClusterSettings clusterSettings) throws
85-
IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException {
86-
Collection<AllocationDecider> deciders =
87-
ClusterModule.createAllocationDeciders(settings, clusterSettings, Collections.emptyList());
82+
public static AllocationDeciders defaultAllocationDeciders(Settings settings, ClusterSettings clusterSettings) {
83+
Collection<AllocationDecider> deciders = ClusterModule.createAllocationDeciders(settings, clusterSettings, Collections.emptyList());
8884
return new AllocationDeciders(deciders);
89-
9085
}
9186

9287
private static final AtomicInteger portGenerator = new AtomicInteger();
9388

9489
public static DiscoveryNode newNode(String nodeId, Map<String, String> attributes) {
95-
return new DiscoveryNode("", nodeId, new TransportAddress(TransportAddress.META_ADDRESS,
96-
portGenerator.incrementAndGet()), attributes, Sets.newHashSet(DiscoveryNodeRole.MASTER_ROLE,
97-
DiscoveryNodeRole.DATA_ROLE), Version.CURRENT);
90+
return new DiscoveryNode(
91+
"",
92+
nodeId,
93+
new TransportAddress(TransportAddress.META_ADDRESS, portGenerator.incrementAndGet()),
94+
attributes,
95+
Sets.newHashSet(DiscoveryNodeRole.MASTER_ROLE, DiscoveryNodeRole.DATA_ROLE),
96+
Version.CURRENT
97+
);
9898
}
9999
}

benchmarks/src/main/java/org/elasticsearch/benchmark/time/DateFormatterBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
@BenchmarkMode(Mode.AverageTime)
4040
@OutputTimeUnit(TimeUnit.NANOSECONDS)
4141
@State(Scope.Benchmark)
42-
@SuppressWarnings("unused") //invoked by benchmarking framework
42+
@SuppressWarnings("unused") // invoked by benchmarking framework
4343
public class DateFormatterBenchmark {
4444

4545
private final DateFormatter javaFormatter = DateFormatter.forPattern("8year_month_day||ordinal_date||epoch_millis");

benchmarks/src/main/java/org/elasticsearch/benchmark/time/DateFormatterFromBenchmark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
@BenchmarkMode(Mode.AverageTime)
4040
@OutputTimeUnit(TimeUnit.NANOSECONDS)
4141
@State(Scope.Benchmark)
42-
@SuppressWarnings("unused") //invoked by benchmarking framework
42+
@SuppressWarnings("unused") // invoked by benchmarking framework
4343
public class DateFormatterFromBenchmark {
4444

4545
private final TemporalAccessor accessor = DateFormatter.forPattern("epoch_millis").parse("1234567890");

build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,15 @@ subprojects {
106106
// Projects that should be formatted and checked with Spotless are
107107
// listed here, by project path. Once the number of formatted projects
108108
// is greater than the number of unformatted projects, this can be
109-
// switched to an exclude list, and eventualy removed completely.
109+
// switched to an exclude list, and eventually removed completely.
110110
def projectPathsToFormat = [
111+
':benchmarks',
111112
':build-tools',
112113
':distribution:tools:java-version-checker',
113114
':distribution:tools:keystore-cli',
114115
':distribution:tools:launchers',
115116
':distribution:tools:plugin-cli',
117+
':qa:os',
116118
':x-pack:plugin:autoscaling',
117119
':x-pack:plugin:enrich'
118120
]
@@ -191,7 +193,7 @@ task verifyVersions {
191193
throw new GradleException("Must run in online mode to verify versions")
192194
}
193195
// Read the list from maven central.
194-
// Fetch the metadata an parse the xml into Version instances because it's more straight forward here
196+
// Fetch the metadata and parse the xml into Version instances because it's more straight forward here
195197
// rather than bwcVersion ( VersionCollection ).
196198
new URL('https://repo1.maven.org/maven2/org/elasticsearch/elasticsearch/maven-metadata.xml').openStream().withStream { s ->
197199
bwcVersions.compareToAuthoritative(

buildSrc/build.gradle

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@ sourceSets {
8080
compileMinimumRuntimeJava {
8181
targetCompatibility = 8
8282
sourceCompatibility = 8
83+
tasks.withType(JavaCompile).configureEach {
84+
options.encoding = 'UTF-8'
85+
}
8386
}
8487

8588
jar {
@@ -196,6 +199,18 @@ if (project != rootProject) {
196199
}
197200
}
198201

202+
// Track reaper jar as a test input using runtime classpath normalization strategy
203+
tasks.withType(Test).configureEach {
204+
inputs.files(configurations.reaper).withNormalizer(ClasspathNormalizer)
205+
}
206+
207+
normalization {
208+
runtimeClasspath {
209+
// We already include the reaper jar as part of our runtime classpath. Ignore the copy in META-INF.
210+
ignore('META-INF/reaper.jar')
211+
}
212+
}
213+
199214
// TODO: re-enable once randomizedtesting gradle code is published and removed from here
200215
licenseHeaders.enabled = false
201216

buildSrc/src/main/groovy/org/elasticsearch/gradle/plugin/PluginBuildPlugin.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import org.elasticsearch.gradle.NoticeTask
2424
import org.elasticsearch.gradle.Version
2525
import org.elasticsearch.gradle.VersionProperties
2626
import org.elasticsearch.gradle.info.BuildParams
27+
import org.elasticsearch.gradle.test.rest.RestResourcesPlugin
2728
import org.elasticsearch.gradle.test.RestIntegTestTask
2829
import org.elasticsearch.gradle.testclusters.RunTask
2930
import org.elasticsearch.gradle.testclusters.TestClustersPlugin
@@ -51,6 +52,7 @@ class PluginBuildPlugin implements Plugin<Project> {
5152
void apply(Project project) {
5253
project.pluginManager.apply(BuildPlugin)
5354
project.pluginManager.apply(TestClustersPlugin)
55+
project.pluginManager.apply(RestResourcesPlugin)
5456

5557
PluginPropertiesExtension extension = project.extensions.create(PLUGIN_EXTENSION_NAME, PluginPropertiesExtension, project)
5658
configureDependencies(project)

0 commit comments

Comments
 (0)