TESTING.asciidoc 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. [[Testing Framework Cheatsheet]]
  2. = Testing
  3. [partintro]
  4. Elasticsearch uses jUnit for testing, it also uses randomness in the
  5. tests, that can be set using a seed, the following is a cheatsheet of
  6. options for running the tests for ES.
  7. == Creating packages
  8. To create a distribution without running the tests, simply run the
  9. following:
  10. -----------------------------
  11. ./gradlew assemble
  12. -----------------------------
  13. === Running Elasticsearch from a checkout
  14. In order to run Elasticsearch from source without building a package, you can
  15. run it using Gradle:
  16. -------------------------------------
  17. ./gradlew run
  18. -------------------------------------
  19. ==== Launching and debugging from an IDE
  20. If you want to run Elasticsearch from your IDE, the `./gradlew run` task
  21. supports a remote debugging option:
  22. ---------------------------------------------------------------------------
  23. ./gradlew run --debug-jvm
  24. ---------------------------------------------------------------------------
  25. ==== Distribution
  26. By default a node is started with the zip distribution.
  27. In order to start with a different distribution use the `-Drun.distribution` argument.
  28. To for example start the open source distribution:
  29. -------------------------------------
  30. ./gradlew run -Drun.distribution=oss-zip
  31. -------------------------------------
  32. ==== License type
  33. By default a node is started with the `basic` license type.
  34. In order to start with a different license type use the `-Drun.license_type` argument.
  35. In order to start a node with a trial license execute the following command:
  36. -------------------------------------
  37. ./gradlew run -Drun.license_type=trial
  38. -------------------------------------
  39. This enables security and other paid features and adds a superuser with the username: `elastic-admin` and
  40. password: `elastic-password`.
  41. ==== Other useful arguments
  42. In order to start a node with a different max heap space add: `-Dtests.heap.size=4G`
  43. In order to disable annotations add: `-Dtests.asserts=false`
  44. In order to set an Elasticsearch setting, provide a setting with the following prefix: `-Dtests.es.`
  45. === Test case filtering.
  46. - `tests.class` is a class-filtering shell-like glob pattern,
  47. - `tests.method` is a method-filtering glob pattern.
  48. Run a single test case (variants)
  49. ----------------------------------------------------------
  50. ./gradlew test -Dtests.class=org.elasticsearch.package.ClassName
  51. ./gradlew test "-Dtests.class=*.ClassName"
  52. ----------------------------------------------------------
  53. Run all tests in a package and sub-packages
  54. ----------------------------------------------------
  55. ./gradlew test "-Dtests.class=org.elasticsearch.package.*"
  56. ----------------------------------------------------
  57. Run any test methods that contain 'esi' (like: ...r*esi*ze...).
  58. -------------------------------
  59. ./gradlew test "-Dtests.method=*esi*"
  60. -------------------------------
  61. You can also filter tests by certain annotations ie:
  62. * `@Nightly` - tests that only run in nightly builds (disabled by default)
  63. * `@Backwards` - backwards compatibility tests (disabled by default)
  64. * `@AwaitsFix` - tests that are waiting for a bugfix (disabled by default)
  65. * `@BadApple` - tests that are known to fail randomly (disabled by default)
  66. Those annotation names can be combined into a filter expression like:
  67. ------------------------------------------------
  68. ./gradlew test -Dtests.filter="@nightly and not @backwards"
  69. ------------------------------------------------
  70. to run all nightly test but not the ones that are backwards tests. `tests.filter` supports
  71. the boolean operators `and, or, not` and grouping ie:
  72. ---------------------------------------------------------------
  73. ./gradlew test -Dtests.filter="@nightly and not(@badapple or @backwards)"
  74. ---------------------------------------------------------------
  75. === Seed and repetitions.
  76. Run with a given seed (seed is a hex-encoded long).
  77. ------------------------------
  78. ./gradlew test -Dtests.seed=DEADBEEF
  79. ------------------------------
  80. === Repeats _all_ tests of ClassName N times.
  81. Every test repetition will have a different method seed
  82. (derived from a single random master seed).
  83. --------------------------------------------------
  84. ./gradlew test -Dtests.iters=N -Dtests.class=*.ClassName
  85. --------------------------------------------------
  86. === Repeats _all_ tests of ClassName N times.
  87. Every test repetition will have exactly the same master (0xdead) and
  88. method-level (0xbeef) seed.
  89. ------------------------------------------------------------------------
  90. ./gradlew test -Dtests.iters=N -Dtests.class=*.ClassName -Dtests.seed=DEAD:BEEF
  91. ------------------------------------------------------------------------
  92. === Repeats a given test N times
  93. (note the filters - individual test repetitions are given suffixes,
  94. ie: testFoo[0], testFoo[1], etc... so using testmethod or tests.method
  95. ending in a glob is necessary to ensure iterations are run).
  96. -------------------------------------------------------------------------
  97. ./gradlew test -Dtests.iters=N -Dtests.class=*.ClassName -Dtests.method=mytest*
  98. -------------------------------------------------------------------------
  99. Repeats N times but skips any tests after the first failure or M initial failures.
  100. -------------------------------------------------------------
  101. ./gradlew test -Dtests.iters=N -Dtests.failfast=true -Dtestcase=...
  102. ./gradlew test -Dtests.iters=N -Dtests.maxfailures=M -Dtestcase=...
  103. -------------------------------------------------------------
  104. === Test groups.
  105. Test groups can be enabled or disabled (true/false).
  106. Default value provided below in [brackets].
  107. ------------------------------------------------------------------
  108. ./gradlew test -Dtests.nightly=[false] - nightly test group (@Nightly)
  109. ./gradlew test -Dtests.weekly=[false] - weekly tests (@Weekly)
  110. ./gradlew test -Dtests.awaitsfix=[false] - known issue (@AwaitsFix)
  111. ------------------------------------------------------------------
  112. === Load balancing and caches.
  113. By default the tests run on up to 4 JVMs based on the number of cores. If you
  114. want to explicitly specify the number of JVMs you can do so on the command
  115. line:
  116. ----------------------------
  117. ./gradlew test -Dtests.jvms=8
  118. ----------------------------
  119. Or in `~/.gradle/gradle.properties`:
  120. ----------------------------
  121. systemProp.tests.jvms=8
  122. ----------------------------
  123. Its difficult to pick the "right" number here. Hypercores don't count for CPU
  124. intensive tests and you should leave some slack for JVM-interal threads like
  125. the garbage collector. And you have to have enough RAM to handle each JVM.
  126. === Test compatibility.
  127. It is possible to provide a version that allows to adapt the tests behaviour
  128. to older features or bugs that have been changed or fixed in the meantime.
  129. -----------------------------------------
  130. ./gradlew test -Dtests.compatibility=1.0.0
  131. -----------------------------------------
  132. === Miscellaneous.
  133. Run all tests without stopping on errors (inspect log files).
  134. -----------------------------------------
  135. ./gradlew test -Dtests.haltonfailure=false
  136. -----------------------------------------
  137. Run more verbose output (slave JVM parameters, etc.).
  138. ----------------------
  139. ./gradlew test -verbose
  140. ----------------------
  141. Change the default suite timeout to 5 seconds for all
  142. tests (note the exclamation mark).
  143. ---------------------------------------
  144. ./gradlew test -Dtests.timeoutSuite=5000! ...
  145. ---------------------------------------
  146. Change the logging level of ES (not Gradle)
  147. --------------------------------
  148. ./gradlew test -Dtests.es.logger.level=DEBUG
  149. --------------------------------
  150. Print all the logging output from the test runs to the commandline
  151. even if tests are passing.
  152. ------------------------------
  153. ./gradlew test -Dtests.output=always
  154. ------------------------------
  155. Configure the heap size.
  156. ------------------------------
  157. ./gradlew test -Dtests.heap.size=512m
  158. ------------------------------
  159. Pass arbitrary jvm arguments.
  160. ------------------------------
  161. # specify heap dump path
  162. ./gradlew test -Dtests.jvm.argline="-XX:HeapDumpPath=/path/to/heapdumps"
  163. # enable gc logging
  164. ./gradlew test -Dtests.jvm.argline="-verbose:gc"
  165. # enable security debugging
  166. ./gradlew test -Dtests.jvm.argline="-Djava.security.debug=access,failure"
  167. ------------------------------
  168. == Backwards Compatibility Tests
  169. Running backwards compatibility tests is disabled by default since it
  170. requires a release version of elasticsearch to be present on the test system.
  171. To run backwards compatibility tests untar or unzip a release and run the tests
  172. with the following command:
  173. ---------------------------------------------------------------------------
  174. ./gradlew test -Dtests.filter="@backwards" -Dtests.bwc.version=x.y.z -Dtests.bwc.path=/path/to/elasticsearch -Dtests.security.manager=false
  175. ---------------------------------------------------------------------------
  176. Note that backwards tests must be run with security manager disabled.
  177. If the elasticsearch release is placed under `./backwards/elasticsearch-x.y.z` the path
  178. can be omitted:
  179. ---------------------------------------------------------------------------
  180. ./gradlew test -Dtests.filter="@backwards" -Dtests.bwc.version=x.y.z -Dtests.security.manager=false
  181. ---------------------------------------------------------------------------
  182. To setup the bwc test environment execute the following steps (provided you are
  183. already in your elasticsearch clone):
  184. ---------------------------------------------------------------------------
  185. $ mkdir backwards && cd backwards
  186. $ curl -O https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.2.1.tar.gz
  187. $ tar -xzf elasticsearch-1.2.1.tar.gz
  188. ---------------------------------------------------------------------------
  189. == Running verification tasks
  190. To run all verification tasks, including static checks, unit tests, and integration tests:
  191. ---------------------------------------------------------------------------
  192. ./gradlew check
  193. ---------------------------------------------------------------------------
  194. Note that this will also run the unit tests and precommit tasks first. If you want to just
  195. run the integration tests (because you are debugging them):
  196. ---------------------------------------------------------------------------
  197. ./gradlew integTest
  198. ---------------------------------------------------------------------------
  199. If you want to just run the precommit checks:
  200. ---------------------------------------------------------------------------
  201. ./gradlew precommit
  202. ---------------------------------------------------------------------------
  203. == Testing the REST layer
  204. The available integration tests make use of the java API to communicate with
  205. the elasticsearch nodes, using the internal binary transport (port 9300 by
  206. default).
  207. The REST layer is tested through specific tests that are shared between all
  208. the elasticsearch official clients and consist of YAML files that describe the
  209. operations to be executed and the obtained results that need to be tested.
  210. The YAML files support various operators defined in the link:/rest-api-spec/src/main/resources/rest-api-spec/test/README.asciidoc[rest-api-spec] and adhere to the link:/rest-api-spec/README.markdown[Elasticsearch REST API JSON specification]
  211. The REST tests are run automatically when executing the "./gradlew check" command. To run only the
  212. REST tests use the following command:
  213. ---------------------------------------------------------------------------
  214. ./gradlew :distribution:archives:integ-test-zip:integTest \
  215. -Dtests.class="org.elasticsearch.test.rest.*Yaml*IT"
  216. ---------------------------------------------------------------------------
  217. A specific test case can be run with
  218. ---------------------------------------------------------------------------
  219. ./gradlew :distribution:archives:integ-test-zip:integTest \
  220. -Dtests.class="org.elasticsearch.test.rest.*Yaml*IT" \
  221. -Dtests.method="test {p0=cat.shards/10_basic/Help}"
  222. ---------------------------------------------------------------------------
  223. `*Yaml*IT` are the executable test classes that runs all the
  224. yaml suites available within the `rest-api-spec` folder.
  225. The REST tests support all the options provided by the randomized runner, plus the following:
  226. * `tests.rest[true|false]`: determines whether the REST tests need to be run (default) or not.
  227. * `tests.rest.suite`: comma separated paths of the test suites to be run
  228. (by default loaded from /rest-api-spec/test). It is possible to run only a subset
  229. of the tests providing a sub-folder or even a single yaml file (the default
  230. /rest-api-spec/test prefix is optional when files are loaded from classpath)
  231. e.g. -Dtests.rest.suite=index,get,create/10_with_id
  232. * `tests.rest.blacklist`: comma separated globs that identify tests that are
  233. blacklisted and need to be skipped
  234. e.g. -Dtests.rest.blacklist=index/*/Index document,get/10_basic/*
  235. Note that the REST tests, like all the integration tests, can be run against an external
  236. cluster by specifying the `tests.cluster` property, which if present needs to contain a
  237. comma separated list of nodes to connect to (e.g. localhost:9300). A transport client will
  238. be created based on that and used for all the before|after test operations, and to extract
  239. the http addresses of the nodes so that REST requests can be sent to them.
  240. == Testing packaging
  241. The packaging tests use Vagrant virtual machines to verify that installing
  242. and running elasticsearch distributions works correctly on supported operating systems.
  243. These tests should really only be run in vagrant vms because they're destructive.
  244. . Install Virtual Box and Vagrant.
  245. +
  246. . (Optional) Install https://github.com/fgrehm/vagrant-cachier[vagrant-cachier] to squeeze
  247. a bit more performance out of the process:
  248. +
  249. --------------------------------------
  250. vagrant plugin install vagrant-cachier
  251. --------------------------------------
  252. +
  253. . Validate your installed dependencies:
  254. +
  255. -------------------------------------
  256. ./gradlew :qa:vagrant:vagrantCheckVersion
  257. -------------------------------------
  258. +
  259. . Download and smoke test the VMs with `./gradlew vagrantSmokeTest` or
  260. `./gradlew -Pvagrant.boxes=all vagrantSmokeTest`. The first time you run this it will
  261. download the base images and provision the boxes and immediately quit. Downloading all
  262. the images may take a long time. After the images are already on your machine, they won't
  263. be downloaded again unless they have been updated to a new version.
  264. +
  265. . Run the tests with `./gradlew packagingTest`. This will cause Gradle to build
  266. the tar, zip, and deb packages and all the plugins. It will then run the tests
  267. on ubuntu-1404 and centos-7. We chose those two distributions as the default
  268. because they cover deb and rpm packaging and SyvVinit and systemd.
  269. You can choose which boxes to test by setting the `-Pvagrant.boxes` project property. All of
  270. the valid options for this property are:
  271. * `sample` - The default, only chooses ubuntu-1404 and centos-7
  272. * List of box names, comma separated (e.g. `oel-7,fedora-28`) - Chooses exactly the boxes listed.
  273. * `linux-all` - All linux boxes.
  274. * `windows-all` - All Windows boxes. If there are any Windows boxes which do not
  275. have images available when this value is provided, the build will fail.
  276. * `all` - All boxes we test. If there are any boxes (e.g. Windows) which do not have images
  277. available when this value is provided, the build will fail.
  278. For a complete list of boxes on which tests can be run, run `./gradlew :qa:vagrant:listAllBoxes`.
  279. For a list of boxes that have images available from your configuration, run
  280. `./gradlew :qa:vagrant:listAvailableBoxes`
  281. Note that if you interrupt gradle in the middle of running these tasks, any boxes started
  282. will remain running and you'll have to stop them manually with `./gradlew stop` or
  283. `vagrant halt`.
  284. All the regular vagrant commands should just work so you can get a shell in a
  285. VM running trusty by running
  286. `vagrant up ubuntu-1404 --provider virtualbox && vagrant ssh ubuntu-1404`.
  287. These are the linux flavors supported, all of which we provide images for
  288. * ubuntu-1404 aka trusty
  289. * ubuntu-1604 aka xenial
  290. * ubuntu-1804 aka bionic beaver
  291. * debian-8 aka jessie
  292. * debian-9 aka stretch, the current debian stable distribution
  293. * centos-6
  294. * centos-7
  295. * fedora-27
  296. * fedora-28
  297. * oel-6 aka Oracle Enterprise Linux 6
  298. * oel-7 aka Oracle Enterprise Linux 7
  299. * sles-12
  300. * opensuse-42 aka Leap
  301. We're missing the following from the support matrix because there aren't high
  302. quality boxes available in vagrant atlas:
  303. * sles-11
  304. === Testing packaging on Windows
  305. The packaging tests also support Windows Server 2012R2 and Windows Server 2016.
  306. Unfortunately we're not able to provide boxes for them in open source use
  307. because of licensing issues. Any Virtualbox image that has WinRM and Powershell
  308. enabled for remote users should work.
  309. Testing on Windows requires the https://github.com/criteo/vagrant-winrm[vagrant-winrm] plugin.
  310. ------------------------------------
  311. vagrant plugin install vagrant-winrm
  312. ------------------------------------
  313. Specify the image IDs of the Windows boxes to gradle with the following project
  314. properties. They can be set in `~/.gradle/gradle.properties` like
  315. ------------------------------------
  316. vagrant.windows-2012r2.id=my-image-id
  317. vagrant.windows-2016.id=another-image-id
  318. ------------------------------------
  319. or passed on the command line like `-Pvagrant.windows-2012r2.id=my-image-id`
  320. `-Pvagrant.windows-2016=another-image-id`
  321. These properties are required for Windows support in all gradle tasks that
  322. handle packaging tests. Either or both may be specified. Remember that to run tests
  323. on these boxes, the project property `vagrant.boxes` still needs to be set to a
  324. value that will include them.
  325. If you're running vagrant commands outside of gradle, specify the Windows boxes
  326. with the environment variables
  327. * `VAGRANT_WINDOWS_2012R2_BOX`
  328. * `VAGRANT_WINDOWS_2016_BOX`
  329. === Testing VMs are disposable
  330. It's important to think of VMs like cattle. If they become lame you just shoot
  331. them and let vagrant reprovision them. Say you've hosed your precise VM:
  332. ----------------------------------------------------
  333. vagrant ssh ubuntu-1404 -c 'sudo rm -rf /bin'; echo oops
  334. ----------------------------------------------------
  335. All you've got to do to get another one is
  336. ----------------------------------------------
  337. vagrant destroy -f ubuntu-1404 && vagrant up ubuntu-1404 --provider virtualbox
  338. ----------------------------------------------
  339. The whole process takes a minute and a half on a modern laptop, two and a half
  340. without vagrant-cachier.
  341. Its possible that some downloads will fail and it'll be impossible to restart
  342. them. This is a bug in vagrant. See the instructions here for how to work
  343. around it:
  344. https://github.com/mitchellh/vagrant/issues/4479
  345. Some vagrant commands will work on all VMs at once:
  346. ------------------
  347. vagrant halt
  348. vagrant destroy -f
  349. ------------------
  350. `vagrant up` would normally start all the VMs but we've prevented that because
  351. that'd consume a ton of ram.
  352. === Iterating on packaging tests
  353. Running the packaging tests through gradle can take a while because it will start
  354. and stop the VM each time. You can iterate faster by keeping the VM up and running
  355. the tests directly.
  356. The packaging tests use a random seed to determine which past version to use for
  357. testing upgrades. To use a single past version fix the test seed when running
  358. the commands below (see <<Seed and repetitions.>>)
  359. First build the packaging tests and their dependencies
  360. --------------------------------------------
  361. ./gradlew :qa:vagrant:setupPackagingTest
  362. --------------------------------------------
  363. Then choose the VM you want to test on and bring it up. For example, to bring
  364. up Debian 9 use the gradle command below. Bringing the box up with vagrant directly
  365. may not mount the packaging test project in the right place. Once the VM is up, ssh
  366. into it
  367. --------------------------------------------
  368. ./gradlew :qa:vagrant:vagrantDebian9#up
  369. vagrant ssh debian-9
  370. --------------------------------------------
  371. Now inside the VM, start the packaging tests from the terminal. There are two packaging
  372. test projects. The old ones are written with https://github.com/sstephenson/bats[bats]
  373. and only run on linux. To run them do
  374. --------------------------------------------
  375. cd $PACKAGING_ARCHIVES
  376. # runs all bats tests
  377. sudo bats $BATS_TESTS/*.bats
  378. # you can also pass specific test files
  379. sudo bats $BATS_TESTS/20_tar_package.bats $BATS_TESTS/25_tar_plugins.bats
  380. --------------------------------------------
  381. The new packaging tests are written in Java and run on both linux and windows. On
  382. linux (again, inside the VM)
  383. --------------------------------------------
  384. # run the full suite
  385. sudo bash $PACKAGING_TESTS/run-tests.sh
  386. # run specific test cases
  387. sudo bash $PACKAGING_TESTS/run-tests.sh \
  388. org.elasticsearch.packaging.test.DefaultZipTests \
  389. org.elasticsearch.packaging.test.OssZipTests
  390. --------------------------------------------
  391. or on Windows, from a terminal running as Administrator
  392. --------------------------------------------
  393. # run the full suite
  394. powershell -File $Env:PACKAGING_TESTS/run-tests.ps1
  395. # run specific test cases
  396. powershell -File $Env:PACKAGING_TESTS/run-tests.ps1 `
  397. org.elasticsearch.packaging.test.DefaultZipTests `
  398. org.elasticsearch.packaging.test.OssZipTests
  399. --------------------------------------------
  400. Note that on Windows boxes when running from inside the GUI, you may have to log out and
  401. back in to the `vagrant` user (password `vagrant`) for the environment variables that
  402. locate the packaging tests and distributions to take effect, due to how vagrant provisions
  403. Windows machines.
  404. When you've made changes you want to test, keep the VM up and reload the tests and
  405. distributions inside by running (on the host)
  406. --------------------------------------------
  407. ./gradlew :qa:vagrant:clean :qa:vagrant:setupPackagingTest
  408. --------------------------------------------
  409. Note: Starting vagrant VM outside of the elasticsearch folder requires to
  410. indicates the folder that contains the Vagrantfile using the VAGRANT_CWD
  411. environment variable.
  412. == Testing backwards compatibility
  413. Backwards compatibility tests exist to test upgrading from each supported version
  414. to the current version. To run all backcompat tests use:
  415. -------------------------------------------------
  416. ./gradlew bwcTest
  417. -------------------------------------------------
  418. A specific version can be tested as well. For example, to test backcompat with
  419. version 5.3.2 run:
  420. -------------------------------------------------
  421. ./gradlew v5.3.2#bwcTest
  422. -------------------------------------------------
  423. When running `./gradlew check`, some minimal backcompat checks are run. Which version
  424. is tested depends on the branch. On master, this will test against the current
  425. stable branch. On the stable branch, it will test against the latest release
  426. branch. Finally, on a release branch, it will test against the most recent release.
  427. === BWC Testing against a specific remote/branch
  428. Sometimes a backward compatibility change spans two versions. A common case is a new functionality
  429. that needs a BWC bridge in an unreleased versioned of a release branch (for example, 5.x).
  430. To test the changes, you can instruct Gradle to build the BWC version from a another remote/branch combination instead of
  431. pulling the release branch from GitHub. You do so using the `tests.bwc.remote` and `tests.bwc.refspec.BRANCH` system properties:
  432. -------------------------------------------------
  433. ./gradlew check -Dtests.bwc.remote=${remote} -Dtests.bwc.refspec.5.x=index_req_bwc_5.x
  434. -------------------------------------------------
  435. The branch needs to be available on the remote that the BWC makes of the
  436. repository you run the tests from. Using the remote is a handy trick to make
  437. sure that a branch is available and is up to date in the case of multiple runs.
  438. Example:
  439. Say you need to make a change to `master` and have a BWC layer in `5.x`. You
  440. will need to:
  441. . Create a branch called `index_req_change` off your remote `${remote}`. This
  442. will contain your change.
  443. . Create a branch called `index_req_bwc_5.x` off `5.x`. This will contain your bwc layer.
  444. . Push both branches to your remote repository.
  445. . Run the tests with `./gradlew check -Dtests.bwc.remote=${remote} -Dtests.bwc.refspec.5.x=index_req_bwc_5.x`.
  446. == Skip fetching latest
  447. For some BWC testing scenarios, you want to use the local clone of the
  448. repository without fetching latest. For these use cases, you can set the system
  449. property `tests.bwc.git_fetch_latest` to `false` and the BWC builds will skip
  450. fetching the latest from the remote.
  451. == Test coverage analysis
  452. Generating test coverage reports for Elasticsearch is currently not possible through Gradle.
  453. However, it _is_ possible to gain insight in code coverage using IntelliJ's built-in coverage
  454. analysis tool that can measure coverage upon executing specific tests. Eclipse may also be able
  455. to do the same using the EclEmma plugin.
  456. Test coverage reporting used to be possible with JaCoCo when Elasticsearch was using Maven
  457. as its build system. Since the switch to Gradle though, this is no longer possible, seeing as
  458. the code currently used to build Elasticsearch does not allow JaCoCo to recognize its tests.
  459. For more information on this, see the discussion in https://github.com/elastic/elasticsearch/issues/28867[issue #28867].
  460. == Debugging remotely from an IDE
  461. If you want to run Elasticsearch and be able to remotely attach the process
  462. for debugging purposes from your IDE, can start Elasticsearch using `ES_JAVA_OPTS`:
  463. ---------------------------------------------------------------------------
  464. ES_JAVA_OPTS="-Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=y" ./bin/elasticsearch
  465. ---------------------------------------------------------------------------
  466. Read your IDE documentation for how to attach a debugger to a JVM process.
  467. == Building with extra plugins
  468. Additional plugins may be built alongside elasticsearch, where their
  469. dependency on elasticsearch will be substituted with the local elasticsearch
  470. build. To add your plugin, create a directory called elasticsearch-extra as
  471. a sibling of elasticsearch. Checkout your plugin underneath elasticsearch-extra
  472. and the build will automatically pick it up. You can verify the plugin is
  473. included as part of the build by checking the projects of the build.
  474. ---------------------------------------------------------------------------
  475. ./gradlew projects
  476. ---------------------------------------------------------------------------
  477. == Environment misc
  478. There is a known issue with macOS localhost resolve strategy that can cause
  479. some integration tests to fail. This is because integration tests have timings
  480. for cluster formation, discovery, etc. that can be exceeded if name resolution
  481. takes a long time.
  482. To fix this, make sure you have your computer name (as returned by `hostname`)
  483. inside `/etc/hosts`, e.g.:
  484. ....
  485. 127.0.0.1 localhost ElasticMBP.local
  486. 255.255.255.255 broadcasthost
  487. ::1 localhost ElasticMBP.local`
  488. ....