Skip to content

Commit 8ea0c42

Browse files
committed
Merge branch 'master' into feature/ml-inference
2 parents 27d14a0 + 652bda7 commit 8ea0c42

File tree

279 files changed

+3916
-2417
lines changed

Some content is hidden

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

279 files changed

+3916
-2417
lines changed

CONTRIBUTING.md

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,47 @@ by running Gradle with `-Dspotless.paddedcell`.
219219

220220
### License Headers
221221

222-
We require license headers on all Java files. You will notice that all the Java files in
223-
the top-level `x-pack` directory contain a separate license from the rest of the repository. This
224-
directory contains commercial code that is associated with a separate license. It can be helpful
225-
to have the IDE automatically insert the appropriate license header depending which part of the project
226-
contributions are made to.
222+
We require license headers on all Java files. With the exception of the
223+
top-level `x-pack` directory, all contributed code should have the following
224+
license header unless instructed otherwise:
225+
226+
/*
227+
* Licensed to Elasticsearch under one or more contributor
228+
* license agreements. See the NOTICE file distributed with
229+
* this work for additional information regarding copyright
230+
* ownership. Elasticsearch licenses this file to you under
231+
* the Apache License, Version 2.0 (the "License"); you may
232+
* not use this file except in compliance with the License.
233+
* You may obtain a copy of the License at
234+
*
235+
* http://www.apache.org/licenses/LICENSE-2.0
236+
*
237+
* Unless required by applicable law or agreed to in writing,
238+
* software distributed under the License is distributed on an
239+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
240+
* KIND, either express or implied. See the License for the
241+
* specific language governing permissions and limitations
242+
* under the License.
243+
*/
244+
245+
The top-level `x-pack` directory contains code covered by the [Elastic
246+
license](licenses/ELASTIC-LICENSE.txt). Community contributions to this code are
247+
welcome, and should have the following license header unless instructed
248+
otherwise:
249+
250+
/*
251+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
252+
* or more contributor license agreements. Licensed under the Elastic License;
253+
* you may not use this file except in compliance with the Elastic License.
254+
*/
255+
256+
It is important that the only code covered by the Elastic licence is contained
257+
within the top-level `x-pack` directory. The build will fail its pre-commit
258+
checks if contributed code does not have the appropriate license headers.
259+
260+
You may find it helpful to configure your IDE to automatically insert the
261+
appropriate license header depending on the part of the project to which you are
262+
contributing.
227263

228264
#### IntelliJ: Copyright & Scope Profiles
229265

TESTING.asciidoc

Lines changed: 49 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Default value provided below in [brackets].
152152

153153
=== Load balancing and caches.
154154

155-
By default the tests run on multiple processes using all the available cores on all
155+
By default the tests run on multiple processes using all the available cores on all
156156
available CPUs. Not including hyper-threading.
157157
If you want to explicitly specify the number of JVMs you can do so on the command
158158
line:
@@ -300,9 +300,17 @@ e.g. -Dtests.rest.blacklist=index/*/Index document,get/10_basic/*
300300

301301
== Testing packaging
302302

303-
The packaging tests use Vagrant virtual machines to verify that installing
304-
and running elasticsearch distributions works correctly on supported operating systems.
305-
These tests should really only be run in vagrant vms because they're destructive.
303+
The packaging tests use Vagrant virtual machines or cloud instances to verify
304+
that installing and running Elasticsearch distributions works correctly on
305+
supported operating systems. These tests should really only be run on ephemeral
306+
systems because they're destructive; that is, these tests install and remove
307+
packages and freely modify system settings, so you will probably regret it if
308+
you execute them on your development machine.
309+
310+
When you run a packaging test, Gradle will set up the target VM and mount your
311+
repository directory in the VM. Once this is done, a Gradle task will issue a
312+
Vagrant command to run a *nested* Gradle task on the VM. This nested Gradle
313+
runs the actual "destructive" test classes.
306314

307315
. Install Virtual Box and Vagrant.
308316
+
@@ -313,40 +321,29 @@ a bit more performance out of the process:
313321
vagrant plugin install vagrant-cachier
314322
--------------------------------------
315323
+
316-
. Validate your installed dependencies:
324+
. You can run all of the OS packaging tests with `./gradlew packagingTest`.
325+
This task includes our legacy `bats` tests. To run only the OS tests that are
326+
written in Java, run `.gradlew distroTest`, will cause Gradle to build the tar,
327+
zip, and deb packages and all the plugins. It will then run the tests on every
328+
available system. This will take a very long time.
317329
+
318-
-------------------------------------
319-
./gradlew :qa:vagrant:vagrantCheckVersion
320-
-------------------------------------
330+
Fortunately, the various systems under test have their own Gradle tasks under
331+
`qa/os`. To find out what packaging combinations can be tested on a system, run
332+
the `tasks` task. For example:
321333
+
322-
. Download and smoke test the VMs with `./gradlew vagrantSmokeTest` or
323-
`./gradlew -Pvagrant.boxes=all vagrantSmokeTest`. The first time you run this it will
324-
download the base images and provision the boxes and immediately quit. Downloading all
325-
the images may take a long time. After the images are already on your machine, they won't
326-
be downloaded again unless they have been updated to a new version.
334+
----------------------------------
335+
./gradlew :qa:os:ubuntu-1804:tasks
336+
----------------------------------
327337
+
328-
. Run the tests with `./gradlew packagingTest`. This will cause Gradle to build
329-
the tar, zip, and deb packages and all the plugins. It will then run the tests
330-
on ubuntu-1604 and centos-7. We chose those two distributions as the default
331-
because they cover deb and rpm packaging and SyvVinit and systemd.
332-
333-
You can choose which boxes to test by setting the `-Pvagrant.boxes` project property. All of
334-
the valid options for this property are:
335-
336-
* `sample` - The default, only chooses ubuntu-1604 and centos-7
337-
* List of box names, comma separated (e.g. `oel-7,fedora-28`) - Chooses exactly the boxes listed.
338-
* `linux-all` - All linux boxes.
339-
* `windows-all` - All Windows boxes. If there are any Windows boxes which do not
340-
have images available when this value is provided, the build will fail.
341-
* `all` - All boxes we test. If there are any boxes (e.g. Windows) which do not have images
342-
available when this value is provided, the build will fail.
343-
344-
For a complete list of boxes on which tests can be run, run `./gradlew :qa:vagrant:listAllBoxes`.
345-
For a list of boxes that have images available from your configuration, run
346-
`./gradlew :qa:vagrant:listAvailableBoxes`
347-
348-
Note that if you interrupt gradle in the middle of running these tasks, any boxes started
349-
will remain running and you'll have to stop them manually with `./gradlew stop` or
338+
If you want a quick test of the tarball and RPM packagings for Centos 7, you
339+
would run:
340+
+
341+
-------------------------------------------------------------------------------------------------
342+
./gradlew :qa:os:centos-7:distroTest.default-rpm :qa:os:centos-7:distroTest.default-linux-archive
343+
-------------------------------------------------------------------------------------------------
344+
345+
Note that if you interrupt Gradle in the middle of running these tasks, any boxes started
346+
will remain running and you'll have to stop them manually with `./gradlew --stop` or
350347
`vagrant halt`.
351348

352349
All the regular vagrant commands should just work so you can get a shell in a
@@ -393,9 +390,7 @@ or passed on the command line like `-Pvagrant.windows-2012r2.id=my-image-id`
393390
`-Pvagrant.windows-2016=another-image-id`
394391

395392
These properties are required for Windows support in all gradle tasks that
396-
handle packaging tests. Either or both may be specified. Remember that to run tests
397-
on these boxes, the project property `vagrant.boxes` still needs to be set to a
398-
value that will include them.
393+
handle packaging tests. Either or both may be specified.
399394

400395
If you're running vagrant commands outside of gradle, specify the Windows boxes
401396
with the environment variables
@@ -438,84 +433,23 @@ that'd consume a ton of ram.
438433

439434
=== Iterating on packaging tests
440435

441-
Running the packaging tests through gradle can take a while because it will start
442-
and stop the VM each time. You can iterate faster by keeping the VM up and running
443-
the tests directly.
444-
445-
The packaging tests use a random seed to determine which past version to use for
446-
testing upgrades. To use a single past version fix the test seed when running
447-
the commands below (see <<Seed and repetitions.>>)
448-
449-
First build the packaging tests and their dependencies
450-
451-
--------------------------------------------
452-
./gradlew :qa:vagrant:setupPackagingTest
453-
--------------------------------------------
454-
455-
Then choose the VM you want to test on and bring it up. For example, to bring
456-
up Debian 9 use the gradle command below. Bringing the box up with vagrant directly
457-
may not mount the packaging test project in the right place. Once the VM is up, ssh
458-
into it
459-
460-
--------------------------------------------
461-
./gradlew :qa:vagrant:vagrantDebian9#up
462-
vagrant ssh debian-9
463-
--------------------------------------------
464-
465-
Now inside the VM, start the packaging tests from the terminal. There are two packaging
466-
test projects. The old ones are written with https://github.com/sstephenson/bats[bats]
467-
and only run on linux. To run them do
468-
469-
--------------------------------------------
470-
cd $PACKAGING_ARCHIVES
471-
472-
# runs all bats tests
473-
sudo bats $BATS_TESTS/*.bats
474-
475-
# you can also pass specific test files
476-
sudo bats $BATS_TESTS/20_tar_package.bats $BATS_TESTS/25_tar_plugins.bats
477-
--------------------------------------------
478-
479-
The new packaging tests are written in Java and run on both linux and windows. On
480-
linux (again, inside the VM)
481-
482-
--------------------------------------------
483-
# run the full suite
484-
sudo bash $PACKAGING_TESTS/run-tests.sh
485-
486-
# run specific test cases
487-
sudo bash $PACKAGING_TESTS/run-tests.sh \
488-
org.elasticsearch.packaging.test.DefaultWindowsZipTests \
489-
org.elasticsearch.packaging.test.OssWindowsZipTests
490-
--------------------------------------------
491-
492-
or on Windows, from a terminal running as Administrator
493-
494-
--------------------------------------------
495-
# run the full suite
496-
powershell -File $Env:PACKAGING_TESTS/run-tests.ps1
497-
498-
# run specific test cases
499-
powershell -File $Env:PACKAGING_TESTS/run-tests.ps1 `
500-
org.elasticsearch.packaging.test.DefaultWindowsZipTests `
501-
org.elasticsearch.packaging.test.OssWindowsZipTests
502-
--------------------------------------------
503-
504-
Note that on Windows boxes when running from inside the GUI, you may have to log out and
505-
back in to the `vagrant` user (password `vagrant`) for the environment variables that
506-
locate the packaging tests and distributions to take effect, due to how vagrant provisions
507-
Windows machines.
436+
Because our packaging tests are capable of testing many combinations of OS
437+
(e.g., Windows, Linux, etc.), package type (e.g., zip file, RPM, etc.),
438+
Elasticsearch distribution type (e.g., default or OSS), and so forth, it's
439+
faster to develop against smaller subsets of the tests. For example, to run
440+
tests for the default archive distribution on Fedora 28:
508441

509-
When you've made changes you want to test, keep the VM up and reload the tests and
510-
distributions inside by running (on the host)
442+
-----------------------------------------------------------
443+
./gradlew :qa:os:fedora-28:distroTest.default-linux-archive
444+
-----------------------------------------------------------
511445

512-
--------------------------------------------
513-
./gradlew :qa:vagrant:clean :qa:vagrant:setupPackagingTest
514-
--------------------------------------------
446+
These test tasks can use the `--tests`, `--info`, and `--debug` parameters just like
447+
non-OS tests can. For example:
515448

516-
Note: Starting vagrant VM outside of the elasticsearch folder requires to
517-
indicates the folder that contains the Vagrantfile using the VAGRANT_CWD
518-
environment variable.
449+
-----------------------------------------------------------
450+
./gradlew :qa:os:fedora-28:distroTest.default-linux-archive \
451+
--tests "com.elasticsearch.packaging.test.ArchiveTests"
452+
-----------------------------------------------------------
519453

520454
== Testing backwards compatibility
521455

@@ -536,7 +470,7 @@ version 5.3.2 run:
536470
Tests are ran for versions that are not yet released but with which the current version will be compatible with.
537471
These are automatically checked out and built from source.
538472
See link:./buildSrc/src/main/java/org/elasticsearch/gradle/VersionCollection.java[VersionCollection]
539-
and link:./distribution/bwc/build.gradle[distribution/bwc/build.gradle]
473+
and link:./distribution/bwc/build.gradle[distribution/bwc/build.gradle]
540474
for more information.
541475

542476
When running `./gradlew check`, minimal bwc checks are also run against compatible versions that are not yet released.
@@ -657,7 +591,7 @@ care.
657591
== Test coverage analysis
658592

659593
Generating test coverage reports for Elasticsearch is currently not possible through Gradle.
660-
However, it _is_ possible to gain insight in code coverage using IntelliJ's built-in coverage
594+
However, it _is_ possible to gain insight in code coverage using IntelliJ's built-in coverage
661595
analysis tool that can measure coverage upon executing specific tests. Eclipse may also be able
662596
to do the same using the EclEmma plugin.
663597

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ import org.gradle.util.GradleVersion
3232
import static org.elasticsearch.gradle.tool.Boilerplate.maybeConfigure
3333

3434
plugins {
35-
id 'com.gradle.build-scan' version '2.4'
35+
id 'com.gradle.build-scan' version '2.4.2'
3636
id 'lifecycle-base'
3737
id 'elasticsearch.global-build-info'
3838
id "com.diffplug.gradle.spotless" version "3.24.2" apply false
3939
}
4040

4141
apply plugin: 'nebula.info-scm'
4242
apply from: 'gradle/build-scan.gradle'
43+
apply from: 'gradle/build-complete.gradle'
4344

4445
// common maven publishing configuration
4546
allprojects {

buildSrc/src/main/java/org/elasticsearch/gradle/testclusters/RestTestRunnerTask.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
import org.gradle.api.tasks.testing.Test;
66

77
import java.util.Collection;
8+
import java.util.Collections;
89
import java.util.HashSet;
910

10-
import static org.elasticsearch.gradle.testclusters.TestDistribution.INTEG_TEST;
11-
1211
/**
1312
* Customized version of Gradle {@link Test} task which tracks a collection of {@link ElasticsearchCluster} as a task input. We must do this
1413
* as a custom task type because the current {@link org.gradle.api.tasks.TaskInputs} runtime API does not have a way to register
@@ -20,9 +19,17 @@ public class RestTestRunnerTask extends Test implements TestClustersAware {
2019
private Collection<ElasticsearchCluster> clusters = new HashSet<>();
2120

2221
public RestTestRunnerTask() {
23-
super();
24-
this.getOutputs().doNotCacheIf("Build cache is only enabled for tests against clusters using the 'integ-test' distribution",
25-
task -> clusters.stream().flatMap(c -> c.getNodes().stream()).anyMatch(n -> n.getTestDistribution() != INTEG_TEST));
22+
this.getOutputs().doNotCacheIf("Caching disabled for this task since it uses a cluster shared by other tasks",
23+
/*
24+
* Look for any other tasks which use the same cluster as this task. Since tests often have side effects for the cluster they
25+
* execute against, this state can cause issues when trying to cache tests results of tasks that share a cluster. To avoid any
26+
* undesired behavior we simply disable the cache if we detect that this task uses a cluster shared between multiple tasks.
27+
*/
28+
t -> getProject().getTasks().withType(RestTestRunnerTask.class)
29+
.stream()
30+
.filter(task -> task != this)
31+
.anyMatch(task -> Collections.disjoint(task.getClusters(), getClusters()) == false)
32+
);
2633
}
2734

2835
@Override

buildSrc/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
elasticsearch = 8.0.0
2-
lucene = 8.3.0-snapshot-47aece66b48
2+
lucene = 8.3.0-snapshot-25968e3b75e
33

44
bundled_jdk_vendor = adoptopenjdk
55
bundled_jdk = 13+33

client/rest-high-level/build.gradle

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,11 @@ testClusters.integTest {
129129

130130
setting 'indices.lifecycle.poll_interval', '1000ms'
131131
keystore 'xpack.security.transport.ssl.truststore.secure_password', 'testnode'
132+
extraConfigFile 'roles.yml', file('roles.yml')
132133
user username: System.getProperty('tests.rest.cluster.username', 'test_user'),
133-
password: System.getProperty('tests.rest.cluster.password', 'test-password')
134+
password: System.getProperty('tests.rest.cluster.password', 'test-password'),
135+
role: System.getProperty('tests.rest.cluster.role', 'admin')
136+
user username: 'admin_user', password: 'admin-password'
134137

135138
extraConfigFile nodeCert.name, nodeCert
136139
extraConfigFile nodeTrustStore.name, nodeTrustStore

client/rest-high-level/roles.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
admin:
2+
cluster:
3+
- all
4+
indices:
5+
- names: '*'
6+
privileges:
7+
- all
8+
run_as: [ '*' ]
9+
applications:
10+
- application: '*'
11+
privileges: [ '*' ]
12+
resources: [ '*' ]

0 commit comments

Comments
 (0)