TESTING.asciidoc 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. [[Testing Framework Cheatsheet]]
  2. = Testing
  3. [partintro]
  4. --
  5. Elasticsearch uses jUnit for testing, it also uses randomness in the
  6. tests, that can be set using a seed, the following is a cheatsheet of
  7. options for running the tests for ES.
  8. == Creating packages
  9. To create a distribution without running the tests, simply run the
  10. following:
  11. -----------------------------
  12. mvn clean package -DskipTests
  13. -----------------------------
  14. == Other test options
  15. To disable and enable network transport, set the `ES_TEST_LOCAL`
  16. environment variable.
  17. Use network transport (default):
  18. ------------------------------------
  19. export ES_TEST_LOCAL=false && mvn test
  20. ------------------------------------
  21. Use local transport:
  22. -------------------------------------
  23. export ES_TEST_LOCAL=true && mvn test
  24. -------------------------------------
  25. === Test case filtering.
  26. - `tests.class` is a class-filtering shell-like glob pattern,
  27. - `tests.method` is a method-filtering glob pattern.
  28. Run a single test case (variants)
  29. ----------------------------------------------------------
  30. mvn test -Dtests.class=org.elasticsearch.package.ClassName
  31. mvn test "-Dtests.class=*.ClassName"
  32. ----------------------------------------------------------
  33. Run all tests in a package and sub-packages
  34. ----------------------------------------------------
  35. mvn test "-Dtests.class=org.elasticsearch.package.*"
  36. ----------------------------------------------------
  37. Run any test methods that contain 'esi' (like: ...r*esi*ze...).
  38. -------------------------------
  39. mvn test "-Dtests.method=*esi*"
  40. -------------------------------
  41. === Seed and repetitions.
  42. Run with a given seed (seed is a hex-encoded long).
  43. ------------------------------
  44. mvn test -Dtests.seed=DEADBEEF
  45. ------------------------------
  46. === Repeats _all_ tests of ClassName N times.
  47. Every test repetition will have a different seed.
  48. --------------------------------------------------
  49. mvn test -Dtests.iters=N -Dtests.class=*.ClassName
  50. --------------------------------------------------
  51. === Repeats _all_ tests of ClassName N times.
  52. Every test repetition will have exactly the same master (dead) and
  53. method-level (beef) seed.
  54. ------------------------------------------------------------------------
  55. mvn test -Dtests.iters=N -Dtests.class=*.ClassName -Dtests.seed=DEADBEEF
  56. ------------------------------------------------------------------------
  57. === Repeats a given test N times
  58. (note the filters - individual test repetitions are given suffixes,
  59. ie: testFoo[0], testFoo[1], etc... so using testmethod or tests.method
  60. ending in a glob is necessary to ensure iterations are run).
  61. -------------------------------------------------------------------------
  62. mvn test -Dtests.iters=N -Dtests.class=*.ClassName -Dtests.method=mytest*
  63. -------------------------------------------------------------------------
  64. Repeats N times but skips any tests after the first failure or M initial failures.
  65. -------------------------------------------------------------
  66. mvn test -Dtests.iters=N -Dtests.failfast=true -Dtestcase=...
  67. mvn test -Dtests.iters=N -Dtests.maxfailures=M -Dtestcase=...
  68. -------------------------------------------------------------
  69. === Test groups.
  70. Test groups can be enabled or disabled (true/false).
  71. Default value provided below in [brackets].
  72. ------------------------------------------------------------------
  73. mvn test -Dtests.nightly=[false] - nightly test group (@Nightly)
  74. mvn test -Dtests.weekly=[false] - weekly tests (@Weekly)
  75. mvn test -Dtests.awaitsfix=[false] - known issue (@AwaitsFix)
  76. mvn test -Dtests.slow=[true] - slow tests (@Slow)
  77. ------------------------------------------------------------------
  78. === Load balancing and caches.
  79. Run sequentially (one slave JVM). By default, the tests run with 3
  80. concurrent JVMs.
  81. ----------------------------
  82. mvn test -Dtests.jvms=1 test
  83. ----------------------------
  84. Run with more slave JVMs than the default. Don't count hypercores for
  85. CPU-intense tests. Make sure there is enough RAM to handle child JVMs.
  86. ----------------------------
  87. mvn test -Dtests.jvms=8 test
  88. ----------------------------
  89. === Miscellaneous.
  90. Run all tests without stopping on errors (inspect log files).
  91. -----------------------------------------
  92. mvn test -Dtests.haltonfailure=false test
  93. -----------------------------------------
  94. Run more verbose output (slave JVM parameters, etc.).
  95. ----------------------
  96. mvn test -verbose test
  97. ----------------------
  98. Change the default suite timeout to 5 seconds.
  99. ---------------------------------------
  100. mvn test -Dtests.timeoutSuite=5000! ...
  101. ---------------------------------------
  102. Change the logging level of ES (not mvn)
  103. --------------------------------
  104. mvn test -Des.logger.level=DEBUG
  105. --------------------------------
  106. Print all the logging output from the test runs to the commandline
  107. even if tests are passing.
  108. ------------------------------
  109. mvn test -Dtests.output=always
  110. ------------------------------
  111. == Testing the REST layer
  112. The available integration tests make use of the java API to communicate with
  113. the elasticsearch nodes, using the internal binary transport (port 9300 by
  114. default).
  115. The REST layer is tested through specific tests that are shared between all
  116. the elasticsearch official clients and consist of YAML files that describe the
  117. operations to be executed and the obtained results that need to be tested.
  118. The REST tests are run automatically when executing the maven test command. To run only the
  119. REST tests use the following command:
  120. ---------------------------------------------------------------------------
  121. mvn test -Dtests.class=org.elasticsearch.test.rest.ElasticsearchRestTests
  122. ---------------------------------------------------------------------------
  123. `ElasticsearchRestTests` is the executable test class that runs all the
  124. yaml suites available within the `rest-api-spec` folder.
  125. The following are the options supported by the REST tests runner:
  126. * `tests.rest[true|false|host:port]`: determines whether the REST tests need
  127. to be run and if so whether to rely on an external cluster (providing host
  128. and port) or fire a test cluster (default). It's possible to provide a
  129. comma separated list of addresses to send requests in a round-robin fashion.
  130. * `tests.rest.suite`: comma separated paths of the test suites to be run
  131. (by default loaded from /rest-api-spec/test). It is possible to run only a subset
  132. of the tests providing a sub-folder or even a single yaml file (the default
  133. /rest-api-spec/test prefix is optional when files are loaded from classpath)
  134. e.g. -Dtests.rest.suite=index,get,create/10_with_id
  135. * `tests.rest.section`: regex that allows to filter the test sections that
  136. are going to be run. If provided, only the section names that match (case
  137. insensitive) against it will be executed
  138. * `tests.rest.spec`: REST spec path (default /rest-api-spec/api)
  139. * `tests.iters`: runs multiple iterations
  140. * `tests.seed`: seed to base the random behaviours on
  141. * `tests.appendseed[true|false]`: enables adding the seed to each test
  142. section's description (default false)
  143. * `tests.cluster_seed`: seed used to create the test cluster (if enabled)