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:
|
|
|
|
|
|
|
|
-----------------------------
|
|
|
|
mvn clean package -DskipTests
|
|
|
|
-----------------------------
|
|
|
|
|
|
|
|
== 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
|
|
|
-------------------------------------
|
2013-12-07 14:52:47 -05:00
|
|
|
export ES_TEST_LOCAL=true && mvn test
|
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)
|
|
|
|
|
|
|
|
----------------------------------------------------------
|
|
|
|
mvn test -Dtests.class=org.elasticsearch.package.ClassName
|
|
|
|
mvn test "-Dtests.class=*.ClassName"
|
|
|
|
----------------------------------------------------------
|
|
|
|
|
|
|
|
Run all tests in a package and sub-packages
|
|
|
|
|
|
|
|
----------------------------------------------------
|
|
|
|
mvn test "-Dtests.class=org.elasticsearch.package.*"
|
|
|
|
----------------------------------------------------
|
|
|
|
|
|
|
|
Run any test methods that contain 'esi' (like: ...r*esi*ze...).
|
|
|
|
|
|
|
|
-------------------------------
|
|
|
|
mvn test "-Dtests.method=*esi*"
|
|
|
|
-------------------------------
|
|
|
|
|
|
|
|
=== Seed and repetitions.
|
|
|
|
|
|
|
|
Run with a given seed (seed is a hex-encoded long).
|
|
|
|
|
|
|
|
------------------------------
|
|
|
|
mvn test -Dtests.seed=DEADBEEF
|
|
|
|
------------------------------
|
|
|
|
|
|
|
|
=== Repeats _all_ tests of ClassName N times.
|
|
|
|
|
2014-02-20 08:46:59 -05:00
|
|
|
Every test repetition will have a different method seed
|
|
|
|
(derived from a single random master seed).
|
2013-09-13 13:50:56 -04:00
|
|
|
|
|
|
|
--------------------------------------------------
|
|
|
|
mvn test -Dtests.iters=N -Dtests.class=*.ClassName
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
=== 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
|
|
|
|
|
|
|
------------------------------------------------------------------------
|
2014-02-20 08:46:59 -05:00
|
|
|
mvn 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).
|
|
|
|
|
|
|
|
-------------------------------------------------------------------------
|
|
|
|
mvn test -Dtests.iters=N -Dtests.class=*.ClassName -Dtests.method=mytest*
|
|
|
|
-------------------------------------------------------------------------
|
|
|
|
|
|
|
|
Repeats N times but skips any tests after the first failure or M initial failures.
|
|
|
|
|
|
|
|
-------------------------------------------------------------
|
|
|
|
mvn test -Dtests.iters=N -Dtests.failfast=true -Dtestcase=...
|
|
|
|
mvn test -Dtests.iters=N -Dtests.maxfailures=M -Dtestcase=...
|
|
|
|
-------------------------------------------------------------
|
|
|
|
|
|
|
|
=== Test groups.
|
|
|
|
|
|
|
|
Test groups can be enabled or disabled (true/false).
|
|
|
|
|
|
|
|
Default value provided below in [brackets].
|
|
|
|
|
|
|
|
------------------------------------------------------------------
|
|
|
|
mvn test -Dtests.nightly=[false] - nightly test group (@Nightly)
|
|
|
|
mvn test -Dtests.weekly=[false] - weekly tests (@Weekly)
|
|
|
|
mvn test -Dtests.awaitsfix=[false] - known issue (@AwaitsFix)
|
|
|
|
mvn test -Dtests.slow=[true] - slow tests (@Slow)
|
|
|
|
------------------------------------------------------------------
|
|
|
|
|
|
|
|
=== Load balancing and caches.
|
|
|
|
|
2014-02-25 06:38:22 -05:00
|
|
|
By default, the tests run sequentially on a single forked JVM.
|
2013-09-13 13:50:56 -04:00
|
|
|
|
2014-02-25 06:38:22 -05:00
|
|
|
To run with more forked JVMs than the default use:
|
2013-09-13 13:50:56 -04:00
|
|
|
|
|
|
|
----------------------------
|
|
|
|
mvn test -Dtests.jvms=8 test
|
|
|
|
----------------------------
|
|
|
|
|
2014-02-25 06:38:22 -05:00
|
|
|
Don't count hypercores for CPU-intense tests and leave some slack
|
|
|
|
for JVM-internal threads (like the garbage collector). Make sure there is
|
|
|
|
enough RAM to handle child JVMs.
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
-----------------------------------------
|
|
|
|
mvn test -Dtests.compatibility=1.0.0
|
|
|
|
-----------------------------------------
|
|
|
|
|
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).
|
|
|
|
|
|
|
|
-----------------------------------------
|
|
|
|
mvn test -Dtests.haltonfailure=false test
|
|
|
|
-----------------------------------------
|
|
|
|
|
|
|
|
Run more verbose output (slave JVM parameters, etc.).
|
|
|
|
|
|
|
|
----------------------
|
|
|
|
mvn test -verbose test
|
|
|
|
----------------------
|
|
|
|
|
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
|
|
|
|
|
|
|
---------------------------------------
|
|
|
|
mvn test -Dtests.timeoutSuite=5000! ...
|
|
|
|
---------------------------------------
|
|
|
|
|
|
|
|
Change the logging level of ES (not mvn)
|
|
|
|
|
|
|
|
--------------------------------
|
|
|
|
mvn test -Des.logger.level=DEBUG
|
|
|
|
--------------------------------
|
|
|
|
|
|
|
|
Print all the logging output from the test runs to the commandline
|
|
|
|
even if tests are passing.
|
|
|
|
|
|
|
|
------------------------------
|
|
|
|
mvn test -Dtests.output=always
|
|
|
|
------------------------------
|
2013-12-07 09:41:51 -05: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.
|
|
|
|
To run backwards compatibiilty tests untar or unzip a release and run the tests
|
|
|
|
with the following command:
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------
|
2014-07-01 09:41:02 -04:00
|
|
|
mvn test -Dtests.bwc=true -Dtests.bwc.version=x.y.z -Dtests.bwc.path=/path/to/elasticsearch
|
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:
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------
|
2014-07-01 09:41:02 -04:00
|
|
|
mvn test -Dtests.bwc=true -Dtests.bwc.version=x.y.z
|
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
|
|
|
|
$ tar -xzf elasticsearch-1.2.1.tar.gz
|
2014-05-14 11:52:02 -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:
|
|
|
|
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
mvn test -Dtests.class=org.elasticsearch.test.rest.ElasticsearchRestTests
|
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
2013-12-07 09:41:51 -05:00
|
|
|
`ElasticsearchRestTests` is the executable test class 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
|
|
|
|
|
|
|
|