2013-09-13 13:50:56 -04:00
|
|
|
[[Testing Framework Cheatsheet]]
|
|
|
|
= Testing
|
|
|
|
|
|
|
|
[partintro]
|
2014-04-02 08:27:31 -04:00
|
|
|
|
2013-09-13 13:50:56 -04:00
|
|
|
Elasticsearch uses jUnit for testing, it also uses randomness in the
|
|
|
|
tests, that can be set using a seed, the following is a cheatsheet of
|
|
|
|
options for running the tests for ES.
|
|
|
|
|
|
|
|
== Creating packages
|
|
|
|
|
|
|
|
To create a distribution without running the tests, simply run the
|
|
|
|
following:
|
|
|
|
|
|
|
|
-----------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle assemble
|
2013-09-13 13:50:56 -04:00
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
== Other test options
|
|
|
|
|
2014-04-02 08:27:31 -04:00
|
|
|
To disable and enable network transport, set the `Des.node.mode`.
|
2013-09-13 13:50:56 -04:00
|
|
|
|
2014-06-26 05:11:14 -04:00
|
|
|
Use network transport:
|
2013-09-13 13:50:56 -04:00
|
|
|
|
|
|
|
------------------------------------
|
2014-04-02 08:27:31 -04:00
|
|
|
-Des.node.mode=network
|
2013-09-13 13:50:56 -04:00
|
|
|
------------------------------------
|
|
|
|
|
2014-06-26 05:11:14 -04:00
|
|
|
Use local transport (default since 1.3):
|
2013-09-13 13:50:56 -04:00
|
|
|
|
2014-04-02 08:27:31 -04:00
|
|
|
-------------------------------------
|
|
|
|
-Des.node.mode=local
|
|
|
|
-------------------------------------
|
|
|
|
|
|
|
|
Alternatively, you can set the `ES_TEST_LOCAL` environment variable:
|
|
|
|
|
2013-09-13 13:50:56 -04:00
|
|
|
-------------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
export ES_TEST_LOCAL=true && gradle test
|
2013-09-13 13:50:56 -04:00
|
|
|
-------------------------------------
|
|
|
|
|
2015-03-26 17:55:25 -04:00
|
|
|
=== Running Elasticsearch from a checkout
|
|
|
|
|
|
|
|
In order to run Elasticsearch from source without building a package, you can
|
|
|
|
run it using Maven:
|
|
|
|
|
|
|
|
-------------------------------------
|
2015-11-02 15:14:45 -05:00
|
|
|
gradle run
|
2015-03-26 17:55:25 -04:00
|
|
|
-------------------------------------
|
|
|
|
|
2013-09-13 13:50:56 -04:00
|
|
|
=== Test case filtering.
|
|
|
|
|
|
|
|
- `tests.class` is a class-filtering shell-like glob pattern,
|
|
|
|
- `tests.method` is a method-filtering glob pattern.
|
|
|
|
|
|
|
|
Run a single test case (variants)
|
|
|
|
|
|
|
|
----------------------------------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -Dtests.class=org.elasticsearch.package.ClassName
|
|
|
|
gradle test "-Dtests.class=*.ClassName"
|
2013-09-13 13:50:56 -04:00
|
|
|
----------------------------------------------------------
|
|
|
|
|
|
|
|
Run all tests in a package and sub-packages
|
|
|
|
|
|
|
|
----------------------------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test "-Dtests.class=org.elasticsearch.package.*"
|
2013-09-13 13:50:56 -04:00
|
|
|
----------------------------------------------------
|
|
|
|
|
|
|
|
Run any test methods that contain 'esi' (like: ...r*esi*ze...).
|
|
|
|
|
|
|
|
-------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test "-Dtests.method=*esi*"
|
2013-09-13 13:50:56 -04:00
|
|
|
-------------------------------
|
|
|
|
|
2014-07-03 04:52:29 -04:00
|
|
|
You can also filter tests by certain annotations ie:
|
|
|
|
|
|
|
|
* `@Nightly` - tests that only run in nightly builds (disabled by default)
|
|
|
|
* `@Backwards` - backwards compatibility tests (disabled by default)
|
|
|
|
* `@AwaitsFix` - tests that are waiting for a bugfix (disabled by default)
|
|
|
|
* `@BadApple` - tests that are known to fail randomly (disabled by default)
|
|
|
|
|
|
|
|
Those annotation names can be combined into a filter expression like:
|
|
|
|
|
|
|
|
------------------------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -Dtests.filter="@nightly and not @backwards"
|
2014-07-03 04:52:29 -04:00
|
|
|
------------------------------------------------
|
|
|
|
|
2015-08-03 23:08:18 -04:00
|
|
|
to run all nightly test but not the ones that are backwards tests. `tests.filter` supports
|
2014-07-03 04:52:29 -04:00
|
|
|
the boolean operators `and, or, not` and grouping ie:
|
|
|
|
|
|
|
|
|
|
|
|
---------------------------------------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -Dtests.filter="@nightly and not(@badapple or @backwards)"
|
2014-07-03 04:52:29 -04:00
|
|
|
---------------------------------------------------------------
|
|
|
|
|
2013-09-13 13:50:56 -04:00
|
|
|
=== Seed and repetitions.
|
|
|
|
|
|
|
|
Run with a given seed (seed is a hex-encoded long).
|
|
|
|
|
|
|
|
------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -Dtests.seed=DEADBEEF
|
2013-09-13 13:50:56 -04:00
|
|
|
------------------------------
|
|
|
|
|
|
|
|
=== Repeats _all_ tests of ClassName N times.
|
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
Every test repetition will have a different method seed
|
2014-02-20 08:46:59 -05:00
|
|
|
(derived from a single random master seed).
|
2013-09-13 13:50:56 -04:00
|
|
|
|
|
|
|
--------------------------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -Dtests.iters=N -Dtests.class=*.ClassName
|
2013-09-13 13:50:56 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
=== Repeats _all_ tests of ClassName N times.
|
|
|
|
|
2014-02-20 08:46:59 -05:00
|
|
|
Every test repetition will have exactly the same master (0xdead) and
|
|
|
|
method-level (0xbeef) seed.
|
2013-09-13 13:50:56 -04:00
|
|
|
|
|
|
|
------------------------------------------------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -Dtests.iters=N -Dtests.class=*.ClassName -Dtests.seed=DEAD:BEEF
|
2013-09-13 13:50:56 -04:00
|
|
|
------------------------------------------------------------------------
|
|
|
|
|
|
|
|
=== Repeats a given test N times
|
|
|
|
|
|
|
|
(note the filters - individual test repetitions are given suffixes,
|
|
|
|
ie: testFoo[0], testFoo[1], etc... so using testmethod or tests.method
|
|
|
|
ending in a glob is necessary to ensure iterations are run).
|
|
|
|
|
|
|
|
-------------------------------------------------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -Dtests.iters=N -Dtests.class=*.ClassName -Dtests.method=mytest*
|
2013-09-13 13:50:56 -04:00
|
|
|
-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Repeats N times but skips any tests after the first failure or M initial failures.
|
|
|
|
|
|
|
|
-------------------------------------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -Dtests.iters=N -Dtests.failfast=true -Dtestcase=...
|
|
|
|
gradle test -Dtests.iters=N -Dtests.maxfailures=M -Dtestcase=...
|
2013-09-13 13:50:56 -04:00
|
|
|
-------------------------------------------------------------
|
|
|
|
|
|
|
|
=== Test groups.
|
|
|
|
|
|
|
|
Test groups can be enabled or disabled (true/false).
|
|
|
|
|
|
|
|
Default value provided below in [brackets].
|
|
|
|
|
|
|
|
------------------------------------------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -Dtests.nightly=[false] - nightly test group (@Nightly)
|
|
|
|
gradle test -Dtests.weekly=[false] - weekly tests (@Weekly)
|
|
|
|
gradle test -Dtests.awaitsfix=[false] - known issue (@AwaitsFix)
|
2013-09-13 13:50:56 -04:00
|
|
|
------------------------------------------------------------------
|
|
|
|
|
|
|
|
=== Load balancing and caches.
|
|
|
|
|
2015-10-08 15:16:47 -04:00
|
|
|
By default the tests run on up to 4 JVMs based on the number of cores. If you
|
|
|
|
want to explicitly specify the number of JVMs you can do so on the command
|
|
|
|
line:
|
2013-09-13 13:50:56 -04:00
|
|
|
|
|
|
|
----------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -Dtests.jvms=8
|
2013-09-13 13:50:56 -04:00
|
|
|
----------------------------
|
|
|
|
|
2015-10-08 15:16:47 -04:00
|
|
|
Or in `~/.gradle/gradle.properties`:
|
|
|
|
|
|
|
|
----------------------------
|
|
|
|
systemProp.tests.jvms=8
|
|
|
|
----------------------------
|
|
|
|
|
|
|
|
Its difficult to pick the "right" number here. Hypercores don't count for CPU
|
|
|
|
intensive tests and you should leave some slack for JVM-interal threads like
|
|
|
|
the garbage collector. And you have to have enough RAM to handle each JVM.
|
2014-02-25 06:38:22 -05:00
|
|
|
|
2014-04-22 05:36:53 -04:00
|
|
|
=== Test compatibility.
|
|
|
|
|
|
|
|
It is possible to provide a version that allows to adapt the tests behaviour
|
|
|
|
to older features or bugs that have been changed or fixed in the meantime.
|
|
|
|
|
|
|
|
-----------------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -Dtests.compatibility=1.0.0
|
2014-04-22 05:36:53 -04:00
|
|
|
-----------------------------------------
|
|
|
|
|
2014-02-25 06:38:22 -05:00
|
|
|
|
2013-09-13 13:50:56 -04:00
|
|
|
=== Miscellaneous.
|
|
|
|
|
|
|
|
Run all tests without stopping on errors (inspect log files).
|
|
|
|
|
|
|
|
-----------------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -Dtests.haltonfailure=false
|
2013-09-13 13:50:56 -04:00
|
|
|
-----------------------------------------
|
|
|
|
|
|
|
|
Run more verbose output (slave JVM parameters, etc.).
|
|
|
|
|
|
|
|
----------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -verbose
|
2013-09-13 13:50:56 -04:00
|
|
|
----------------------
|
|
|
|
|
2014-02-25 06:38:22 -05:00
|
|
|
Change the default suite timeout to 5 seconds for all
|
|
|
|
tests (note the exclamation mark).
|
2013-09-13 13:50:56 -04:00
|
|
|
|
|
|
|
---------------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -Dtests.timeoutSuite=5000! ...
|
2013-09-13 13:50:56 -04:00
|
|
|
---------------------------------------
|
|
|
|
|
2015-10-29 14:40:19 -04:00
|
|
|
Change the logging level of ES (not gradle)
|
2013-09-13 13:50:56 -04:00
|
|
|
|
|
|
|
--------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -Des.logger.level=DEBUG
|
2013-09-13 13:50:56 -04:00
|
|
|
--------------------------------
|
|
|
|
|
|
|
|
Print all the logging output from the test runs to the commandline
|
|
|
|
even if tests are passing.
|
|
|
|
|
|
|
|
------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -Dtests.output=always
|
2013-09-13 13:50:56 -04:00
|
|
|
------------------------------
|
2013-12-07 09:41:51 -05:00
|
|
|
|
2014-08-21 07:11:49 -04:00
|
|
|
Configure the heap size.
|
|
|
|
|
|
|
|
------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -Dtests.heap.size=512m
|
2014-08-21 07:11:49 -04:00
|
|
|
------------------------------
|
|
|
|
|
|
|
|
Pass arbitrary jvm arguments.
|
|
|
|
|
|
|
|
------------------------------
|
2015-10-28 15:28:30 -04:00
|
|
|
# specify heap dump path
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -Dtests.jvm.argline="-XX:HeapDumpPath=/path/to/heapdumps"
|
2015-10-28 15:28:30 -04:00
|
|
|
# enable gc logging
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -Dtests.jvm.argline="-verbose:gc"
|
2015-10-28 15:28:30 -04:00
|
|
|
# enable security debugging
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -Dtests.jvm.argline="-Djava.security.debug=access,failure"
|
2014-08-21 07:11:49 -04:00
|
|
|
------------------------------
|
|
|
|
|
2014-05-14 11:52:02 -04:00
|
|
|
== Backwards Compatibility Tests
|
|
|
|
|
|
|
|
Running backwards compatibility tests is disabled by default since it
|
|
|
|
requires a release version of elasticsearch to be present on the test system.
|
2015-05-12 04:24:12 -04:00
|
|
|
To run backwards compatibilty tests untar or unzip a release and run the tests
|
2014-05-14 11:52:02 -04:00
|
|
|
with the following command:
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -Dtests.filter="@backwards" -Dtests.bwc.version=x.y.z -Dtests.bwc.path=/path/to/elasticsearch -Dtests.security.manager=false
|
2014-05-14 11:52:02 -04:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
2015-05-12 04:24:12 -04:00
|
|
|
Note that backwards tests must be run with security manager disabled.
|
2014-05-14 11:52:02 -04:00
|
|
|
If the elasticsearch release is placed under `./backwards/elasticsearch-x.y.z` the path
|
|
|
|
can be omitted:
|
2015-08-04 09:36:22 -04:00
|
|
|
|
2014-05-14 11:52:02 -04:00
|
|
|
---------------------------------------------------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle test -Dtests.filter="@backwards" -Dtests.bwc.version=x.y.z -Dtests.security.manager=false
|
2014-06-27 09:39:53 -04:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
To setup the bwc test environment execute the following steps (provided you are
|
|
|
|
already in your elasticsearch clone):
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
$ mkdir backwards && cd backwards
|
|
|
|
$ curl -O https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.2.1.tar.gz
|
2015-08-04 09:36:22 -04:00
|
|
|
$ tar -xzf elasticsearch-1.2.1.tar.gz
|
2014-05-14 11:52:02 -04:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
2015-10-29 14:40:19 -04:00
|
|
|
== Running verification tasks
|
2015-08-03 23:08:18 -04:00
|
|
|
|
2015-10-29 14:40:19 -04:00
|
|
|
To run all verification tasks, including static checks, unit tests, and integration tests:
|
2015-08-03 23:08:18 -04:00
|
|
|
|
|
|
|
---------------------------------------------------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle check
|
2015-08-03 23:08:18 -04:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
2015-10-29 14:40:19 -04:00
|
|
|
Note that this will also run the unit tests and precommit tasks first. If you want to just
|
|
|
|
run the integration tests (because you are debugging them):
|
2015-08-03 23:08:18 -04:00
|
|
|
|
|
|
|
---------------------------------------------------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle integTest
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
If you want to just run the precommit checks:
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
gradle precommit
|
2015-08-03 23:08:18 -04:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
2013-12-07 09:41:51 -05:00
|
|
|
== Testing the REST layer
|
|
|
|
|
|
|
|
The available integration tests make use of the java API to communicate with
|
|
|
|
the elasticsearch nodes, using the internal binary transport (port 9300 by
|
|
|
|
default).
|
|
|
|
The REST layer is tested through specific tests that are shared between all
|
2013-12-27 14:36:12 -05:00
|
|
|
the elasticsearch official clients and consist of YAML files that describe the
|
|
|
|
operations to be executed and the obtained results that need to be tested.
|
2013-12-07 09:41:51 -05:00
|
|
|
|
2013-12-18 04:55:57 -05:00
|
|
|
The REST tests are run automatically when executing the maven test command. To run only the
|
|
|
|
REST tests use the following command:
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------
|
2015-10-29 14:40:19 -04:00
|
|
|
gradle integTest -Dtests.filter="@Rest"
|
2013-12-18 04:55:57 -05:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
2015-08-03 23:08:18 -04:00
|
|
|
`RestNIT` are the executable test classes that runs all the
|
2013-12-27 14:43:16 -05:00
|
|
|
yaml suites available within the `rest-api-spec` folder.
|
2013-12-07 09:41:51 -05:00
|
|
|
|
2014-03-10 08:48:17 -04:00
|
|
|
The REST tests support all the options provided by the randomized runner, plus the following:
|
2013-12-07 09:41:51 -05:00
|
|
|
|
2014-03-10 08:48:17 -04:00
|
|
|
* `tests.rest[true|false]`: determines whether the REST tests need to be run (default) or not.
|
2013-12-07 09:41:51 -05:00
|
|
|
* `tests.rest.suite`: comma separated paths of the test suites to be run
|
2013-12-27 14:43:16 -05:00
|
|
|
(by default loaded from /rest-api-spec/test). It is possible to run only a subset
|
2013-12-07 09:41:51 -05:00
|
|
|
of the tests providing a sub-folder or even a single yaml file (the default
|
2013-12-27 14:43:16 -05:00
|
|
|
/rest-api-spec/test prefix is optional when files are loaded from classpath)
|
2013-12-07 09:41:51 -05:00
|
|
|
e.g. -Dtests.rest.suite=index,get,create/10_with_id
|
2014-04-19 05:13:51 -04:00
|
|
|
* `tests.rest.blacklist`: comma separated globs that identify tests that are
|
|
|
|
blacklisted and need to be skipped
|
|
|
|
e.g. -Dtests.rest.blacklist=index/*/Index document,get/10_basic/*
|
2013-12-27 14:43:16 -05:00
|
|
|
* `tests.rest.spec`: REST spec path (default /rest-api-spec/api)
|
2014-03-10 08:48:17 -04:00
|
|
|
|
|
|
|
Note that the REST tests, like all the integration tests, can be run against an external
|
|
|
|
cluster by specifying the `tests.cluster` property, which if present needs to contain a
|
|
|
|
comma separated list of nodes to connect to (e.g. localhost:9300). A transport client will
|
|
|
|
be created based on that and used for all the before|after test operations, and to extract
|
|
|
|
the http addresses of the nodes so that REST requests can be sent to them.
|
2014-05-14 11:52:02 -04:00
|
|
|
|
2015-04-14 10:22:37 -04:00
|
|
|
== Testing scripts
|
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
The simplest way to test scripts and the packaged distributions is to use
|
|
|
|
Vagrant. You can get started by following there five easy steps:
|
2015-04-14 10:22:37 -04:00
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
. Install Virtual Box and Vagrant.
|
2015-04-14 10:22:37 -04:00
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
. (Optional) Install vagrant-cachier to squeeze a bit more performance out of
|
|
|
|
the process:
|
2015-08-17 11:45:18 -04:00
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
--------------------------------------
|
|
|
|
vagrant plugin install vagrant-cachier
|
|
|
|
--------------------------------------
|
2015-04-14 10:22:37 -04:00
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
. Validate your installed dependencies:
|
2015-08-17 11:45:18 -04:00
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
-------------------------------------
|
2015-11-02 12:40:47 -05:00
|
|
|
gradle :qa:vagrant:checkVagrantVersion
|
2015-08-04 09:36:22 -04:00
|
|
|
-------------------------------------
|
|
|
|
|
2015-11-02 12:40:47 -05:00
|
|
|
. Download and smoke test the VMs with `gradle vagrantSmokeTest` or
|
|
|
|
`gradle vagrantSmokeTestAllDistros`. The first time you run this it will
|
|
|
|
download the base images and provision the boxes and immediately quit. If you
|
|
|
|
you this again it'll skip the download step.
|
2015-08-17 11:45:18 -04:00
|
|
|
|
2015-11-02 12:40:47 -05:00
|
|
|
. Run the tests with `gradle checkPackages`. This will cause gradle to build
|
|
|
|
the tar, zip, and deb packages and all the plugins. It will then run the tests
|
|
|
|
on ubuntu-1404 and centos-7. We chose those two distributions as the default
|
|
|
|
because they cover deb and rpm packaging and SyvVinit and systemd.
|
2015-08-17 11:45:18 -04:00
|
|
|
|
2015-11-02 12:40:47 -05:00
|
|
|
You can run on all the VMs by running `gradle checkPackagesAllDistros`. You can
|
|
|
|
run a particular VM with a command like `gradle checkOel7`. See `gradle tasks`
|
|
|
|
for a list. Its important to know that if you ctrl-c any of these `gradle`
|
|
|
|
commands then the boxes will remain running and you'll have to terminate them
|
|
|
|
with `vagrant halt`.
|
2015-08-17 11:45:18 -04:00
|
|
|
|
2015-11-02 12:40:47 -05:00
|
|
|
All the regular vagrant commands should just work so you can get a shell in a
|
|
|
|
VM running trusty by running
|
|
|
|
`vagrant up ubuntu-1404 --provider virtualbox && vagrant ssh ubuntu-1404`.
|
2015-08-04 09:36:22 -04:00
|
|
|
|
|
|
|
These are the linux flavors the Vagrantfile currently supports:
|
2015-08-17 11:45:18 -04:00
|
|
|
|
2015-11-02 12:40:47 -05:00
|
|
|
* ubuntu-1204 aka precise
|
|
|
|
* ubuntu-1404 aka trusty
|
|
|
|
* ubuntu-1504 aka vivid
|
|
|
|
* debian-8 aka jessie, the current debian stable distribution
|
2015-08-04 09:36:22 -04:00
|
|
|
* centos-6
|
|
|
|
* centos-7
|
|
|
|
* fedora-22
|
|
|
|
* oel-7 aka Oracle Enterprise Linux 7
|
2015-09-22 08:59:39 -04:00
|
|
|
* sles-12
|
2015-11-02 12:40:47 -05:00
|
|
|
* opensuse-13
|
2015-08-04 09:36:22 -04:00
|
|
|
|
|
|
|
We're missing the following from the support matrix because there aren't high
|
|
|
|
quality boxes available in vagrant atlas:
|
2015-08-17 11:45:18 -04:00
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
* sles-11
|
|
|
|
* oel-6
|
|
|
|
|
|
|
|
We're missing the follow because our tests are very linux/bash centric:
|
2015-08-17 11:45:18 -04:00
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
* Windows Server 2012
|
|
|
|
|
2015-11-02 12:40:47 -05:00
|
|
|
Its important to think of VMs like cattle. If they become lame you just shoot
|
2015-08-04 09:36:22 -04:00
|
|
|
them and let vagrant reprovision them. Say you've hosed your precise VM:
|
2015-08-17 11:45:18 -04:00
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
----------------------------------------------------
|
2015-11-02 12:40:47 -05:00
|
|
|
vagrant ssh ubuntu-1404 -c 'sudo rm -rf /bin'; echo oops
|
2015-08-04 09:36:22 -04:00
|
|
|
----------------------------------------------------
|
2015-08-17 11:45:18 -04:00
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
All you've got to do to get another one is
|
2015-08-17 11:45:18 -04:00
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
----------------------------------------------
|
2015-11-02 12:40:47 -05:00
|
|
|
vagrant destroy -f ubuntu-1404 && vagrant up ubuntu-1404 --provider virtualbox
|
2015-08-04 09:36:22 -04:00
|
|
|
----------------------------------------------
|
2015-08-17 11:45:18 -04:00
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
The whole process takes a minute and a half on a modern laptop, two and a half
|
|
|
|
without vagrant-cachier.
|
|
|
|
|
|
|
|
Its possible that some downloads will fail and it'll be impossible to restart
|
|
|
|
them. This is a bug in vagrant. See the instructions here for how to work
|
|
|
|
around it:
|
|
|
|
https://github.com/mitchellh/vagrant/issues/4479
|
|
|
|
|
|
|
|
Some vagrant commands will work on all VMs at once:
|
2015-08-17 11:45:18 -04:00
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
------------------
|
|
|
|
vagrant halt
|
|
|
|
vagrant destroy -f
|
|
|
|
------------------
|
|
|
|
|
2015-11-02 12:40:47 -05:00
|
|
|
`vagrant up` would normally start all the VMs but we've prevented that because
|
|
|
|
that'd consume a ton of ram.
|
2015-08-04 09:36:22 -04:00
|
|
|
|
|
|
|
== Testing scripts more directly
|
|
|
|
|
|
|
|
In general its best to stick to testing in vagrant because the bats scripts are
|
|
|
|
destructive. When working with a single package its generally faster to run its
|
|
|
|
tests in a tighter loop than maven provides. In one window:
|
2015-08-17 11:45:18 -04:00
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
--------------------------------
|
2015-11-02 12:40:47 -05:00
|
|
|
gradle :distribution:rpm:assemble
|
2015-08-04 09:36:22 -04:00
|
|
|
--------------------------------
|
2015-08-17 11:45:18 -04:00
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
and in another window:
|
2015-08-17 11:45:18 -04:00
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
----------------------------------------------------
|
2015-08-31 10:50:50 -04:00
|
|
|
vagrant up centos-7 --provider virtualbox && vagrant ssh centos-7
|
2015-08-04 09:36:22 -04:00
|
|
|
cd $RPM
|
2015-08-14 18:12:52 -04:00
|
|
|
sudo bats $BATS/*rpm*.bats
|
2015-08-04 09:36:22 -04:00
|
|
|
----------------------------------------------------
|
2015-04-14 10:22:37 -04:00
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
If you wanted to retest all the release artifacts on a single VM you could:
|
2015-08-17 11:45:18 -04:00
|
|
|
|
2015-08-04 09:36:22 -04:00
|
|
|
-------------------------------------------------
|
2015-11-05 15:47:54 -05:00
|
|
|
gradle prepareTestRoot
|
2015-08-31 10:50:50 -04:00
|
|
|
vagrant up trusty --provider virtualbox && vagrant ssh trusty
|
2015-08-04 09:36:22 -04:00
|
|
|
cd $TESTROOT
|
2015-08-14 18:12:52 -04:00
|
|
|
sudo bats $BATS/*.bats
|
2015-08-04 09:36:22 -04:00
|
|
|
-------------------------------------------------
|
2015-08-03 23:08:18 -04:00
|
|
|
|
|
|
|
== Coverage analysis
|
|
|
|
|
2015-09-01 20:57:08 -04:00
|
|
|
Tests can be run instrumented with jacoco to produce a coverage report in
|
|
|
|
`target/site/jacoco/`.
|
|
|
|
|
|
|
|
Unit test coverage:
|
2015-08-03 23:08:18 -04:00
|
|
|
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
mvn -Dtests.coverage test jacoco:report
|
|
|
|
---------------------------------------------------------------------------
|
2015-08-09 06:15:47 -04:00
|
|
|
|
2015-09-01 20:57:08 -04:00
|
|
|
Integration test coverage:
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
mvn -Dtests.coverage -Dskip.unit.tests verify jacoco:report
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Combined (Unit+Integration) coverage:
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
mvn -Dtests.coverage verify jacoco:report
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
2015-08-09 06:15:47 -04:00
|
|
|
== Debugging from an IDE
|
|
|
|
|
2015-11-17 18:37:26 -05:00
|
|
|
If you want to run elasticsearch from your IDE, the `gradle run` task
|
|
|
|
supports a remote debugging option:
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
gradle run --debug-jvm
|
|
|
|
---------------------------------------------------------------------------
|
2015-11-20 14:58:50 -05:00
|
|
|
|
|
|
|
== Building with extra plugins
|
|
|
|
Additional plugins may be built alongside elasticsearch, where their
|
|
|
|
dependency on elasticsearch will be substituted with the local elasticsearch
|
2015-11-23 17:54:08 -05:00
|
|
|
build. To add your plugin, create a directory called x-plugins as a sibling
|
|
|
|
of elasticsearch. Checkout your plugin underneath x-plugins and the build
|
|
|
|
will automatically pick it up. You can verify the plugin is included as part
|
|
|
|
of the build by checking the projects of the build.
|
2015-11-20 14:58:50 -05:00
|
|
|
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
gradle projects
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|