Skip to content

Commit f890bc6

Browse files
committed
Merge remote-tracking branch 'elastic/master' into geosql
2 parents 1157c11 + b26aae3 commit f890bc6

File tree

2,449 files changed

+63808
-30665
lines changed

Some content is hidden

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

2,449 files changed

+63808
-30665
lines changed

CONTRIBUTING.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,14 @@ Before submitting your changes, run the test suite to make sure that nothing is
209209
./gradlew check
210210
```
211211

212+
If your changes affect only the documentation, run:
213+
214+
```sh
215+
./gradlew -p docs check
216+
```
217+
For more information about testing code examples in the documentation, see
218+
https://github.com/elastic/elasticsearch/blob/master/docs/README.asciidoc
219+
212220
### Project layout
213221

214222
This repository is split into many top level directories. The most important

TESTING.asciidoc

Lines changed: 166 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,46 @@ run it using Gradle:
2525
./gradlew run
2626
-------------------------------------
2727

28+
==== Launching and debugging from an IDE
29+
30+
If you want to run Elasticsearch from your IDE, the `./gradlew run` task
31+
supports a remote debugging option:
32+
33+
---------------------------------------------------------------------------
34+
./gradlew run --debug-jvm
35+
---------------------------------------------------------------------------
36+
37+
==== Distribution
38+
39+
By default a node is started with the zip distribution.
40+
In order to start with a different distribution use the `-Drun.distribution` argument.
41+
42+
To for example start the open source distribution:
43+
44+
-------------------------------------
45+
./gradlew run -Drun.distribution=oss-zip
46+
-------------------------------------
47+
48+
==== License type
49+
50+
By default a node is started with the `basic` license type.
51+
In order to start with a different license type use the `-Drun.license_type` argument.
52+
53+
In order to start a node with a trial license execute the following command:
54+
55+
-------------------------------------
56+
./gradlew run -Drun.license_type=trial
57+
-------------------------------------
58+
59+
This enables security and other paid features and adds a superuser with the username: `elastic-admin` and
60+
password: `elastic-password`.
61+
62+
==== Other useful arguments
63+
64+
In order to start a node with a different max heap space add: `-Dtests.heap.size=4G`
65+
In order to disable annotations add: `-Dtests.asserts=false`
66+
In order to set an Elasticsearch setting, provide a setting with the following prefix: `-Dtests.es.`
67+
2868
=== Test case filtering.
2969

3070
- `tests.class` is a class-filtering shell-like glob pattern,
@@ -303,15 +343,16 @@ comma separated list of nodes to connect to (e.g. localhost:9300). A transport c
303343
be created based on that and used for all the before|after test operations, and to extract
304344
the http addresses of the nodes so that REST requests can be sent to them.
305345

306-
== Testing scripts
346+
== Testing packaging
307347

308-
The simplest way to test scripts and the packaged distributions is to use
309-
Vagrant. You can get started by following there five easy steps:
348+
The packaging tests use Vagrant virtual machines to verify that installing
349+
and running elasticsearch distributions works correctly on supported operating systems.
350+
These tests should really only be run in vagrant vms because they're destructive.
310351

311352
. Install Virtual Box and Vagrant.
312353

313-
. (Optional) Install vagrant-cachier to squeeze a bit more performance out of
314-
the process:
354+
. (Optional) Install https://github.com/fgrehm/vagrant-cachier[vagrant-cachier] to squeeze
355+
a bit more performance out of the process:
315356

316357
--------------------------------------
317358
vagrant plugin install vagrant-cachier
@@ -325,35 +366,48 @@ vagrant plugin install vagrant-cachier
325366

326367
. Download and smoke test the VMs with `./gradlew vagrantSmokeTest` or
327368
`./gradlew -Pvagrant.boxes=all vagrantSmokeTest`. The first time you run this it will
328-
download the base images and provision the boxes and immediately quit. If you
329-
you this again it'll skip the download step.
369+
download the base images and provision the boxes and immediately quit. Downloading all
370+
the images may take a long time. After the images are already on your machine, they won't
371+
be downloaded again unless they have been updated to a new version.
330372

331373
. Run the tests with `./gradlew packagingTest`. This will cause Gradle to build
332374
the tar, zip, and deb packages and all the plugins. It will then run the tests
333375
on ubuntu-1404 and centos-7. We chose those two distributions as the default
334376
because they cover deb and rpm packaging and SyvVinit and systemd.
335377

336-
You can run on all the VMs by running `./gradlew -Pvagrant.boxes=all
337-
packagingTest`. You can run a particular VM with a command like `./gradlew
338-
-Pvagrant.boxes=oel-7 packagingTest`. See `./gradlew tasks` for a complete list
339-
of available vagrant boxes for testing. It's important to know that if you
340-
interrupt any of these Gradle commands then the boxes will remain running and
341-
you'll have to terminate them with `./gradlew stop`.
378+
You can choose which boxes to test by setting the `-Pvagrant.boxes` project property. All of
379+
the valid options for this property are:
380+
381+
* `sample` - The default, only chooses ubuntu-1404 and centos-7
382+
* List of box names, comma separated (e.g. `oel-7,fedora-28`) - Chooses exactly the boxes listed.
383+
* `linux-all` - All linux boxes.
384+
* `windows-all` - All Windows boxes. If there are any Windows boxes which do not
385+
have images available when this value is provided, the build will fail.
386+
* `all` - All boxes we test. If there are any boxes (e.g. Windows) which do not have images
387+
available when this value is provided, the build will fail.
388+
389+
For a complete list of boxes on which tests can be run, run `./gradlew :qa:vagrant:listAllBoxes`.
390+
For a list of boxes that have images available from your configuration, run
391+
`./gradlew :qa:vagrant:listAvailableBoxes`
392+
393+
Note that if you interrupt gradle in the middle of running these tasks, any boxes started
394+
will remain running and you'll have to stop them manually with `./gradlew stop` or
395+
`vagrant halt`.
342396

343397
All the regular vagrant commands should just work so you can get a shell in a
344398
VM running trusty by running
345399
`vagrant up ubuntu-1404 --provider virtualbox && vagrant ssh ubuntu-1404`.
346400

347-
These are the linux flavors the Vagrantfile currently supports:
401+
These are the linux flavors supported, all of which we provide images for
348402

349403
* ubuntu-1404 aka trusty
350404
* ubuntu-1604 aka xenial
351405
* debian-8 aka jessie
352406
* debian-9 aka stretch, the current debian stable distribution
353407
* centos-6
354408
* centos-7
355-
* fedora-26
356409
* fedora-27
410+
* fedora-28
357411
* oel-6 aka Oracle Enterprise Linux 6
358412
* oel-7 aka Oracle Enterprise Linux 7
359413
* sles-12
@@ -364,9 +418,42 @@ quality boxes available in vagrant atlas:
364418

365419
* sles-11
366420

367-
We're missing the following because our tests are very linux/bash centric:
421+
=== Testing packaging on Windows
422+
423+
The packaging tests also support Windows Server 2012R2 and Windows Server 2016.
424+
Unfortunately we're not able to provide boxes for them in open source use
425+
because of licensing issues. Any Virtualbox image that has WinRM and Powershell
426+
enabled for remote users should work.
427+
428+
Testing on Windows requires the https://github.com/criteo/vagrant-winrm[vagrant-winrm] plugin.
429+
430+
------------------------------------
431+
vagrant plugin install vagrant-winrm
432+
------------------------------------
433+
434+
Specify the image IDs of the Windows boxes to gradle with the following project
435+
properties. They can be set in `~/.gradle/gradle.properties` like
436+
437+
------------------------------------
438+
vagrant.windows-2012r2.id=my-image-id
439+
vagrant.windows-2016.id=another-image-id
440+
------------------------------------
368441

369-
* Windows Server 2012
442+
or passed on the command line like `-Pvagrant.windows-2012r2.id=my-image-id`
443+
`-Pvagrant.windows-2016=another-image-id`
444+
445+
These properties are required for Windows support in all gradle tasks that
446+
handle packaging tests. Either or both may be specified. Remember that to run tests
447+
on these boxes, the project property `vagrant.boxes` still needs to be set to a
448+
value that will include them.
449+
450+
If you're running vagrant commands outside of gradle, specify the Windows boxes
451+
with the environment variables
452+
453+
* `VAGRANT_WINDOWS_2012R2_BOX`
454+
* `VAGRANT_WINDOWS_2016_BOX`
455+
456+
=== Testing VMs are disposable
370457

371458
It's important to think of VMs like cattle. If they become lame you just shoot
372459
them and let vagrant reprovision them. Say you've hosed your precise VM:
@@ -399,54 +486,82 @@ vagrant destroy -f
399486
`vagrant up` would normally start all the VMs but we've prevented that because
400487
that'd consume a ton of ram.
401488

402-
== Testing scripts more directly
489+
=== Iterating on packaging tests
403490

404-
In general its best to stick to testing in vagrant because the bats scripts are
405-
destructive. When working with a single package it's generally faster to run its
406-
tests in a tighter loop than Gradle provides. In one window:
491+
Running the packaging tests through gradle can take a while because it will start
492+
and stop the VM each time. You can iterate faster by keeping the VM up and running
493+
the tests directly.
407494

408-
--------------------------------
409-
./gradlew :distribution:packages:rpm:assemble
410-
--------------------------------
495+
The packaging tests use a random seed to determine which past version to use for
496+
testing upgrades. To use a single past version fix the test seed when running
497+
the commands below (see <<Seed and repetitions.>>)
411498

412-
and in another window:
499+
First build the packaging tests and their dependencies
413500

414-
----------------------------------------------------
415-
vagrant up centos-7 --provider virtualbox && vagrant ssh centos-7
416-
cd $PACKAGING_ARCHIVES
417-
sudo -E bats $BATS_TESTS/*rpm*.bats
418-
----------------------------------------------------
501+
--------------------------------------------
502+
./gradlew :qa:vagrant:setupPackagingTest
503+
--------------------------------------------
419504

420-
If you wanted to retest all the release artifacts on a single VM you could:
505+
Then choose the VM you want to test on and bring it up. For example, to bring
506+
up Debian 9 use the gradle command below. Bringing the box up with vagrant directly
507+
may not mount the packaging test project in the right place. Once the VM is up, ssh
508+
into it
421509

422-
-------------------------------------------------
423-
./gradlew setupPackagingTest
424-
cd qa/vagrant; vagrant up ubuntu-1404 --provider virtualbox && vagrant ssh ubuntu-1404
510+
--------------------------------------------
511+
./gradlew :qa:vagrant:vagrantDebian9#up
512+
vagrant ssh debian-9
513+
--------------------------------------------
514+
515+
Now inside the VM, start the packaging tests from the terminal. There are two packaging
516+
test projects. The old ones are written with https://github.com/sstephenson/bats[bats]
517+
and only run on linux. To run them do
518+
519+
--------------------------------------------
425520
cd $PACKAGING_ARCHIVES
426-
sudo -E bats $BATS_TESTS/*.bats
427-
-------------------------------------------------
428521
429-
You can also use Gradle to prepare the test environment and then starts a single VM:
522+
# runs all bats tests
523+
sudo bats $BATS_TESTS/*.bats
430524
431-
-------------------------------------------------
432-
./gradlew vagrantFedora27#up
433-
-------------------------------------------------
525+
# you can also pass specific test files
526+
sudo bats $BATS_TESTS/20_tar_package.bats $BATS_TESTS/25_tar_plugins.bats
527+
--------------------------------------------
434528

435-
Or any of vagrantCentos6#up, vagrantCentos7#up, vagrantDebian8#up,
436-
vagrantDebian9#up, vagrantFedora26#up, vagrantFedora27#up, vagrantOel6#up, vagrantOel7#up,
437-
vagrantOpensuse42#up,vagrantSles12#up, vagrantUbuntu1404#up, vagrantUbuntu1604#up.
529+
The new packaging tests are written in Java and run on both linux and windows. On
530+
linux (again, inside the VM)
438531

439-
Once up, you can then connect to the VM using SSH from the elasticsearch directory:
532+
--------------------------------------------
533+
# run the full suite
534+
sudo bash $PACKAGING_TESTS/run-tests.sh
440535
441-
-------------------------------------------------
442-
vagrant ssh fedora-27
443-
-------------------------------------------------
536+
# run specific test cases
537+
sudo bash $PACKAGING_TESTS/run-tests.sh \
538+
org.elasticsearch.packaging.test.DefaultZipTests \
539+
org.elasticsearch.packaging.test.OssZipTests
540+
--------------------------------------------
444541

445-
Or from another directory:
542+
or on Windows, from a terminal running as Administrator
446543

447-
-------------------------------------------------
448-
VAGRANT_CWD=/path/to/elasticsearch vagrant ssh fedora-27
449-
-------------------------------------------------
544+
--------------------------------------------
545+
# run the full suite
546+
powershell -File $Env:PACKAGING_TESTS/run-tests.ps1
547+
548+
# run specific test cases
549+
powershell -File $Env:PACKAGING_TESTS/run-tests.ps1 `
550+
org.elasticsearch.packaging.test.DefaultZipTests `
551+
org.elasticsearch.packaging.test.OssZipTests
552+
--------------------------------------------
553+
554+
Note that on Windows boxes when running from inside the GUI, you may have to log out and
555+
back in to the `vagrant` user (password `vagrant`) for the environment variables that
556+
locate the packaging tests and distributions to take effect, due to how vagrant provisions
557+
Windows machines.
558+
559+
When you've made changes you want to test, keep the VM up and reload the tests and
560+
distributions inside by running (on the host)
561+
562+
--------------------------------------------
563+
./gradlew :qa:vagrant:clean :qa:vagrant:setupPackagingTest
564+
--------------------------------------------
450565

451566
Note: Starting vagrant VM outside of the elasticsearch folder requires to
452567
indicates the folder that contains the Vagrantfile using the VAGRANT_CWD
@@ -517,15 +632,6 @@ as its build system. Since the switch to Gradle though, this is no longer possib
517632
the code currently used to build Elasticsearch does not allow JaCoCo to recognize its tests.
518633
For more information on this, see the discussion in https://github.com/elastic/elasticsearch/issues/28867[issue #28867].
519634

520-
== Launching and debugging from an IDE
521-
522-
If you want to run Elasticsearch from your IDE, the `./gradlew run` task
523-
supports a remote debugging option:
524-
525-
---------------------------------------------------------------------------
526-
./gradlew run --debug-jvm
527-
---------------------------------------------------------------------------
528-
529635
== Debugging remotely from an IDE
530636

531637
If you want to run Elasticsearch and be able to remotely attach the process

Vagrantfile

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ Vagrant.configure(2) do |config|
9797
rpm_common config, box
9898
end
9999
end
100-
'fedora-26'.tap do |box|
100+
'fedora-27'.tap do |box|
101101
config.vm.define box, define_opts do |config|
102-
config.vm.box = 'elastic/fedora-26-x86_64'
102+
config.vm.box = 'elastic/fedora-27-x86_64'
103103
dnf_common config, box
104104
end
105105
end
106-
'fedora-27'.tap do |box|
106+
'fedora-28'.tap do |box|
107107
config.vm.define box, define_opts do |config|
108-
config.vm.box = 'elastic/fedora-27-x86_64'
108+
config.vm.box = 'elastic/fedora-28-x86_64'
109109
dnf_common config, box
110110
end
111111
end
@@ -121,6 +121,26 @@ Vagrant.configure(2) do |config|
121121
sles_common config, box
122122
end
123123
end
124+
125+
windows_2012r2_box = ENV['VAGRANT_WINDOWS_2012R2_BOX']
126+
if windows_2012r2_box && windows_2012r2_box.empty? == false
127+
'windows-2012r2'.tap do |box|
128+
config.vm.define box, define_opts do |config|
129+
config.vm.box = windows_2012r2_box
130+
windows_common config, box
131+
end
132+
end
133+
end
134+
135+
windows_2016_box = ENV['VAGRANT_WINDOWS_2016_BOX']
136+
if windows_2016_box && windows_2016_box.empty? == false
137+
'windows-2016'.tap do |box|
138+
config.vm.define box, define_opts do |config|
139+
config.vm.box = windows_2016_box
140+
windows_common config, box
141+
end
142+
end
143+
end
124144
end
125145

126146
def deb_common(config, name, extra: '')
@@ -217,6 +237,7 @@ def linux_common(config,
217237

218238
config.vm.provision 'markerfile', type: 'shell', inline: <<-SHELL
219239
touch /etc/is_vagrant_vm
240+
touch /is_vagrant_vm # for consistency between linux and windows
220241
SHELL
221242

222243
# This prevents leftovers from previous tests using the
@@ -353,3 +374,22 @@ SUDOERS_VARS
353374
chmod 0440 /etc/sudoers.d/elasticsearch_vars
354375
SHELL
355376
end
377+
378+
def windows_common(config, name)
379+
config.vm.provision 'markerfile', type: 'shell', inline: <<-SHELL
380+
$ErrorActionPreference = "Stop"
381+
New-Item C:/is_vagrant_vm -ItemType file -Force | Out-Null
382+
SHELL
383+
384+
config.vm.provision 'set prompt', type: 'shell', inline: <<-SHELL
385+
$ErrorActionPreference = "Stop"
386+
$ps_prompt = 'function Prompt { "#{name}:$($ExecutionContext.SessionState.Path.CurrentLocation)>" }'
387+
$ps_prompt | Out-File $PsHome/Microsoft.PowerShell_profile.ps1
388+
SHELL
389+
390+
config.vm.provision 'set env variables', type: 'shell', inline: <<-SHELL
391+
$ErrorActionPreference = "Stop"
392+
[Environment]::SetEnvironmentVariable("PACKAGING_ARCHIVES", "C:/project/build/packaging/archives", "Machine")
393+
[Environment]::SetEnvironmentVariable("PACKAGING_TESTS", "C:/project/build/packaging/tests", "Machine")
394+
SHELL
395+
end

0 commit comments

Comments
 (0)