Skip to content

Commit 15fd6fc

Browse files
committed
Update testing docs to reflect Gradle wrapper
This commit updates the testing docs to reflect the usage of the Gradle wrapper. Relates #28107
1 parent 24ac8a9 commit 15fd6fc

File tree

3 files changed

+59
-57
lines changed

3 files changed

+59
-57
lines changed

GRADLE.CHEATSHEET

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
As a quick helper, below are the equivalent commands from maven to gradle (TESTING.md has also been updated). You can also run "gradle tasks" to see all tasks that are available to run.
1+
As a quick helper, below are the equivalent commands from Maven to Gradle
2+
(TESTING.md has also been updated). You can also run `./gradlew tasks` to see
3+
all tasks that are available to run.
24
clean -> clean
35
test -> test
46
verify -> check

README.textile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,9 @@ We have just covered a very small portion of what Elasticsearch is all about. Fo
200200

201201
h3. Building from Source
202202

203-
Elasticsearch uses "Gradle":https://gradle.org for its build system. You'll need to have at least version 3.3 of Gradle installed.
203+
Elasticsearch uses "Gradle":https://gradle.org for its build system.
204204

205-
In order to create a distribution, simply run the @gradle assemble@ command in the cloned directory.
205+
In order to create a distribution, simply run the @./gradlew assemble@ command in the cloned directory.
206206

207207
The distribution for each project will be created under the @build/distributions@ directory in that project.
208208

TESTING.asciidoc

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ To create a distribution without running the tests, simply run the
1313
following:
1414

1515
-----------------------------
16-
gradle assemble
16+
./gradlew assemble
1717
-----------------------------
1818

1919
== Other test options
@@ -38,7 +38,7 @@ In order to run Elasticsearch from source without building a package, you can
3838
run it using Gradle:
3939

4040
-------------------------------------
41-
gradle run
41+
./gradlew run
4242
-------------------------------------
4343

4444
or to attach a remote debugger, run it as:
@@ -55,20 +55,20 @@ gradle run --debug-jvm
5555
Run a single test case (variants)
5656

5757
----------------------------------------------------------
58-
gradle test -Dtests.class=org.elasticsearch.package.ClassName
59-
gradle test "-Dtests.class=*.ClassName"
58+
./gradlew test -Dtests.class=org.elasticsearch.package.ClassName
59+
./gradlew test "-Dtests.class=*.ClassName"
6060
----------------------------------------------------------
6161

6262
Run all tests in a package and sub-packages
6363

6464
----------------------------------------------------
65-
gradle test "-Dtests.class=org.elasticsearch.package.*"
65+
./gradlew test "-Dtests.class=org.elasticsearch.package.*"
6666
----------------------------------------------------
6767

6868
Run any test methods that contain 'esi' (like: ...r*esi*ze...).
6969

7070
-------------------------------
71-
gradle test "-Dtests.method=*esi*"
71+
./gradlew test "-Dtests.method=*esi*"
7272
-------------------------------
7373

7474
You can also filter tests by certain annotations ie:
@@ -81,23 +81,23 @@ You can also filter tests by certain annotations ie:
8181
Those annotation names can be combined into a filter expression like:
8282

8383
------------------------------------------------
84-
gradle test -Dtests.filter="@nightly and not @backwards"
84+
./gradlew test -Dtests.filter="@nightly and not @backwards"
8585
------------------------------------------------
8686

8787
to run all nightly test but not the ones that are backwards tests. `tests.filter` supports
8888
the boolean operators `and, or, not` and grouping ie:
8989

9090

9191
---------------------------------------------------------------
92-
gradle test -Dtests.filter="@nightly and not(@badapple or @backwards)"
92+
./gradlew test -Dtests.filter="@nightly and not(@badapple or @backwards)"
9393
---------------------------------------------------------------
9494

9595
=== Seed and repetitions.
9696

9797
Run with a given seed (seed is a hex-encoded long).
9898

9999
------------------------------
100-
gradle test -Dtests.seed=DEADBEEF
100+
./gradlew test -Dtests.seed=DEADBEEF
101101
------------------------------
102102

103103
=== Repeats _all_ tests of ClassName N times.
@@ -106,7 +106,7 @@ Every test repetition will have a different method seed
106106
(derived from a single random master seed).
107107

108108
--------------------------------------------------
109-
gradle test -Dtests.iters=N -Dtests.class=*.ClassName
109+
./gradlew test -Dtests.iters=N -Dtests.class=*.ClassName
110110
--------------------------------------------------
111111

112112
=== Repeats _all_ tests of ClassName N times.
@@ -115,7 +115,7 @@ Every test repetition will have exactly the same master (0xdead) and
115115
method-level (0xbeef) seed.
116116

117117
------------------------------------------------------------------------
118-
gradle test -Dtests.iters=N -Dtests.class=*.ClassName -Dtests.seed=DEAD:BEEF
118+
./gradlew test -Dtests.iters=N -Dtests.class=*.ClassName -Dtests.seed=DEAD:BEEF
119119
------------------------------------------------------------------------
120120

121121
=== Repeats a given test N times
@@ -125,14 +125,14 @@ ie: testFoo[0], testFoo[1], etc... so using testmethod or tests.method
125125
ending in a glob is necessary to ensure iterations are run).
126126

127127
-------------------------------------------------------------------------
128-
gradle test -Dtests.iters=N -Dtests.class=*.ClassName -Dtests.method=mytest*
128+
./gradlew test -Dtests.iters=N -Dtests.class=*.ClassName -Dtests.method=mytest*
129129
-------------------------------------------------------------------------
130130

131131
Repeats N times but skips any tests after the first failure or M initial failures.
132132

133133
-------------------------------------------------------------
134-
gradle test -Dtests.iters=N -Dtests.failfast=true -Dtestcase=...
135-
gradle test -Dtests.iters=N -Dtests.maxfailures=M -Dtestcase=...
134+
./gradlew test -Dtests.iters=N -Dtests.failfast=true -Dtestcase=...
135+
./gradlew test -Dtests.iters=N -Dtests.maxfailures=M -Dtestcase=...
136136
-------------------------------------------------------------
137137

138138
=== Test groups.
@@ -142,9 +142,9 @@ Test groups can be enabled or disabled (true/false).
142142
Default value provided below in [brackets].
143143

144144
------------------------------------------------------------------
145-
gradle test -Dtests.nightly=[false] - nightly test group (@Nightly)
146-
gradle test -Dtests.weekly=[false] - weekly tests (@Weekly)
147-
gradle test -Dtests.awaitsfix=[false] - known issue (@AwaitsFix)
145+
./gradlew test -Dtests.nightly=[false] - nightly test group (@Nightly)
146+
./gradlew test -Dtests.weekly=[false] - weekly tests (@Weekly)
147+
./gradlew test -Dtests.awaitsfix=[false] - known issue (@AwaitsFix)
148148
------------------------------------------------------------------
149149

150150
=== Load balancing and caches.
@@ -154,7 +154,7 @@ want to explicitly specify the number of JVMs you can do so on the command
154154
line:
155155

156156
----------------------------
157-
gradle test -Dtests.jvms=8
157+
./gradlew test -Dtests.jvms=8
158158
----------------------------
159159

160160
Or in `~/.gradle/gradle.properties`:
@@ -173,7 +173,7 @@ It is possible to provide a version that allows to adapt the tests behaviour
173173
to older features or bugs that have been changed or fixed in the meantime.
174174

175175
-----------------------------------------
176-
gradle test -Dtests.compatibility=1.0.0
176+
./gradlew test -Dtests.compatibility=1.0.0
177177
-----------------------------------------
178178

179179

@@ -182,50 +182,50 @@ gradle test -Dtests.compatibility=1.0.0
182182
Run all tests without stopping on errors (inspect log files).
183183

184184
-----------------------------------------
185-
gradle test -Dtests.haltonfailure=false
185+
./gradlew test -Dtests.haltonfailure=false
186186
-----------------------------------------
187187

188188
Run more verbose output (slave JVM parameters, etc.).
189189

190190
----------------------
191-
gradle test -verbose
191+
./gradlew test -verbose
192192
----------------------
193193

194194
Change the default suite timeout to 5 seconds for all
195195
tests (note the exclamation mark).
196196

197197
---------------------------------------
198-
gradle test -Dtests.timeoutSuite=5000! ...
198+
./gradlew test -Dtests.timeoutSuite=5000! ...
199199
---------------------------------------
200200

201-
Change the logging level of ES (not gradle)
201+
Change the logging level of ES (not Gradle)
202202

203203
--------------------------------
204-
gradle test -Dtests.es.logger.level=DEBUG
204+
./gradlew test -Dtests.es.logger.level=DEBUG
205205
--------------------------------
206206

207207
Print all the logging output from the test runs to the commandline
208208
even if tests are passing.
209209

210210
------------------------------
211-
gradle test -Dtests.output=always
211+
./gradlew test -Dtests.output=always
212212
------------------------------
213213

214214
Configure the heap size.
215215

216216
------------------------------
217-
gradle test -Dtests.heap.size=512m
217+
./gradlew test -Dtests.heap.size=512m
218218
------------------------------
219219

220220
Pass arbitrary jvm arguments.
221221

222222
------------------------------
223223
# specify heap dump path
224-
gradle test -Dtests.jvm.argline="-XX:HeapDumpPath=/path/to/heapdumps"
224+
./gradlew test -Dtests.jvm.argline="-XX:HeapDumpPath=/path/to/heapdumps"
225225
# enable gc logging
226-
gradle test -Dtests.jvm.argline="-verbose:gc"
226+
./gradlew test -Dtests.jvm.argline="-verbose:gc"
227227
# enable security debugging
228-
gradle test -Dtests.jvm.argline="-Djava.security.debug=access,failure"
228+
./gradlew test -Dtests.jvm.argline="-Djava.security.debug=access,failure"
229229
------------------------------
230230

231231
== Backwards Compatibility Tests
@@ -236,15 +236,15 @@ To run backwards compatibilty tests untar or unzip a release and run the tests
236236
with the following command:
237237

238238
---------------------------------------------------------------------------
239-
gradle test -Dtests.filter="@backwards" -Dtests.bwc.version=x.y.z -Dtests.bwc.path=/path/to/elasticsearch -Dtests.security.manager=false
239+
./gradlew test -Dtests.filter="@backwards" -Dtests.bwc.version=x.y.z -Dtests.bwc.path=/path/to/elasticsearch -Dtests.security.manager=false
240240
---------------------------------------------------------------------------
241241

242242
Note that backwards tests must be run with security manager disabled.
243243
If the elasticsearch release is placed under `./backwards/elasticsearch-x.y.z` the path
244244
can be omitted:
245245

246246
---------------------------------------------------------------------------
247-
gradle test -Dtests.filter="@backwards" -Dtests.bwc.version=x.y.z -Dtests.security.manager=false
247+
./gradlew test -Dtests.filter="@backwards" -Dtests.bwc.version=x.y.z -Dtests.security.manager=false
248248
---------------------------------------------------------------------------
249249

250250
To setup the bwc test environment execute the following steps (provided you are
@@ -261,20 +261,20 @@ $ tar -xzf elasticsearch-1.2.1.tar.gz
261261
To run all verification tasks, including static checks, unit tests, and integration tests:
262262

263263
---------------------------------------------------------------------------
264-
gradle check
264+
./gradlew check
265265
---------------------------------------------------------------------------
266266

267267
Note that this will also run the unit tests and precommit tasks first. If you want to just
268268
run the integration tests (because you are debugging them):
269269

270270
---------------------------------------------------------------------------
271-
gradle integTest
271+
./gradlew integTest
272272
---------------------------------------------------------------------------
273273

274274
If you want to just run the precommit checks:
275275

276276
---------------------------------------------------------------------------
277-
gradle precommit
277+
./gradlew precommit
278278
---------------------------------------------------------------------------
279279

280280
== Testing the REST layer
@@ -286,18 +286,18 @@ The REST layer is tested through specific tests that are shared between all
286286
the elasticsearch official clients and consist of YAML files that describe the
287287
operations to be executed and the obtained results that need to be tested.
288288

289-
The REST tests are run automatically when executing the "gradle check" command. To run only the
289+
The REST tests are run automatically when executing the "./gradlew check" command. To run only the
290290
REST tests use the following command:
291291

292292
---------------------------------------------------------------------------
293-
gradle :distribution:integ-test-zip:integTest \
293+
./gradlew :distribution:integ-test-zip:integTest \
294294
-Dtests.class="org.elasticsearch.test.rest.*Yaml*IT"
295295
---------------------------------------------------------------------------
296296

297297
A specific test case can be run with
298298

299299
---------------------------------------------------------------------------
300-
gradle :distribution:integ-test-zip:integTest \
300+
./gradlew :distribution:integ-test-zip:integTest \
301301
-Dtests.class="org.elasticsearch.test.rest.*Yaml*IT" \
302302
-Dtests.method="test {p0=cat.shards/10_basic/Help}"
303303
---------------------------------------------------------------------------
@@ -341,25 +341,25 @@ vagrant plugin install vagrant-cachier
341341
. Validate your installed dependencies:
342342

343343
-------------------------------------
344-
gradle :qa:vagrant:vagrantCheckVersion
344+
./gradlew :qa:vagrant:vagrantCheckVersion
345345
-------------------------------------
346346

347-
. Download and smoke test the VMs with `gradle vagrantSmokeTest` or
348-
`gradle -Pvagrant.boxes=all vagrantSmokeTest`. The first time you run this it will
347+
. Download and smoke test the VMs with `./gradlew vagrantSmokeTest` or
348+
`./gradlew -Pvagrant.boxes=all vagrantSmokeTest`. The first time you run this it will
349349
download the base images and provision the boxes and immediately quit. If you
350350
you this again it'll skip the download step.
351351

352-
. Run the tests with `gradle packagingTest`. This will cause gradle to build
352+
. Run the tests with `./gradlew packagingTest`. This will cause Gradle to build
353353
the tar, zip, and deb packages and all the plugins. It will then run the tests
354354
on ubuntu-1404 and centos-7. We chose those two distributions as the default
355355
because they cover deb and rpm packaging and SyvVinit and systemd.
356356

357-
You can run on all the VMs by running `gradle -Pvagrant.boxes=all packagingTest`.
358-
You can run a particular VM with a command like
359-
`gradle -Pvagrant.boxes=oel-7 packagingTest`. See `gradle tasks` for a complete
360-
list of available vagrant boxes for testing. It's important to know that if you
361-
ctrl-c any of these `gradle` commands then the boxes will remain running and
362-
you'll have to terminate them with 'gradle stop'.
357+
You can run on all the VMs by running `./gradlew -Pvagrant.boxes=all
358+
packagingTest`. You can run a particular VM with a command like `./gradlew
359+
-Pvagrant.boxes=oel-7 packagingTest`. See `./gradlew tasks` for a complete list
360+
of available vagrant boxes for testing. It's important to know that if you
361+
interrupt any of these Gradle commands then the boxes will remain running and
362+
you'll have to terminate them with `./gradlew stop`.
363363

364364
All the regular vagrant commands should just work so you can get a shell in a
365365
VM running trusty by running
@@ -424,10 +424,10 @@ that'd consume a ton of ram.
424424

425425
In general its best to stick to testing in vagrant because the bats scripts are
426426
destructive. When working with a single package it's generally faster to run its
427-
tests in a tighter loop than gradle provides. In one window:
427+
tests in a tighter loop than Gradle provides. In one window:
428428

429429
--------------------------------
430-
gradle :distribution:rpm:assemble
430+
./gradlew :distribution:rpm:assemble
431431
--------------------------------
432432

433433
and in another window:
@@ -441,7 +441,7 @@ sudo -E bats $BATS_TESTS/*rpm*.bats
441441
If you wanted to retest all the release artifacts on a single VM you could:
442442

443443
-------------------------------------------------
444-
gradle setupBats
444+
./gradlew setupBats
445445
cd qa/vagrant; vagrant up ubuntu-1404 --provider virtualbox && vagrant ssh ubuntu-1404
446446
cd $BATS_ARCHIVES
447447
sudo -E bats $BATS_TESTS/*.bats
@@ -450,7 +450,7 @@ sudo -E bats $BATS_TESTS/*.bats
450450
You can also use Gradle to prepare the test environment and then starts a single VM:
451451

452452
-------------------------------------------------
453-
gradle vagrantFedora27#up
453+
./gradlew vagrantFedora27#up
454454
-------------------------------------------------
455455

456456
Or any of vagrantCentos6#up, vagrantCentos7#up, vagrantDebian8#up,
@@ -499,11 +499,11 @@ mvn -Dtests.coverage verify jacoco:report
499499

500500
== Debugging from an IDE
501501

502-
If you want to run elasticsearch from your IDE, the `gradle run` task
502+
If you want to run elasticsearch from your IDE, the `./gradlew run` task
503503
supports a remote debugging option:
504504

505505
---------------------------------------------------------------------------
506-
gradle run --debug-jvm
506+
./gradlew run --debug-jvm
507507
---------------------------------------------------------------------------
508508

509509
== Building with extra plugins
@@ -515,5 +515,5 @@ and the build will automatically pick it up. You can verify the plugin is
515515
included as part of the build by checking the projects of the build.
516516

517517
---------------------------------------------------------------------------
518-
gradle projects
518+
./gradlew projects
519519
---------------------------------------------------------------------------

0 commit comments

Comments
 (0)