Skip to content

Commit ac1ed6e

Browse files
Update TESTING.asciidoc for new :qa:os test style (#48023)
* Update testing document for new packaging tests The TESTING.asciidoc document had gotten out of date due to some new and wonderful changes in our vagrant testing code. I've removed all of the instructions that no longer work, and added working examples and descriptions in their place.
1 parent 73f5fef commit ac1ed6e

File tree

1 file changed

+49
-115
lines changed

1 file changed

+49
-115
lines changed

TESTING.asciidoc

Lines changed: 49 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Default value provided below in [brackets].
159159

160160
=== Load balancing and caches.
161161

162-
By default the tests run on multiple processes using all the available cores on all
162+
By default the tests run on multiple processes using all the available cores on all
163163
available CPUs. Not including hyper-threading.
164164
If you want to explicitly specify the number of JVMs you can do so on the command
165165
line:
@@ -313,9 +313,17 @@ the http addresses of the nodes so that REST requests can be sent to them.
313313

314314
== Testing packaging
315315

316-
The packaging tests use Vagrant virtual machines to verify that installing
317-
and running elasticsearch distributions works correctly on supported operating systems.
318-
These tests should really only be run in vagrant vms because they're destructive.
316+
The packaging tests use Vagrant virtual machines or cloud instances to verify
317+
that installing and running Elasticsearch distributions works correctly on
318+
supported operating systems. These tests should really only be run on ephemeral
319+
systems because they're destructive; that is, these tests install and remove
320+
packages and freely modify system settings, so you will probably regret it if
321+
you execute them on your development machine.
322+
323+
When you run a packaging test, Gradle will set up the target VM and mount your
324+
repository directory in the VM. Once this is done, a Gradle task will issue a
325+
Vagrant command to run a *nested* Gradle task on the VM. This nested Gradle
326+
runs the actual "destructive" test classes.
319327

320328
. Install Virtual Box and Vagrant.
321329
+
@@ -326,40 +334,29 @@ a bit more performance out of the process:
326334
vagrant plugin install vagrant-cachier
327335
--------------------------------------
328336
+
329-
. Validate your installed dependencies:
337+
. You can run all of the OS packaging tests with `./gradlew packagingTest`.
338+
This task includes our legacy `bats` tests. To run only the OS tests that are
339+
written in Java, run `.gradlew distroTest`, will cause Gradle to build the tar,
340+
zip, and deb packages and all the plugins. It will then run the tests on every
341+
available system. This will take a very long time.
330342
+
331-
-------------------------------------
332-
./gradlew :qa:vagrant:vagrantCheckVersion
333-
-------------------------------------
343+
Fortunately, the various systems under test have their own Gradle tasks under
344+
`qa/os`. To find out what packaging combinations can be tested on a system, run
345+
the `tasks` task. For example:
334346
+
335-
. Download and smoke test the VMs with `./gradlew vagrantSmokeTest` or
336-
`./gradlew -Pvagrant.boxes=all vagrantSmokeTest`. The first time you run this it will
337-
download the base images and provision the boxes and immediately quit. Downloading all
338-
the images may take a long time. After the images are already on your machine, they won't
339-
be downloaded again unless they have been updated to a new version.
347+
----------------------------------
348+
./gradlew :qa:os:ubuntu-1804:tasks
349+
----------------------------------
340350
+
341-
. Run the tests with `./gradlew packagingTest`. This will cause Gradle to build
342-
the tar, zip, and deb packages and all the plugins. It will then run the tests
343-
on ubuntu-1604 and centos-7. We chose those two distributions as the default
344-
because they cover deb and rpm packaging and SyvVinit and systemd.
345-
346-
You can choose which boxes to test by setting the `-Pvagrant.boxes` project property. All of
347-
the valid options for this property are:
348-
349-
* `sample` - The default, only chooses ubuntu-1604 and centos-7
350-
* List of box names, comma separated (e.g. `oel-7,fedora-28`) - Chooses exactly the boxes listed.
351-
* `linux-all` - All linux boxes.
352-
* `windows-all` - All Windows boxes. If there are any Windows boxes which do not
353-
have images available when this value is provided, the build will fail.
354-
* `all` - All boxes we test. If there are any boxes (e.g. Windows) which do not have images
355-
available when this value is provided, the build will fail.
356-
357-
For a complete list of boxes on which tests can be run, run `./gradlew :qa:vagrant:listAllBoxes`.
358-
For a list of boxes that have images available from your configuration, run
359-
`./gradlew :qa:vagrant:listAvailableBoxes`
360-
361-
Note that if you interrupt gradle in the middle of running these tasks, any boxes started
362-
will remain running and you'll have to stop them manually with `./gradlew stop` or
351+
If you want a quick test of the tarball and RPM packagings for Centos 7, you
352+
would run:
353+
+
354+
-------------------------------------------------------------------------------------------------
355+
./gradlew :qa:os:centos-7:distroTest.default-rpm :qa:os:centos-7:distroTest.default-linux-archive
356+
-------------------------------------------------------------------------------------------------
357+
358+
Note that if you interrupt Gradle in the middle of running these tasks, any boxes started
359+
will remain running and you'll have to stop them manually with `./gradlew --stop` or
363360
`vagrant halt`.
364361

365362
All the regular vagrant commands should just work so you can get a shell in a
@@ -412,9 +409,7 @@ or passed on the command line like `-Pvagrant.windows-2012r2.id=my-image-id`
412409
`-Pvagrant.windows-2016=another-image-id`
413410

414411
These properties are required for Windows support in all gradle tasks that
415-
handle packaging tests. Either or both may be specified. Remember that to run tests
416-
on these boxes, the project property `vagrant.boxes` still needs to be set to a
417-
value that will include them.
412+
handle packaging tests. Either or both may be specified.
418413

419414
If you're running vagrant commands outside of gradle, specify the Windows boxes
420415
with the environment variables
@@ -457,84 +452,23 @@ that'd consume a ton of ram.
457452

458453
=== Iterating on packaging tests
459454

460-
Running the packaging tests through gradle can take a while because it will start
461-
and stop the VM each time. You can iterate faster by keeping the VM up and running
462-
the tests directly.
463-
464-
The packaging tests use a random seed to determine which past version to use for
465-
testing upgrades. To use a single past version fix the test seed when running
466-
the commands below (see <<Seed and repetitions.>>)
467-
468-
First build the packaging tests and their dependencies
469-
470-
--------------------------------------------
471-
./gradlew :qa:vagrant:setupPackagingTest
472-
--------------------------------------------
473-
474-
Then choose the VM you want to test on and bring it up. For example, to bring
475-
up Debian 9 use the gradle command below. Bringing the box up with vagrant directly
476-
may not mount the packaging test project in the right place. Once the VM is up, ssh
477-
into it
478-
479-
--------------------------------------------
480-
./gradlew :qa:vagrant:vagrantDebian9#up
481-
vagrant ssh debian-9
482-
--------------------------------------------
483-
484-
Now inside the VM, start the packaging tests from the terminal. There are two packaging
485-
test projects. The old ones are written with https://github.com/sstephenson/bats[bats]
486-
and only run on linux. To run them do
487-
488-
--------------------------------------------
489-
cd $PACKAGING_ARCHIVES
490-
491-
# runs all bats tests
492-
sudo bats $BATS_TESTS/*.bats
493-
494-
# you can also pass specific test files
495-
sudo bats $BATS_TESTS/20_tar_package.bats $BATS_TESTS/25_tar_plugins.bats
496-
--------------------------------------------
497-
498-
The new packaging tests are written in Java and run on both linux and windows. On
499-
linux (again, inside the VM)
500-
501-
--------------------------------------------
502-
# run the full suite
503-
sudo bash $PACKAGING_TESTS/run-tests.sh
504-
505-
# run specific test cases
506-
sudo bash $PACKAGING_TESTS/run-tests.sh \
507-
org.elasticsearch.packaging.test.DefaultWindowsZipTests \
508-
org.elasticsearch.packaging.test.OssWindowsZipTests
509-
--------------------------------------------
510-
511-
or on Windows, from a terminal running as Administrator
512-
513-
--------------------------------------------
514-
# run the full suite
515-
powershell -File $Env:PACKAGING_TESTS/run-tests.ps1
516-
517-
# run specific test cases
518-
powershell -File $Env:PACKAGING_TESTS/run-tests.ps1 `
519-
org.elasticsearch.packaging.test.DefaultWindowsZipTests `
520-
org.elasticsearch.packaging.test.OssWindowsZipTests
521-
--------------------------------------------
522-
523-
Note that on Windows boxes when running from inside the GUI, you may have to log out and
524-
back in to the `vagrant` user (password `vagrant`) for the environment variables that
525-
locate the packaging tests and distributions to take effect, due to how vagrant provisions
526-
Windows machines.
455+
Because our packaging tests are capable of testing many combinations of OS
456+
(e.g., Windows, Linux, etc.), package type (e.g., zip file, RPM, etc.),
457+
Elasticsearch distribution type (e.g., default or OSS), and so forth, it's
458+
faster to develop against smaller subsets of the tests. For example, to run
459+
tests for the default archive distribution on Fedora 28:
527460

528-
When you've made changes you want to test, keep the VM up and reload the tests and
529-
distributions inside by running (on the host)
461+
-----------------------------------------------------------
462+
./gradlew :qa:os:fedora-28:distroTest.default-linux-archive
463+
-----------------------------------------------------------
530464

531-
--------------------------------------------
532-
./gradlew :qa:vagrant:clean :qa:vagrant:setupPackagingTest
533-
--------------------------------------------
465+
These test tasks can use the `--tests`, `--info`, and `--debug` parameters just like
466+
non-OS tests can. For example:
534467

535-
Note: Starting vagrant VM outside of the elasticsearch folder requires to
536-
indicates the folder that contains the Vagrantfile using the VAGRANT_CWD
537-
environment variable.
468+
-----------------------------------------------------------
469+
./gradlew :qa:os:fedora-28:distroTest.default-linux-archive \
470+
--tests "com.elasticsearch.packaging.test.ArchiveTests"
471+
-----------------------------------------------------------
538472

539473
== Testing backwards compatibility
540474

@@ -555,7 +489,7 @@ version 5.3.2 run:
555489
Tests are ran for versions that are not yet released but with which the current version will be compatible with.
556490
These are automatically checked out and built from source.
557491
See link:./buildSrc/src/main/java/org/elasticsearch/gradle/VersionCollection.java[VersionCollection]
558-
and link:./distribution/bwc/build.gradle[distribution/bwc/build.gradle]
492+
and link:./distribution/bwc/build.gradle[distribution/bwc/build.gradle]
559493
for more information.
560494

561495
When running `./gradlew check`, minimal bwc checks are also run against compatible versions that are not yet released.
@@ -676,7 +610,7 @@ care.
676610
== Test coverage analysis
677611

678612
Generating test coverage reports for Elasticsearch is currently not possible through Gradle.
679-
However, it _is_ possible to gain insight in code coverage using IntelliJ's built-in coverage
613+
However, it _is_ possible to gain insight in code coverage using IntelliJ's built-in coverage
680614
analysis tool that can measure coverage upon executing specific tests. Eclipse may also be able
681615
to do the same using the EclEmma plugin.
682616

0 commit comments

Comments
 (0)