@@ -303,15 +303,16 @@ comma separated list of nodes to connect to (e.g. localhost:9300). A transport c
303303be created based on that and used for all the before|after test operations, and to extract
304304the http addresses of the nodes so that REST requests can be sent to them.
305305
306- == Testing scripts
306+ == Testing packaging
307307
308- The simplest way to test scripts and the packaged distributions is to use
309- Vagrant. You can get started by following there five easy steps:
308+ The packaging tests use Vagrant virtual machines to verify that installing
309+ and running elasticsearch distributions works correctly on supported operating systems.
310+ These tests should really only be run in vagrant vms because they're destructive.
310311
311312. Install Virtual Box and Vagrant.
312313
313- . (Optional) Install vagrant-cachier to squeeze a bit more performance out of
314- the process:
314+ . (Optional) Install https://github.com/fgrehm/ vagrant-cachier[vagrant-cachier] to squeeze
315+ a bit more performance out of the process:
315316
316317--------------------------------------
317318vagrant plugin install vagrant-cachier
@@ -325,26 +326,37 @@ vagrant plugin install vagrant-cachier
325326
326327. Download and smoke test the VMs with `./gradlew vagrantSmokeTest` or
327328`./gradlew -Pvagrant.boxes=all vagrantSmokeTest`. The first time you run this it will
328- download the base images and provision the boxes and immediately quit. If you
329- you this again it'll skip the download step.
329+ download the base images and provision the boxes and immediately quit. Downloading all
330+ the images may take a long time. After the images are already on your machine, they won't
331+ be downloaded again unless they have been updated to a new version.
330332
331333. Run the tests with `./gradlew packagingTest`. This will cause Gradle to build
332334the tar, zip, and deb packages and all the plugins. It will then run the tests
333335on ubuntu-1404 and centos-7. We chose those two distributions as the default
334336because they cover deb and rpm packaging and SyvVinit and systemd.
335337
336- You can run on all the VMs by running `./gradlew -Pvagrant.boxes=all
337- packagingTest`. You can run a particular VM with a command like `./gradlew
338- -Pvagrant.boxes=oel-7 packagingTest`. See `./gradlew tasks` for a complete list
339- of available vagrant boxes for testing. It's important to know that if you
340- interrupt any of these Gradle commands then the boxes will remain running and
341- you'll have to terminate them with `./gradlew stop`.
338+ You can choose which boxes to test by setting the `-Pvagrant.boxes` project property. For
339+ example, to test all boxes, run `./gradlew -Pvagrant.boxes=all`. For a complete list of
340+ available boxes, run `./gradlew :qa:vagrant:tasks --all`. All of the following values are
341+ supported by the `vagrant.boxes` property
342+
343+ * `sample` - The default, only chooses ubuntu-1404 and centos-7
344+ * `all` - All configured boxes, i.e. all linux boxes and any configured Windows
345+ boxes.
346+ * `linux-all` - All linux boxes.
347+ * `windows-all` - All configured Windows boxes. If there are none configured when this
348+ value is set, the build will fail.
349+ * List of box names, comma separated (e.g. `oel-7,fedora-26`) - Chooses exactly the boxes listed.
350+
351+ Note that if you interrupt gradle in the middle of running these tasks, any boxes started
352+ will remain running and you'll have to stop them manually with `./gradlew stop` or
353+ `vagrant halt`.
342354
343355All the regular vagrant commands should just work so you can get a shell in a
344356VM running trusty by running
345357`vagrant up ubuntu-1404 --provider virtualbox && vagrant ssh ubuntu-1404`.
346358
347- These are the linux flavors the Vagrantfile currently supports:
359+ These are the linux flavors supported, all of which we provide images for
348360
349361* ubuntu-1404 aka trusty
350362* ubuntu-1604 aka xenial
@@ -364,9 +376,34 @@ quality boxes available in vagrant atlas:
364376
365377* sles-11
366378
367- We're missing the following because our tests are very linux/bash centric:
379+ === Testing packaging on Windows
380+
381+ The packaging tests also support Windows Server 2012R2 and Windows Server 2016.
382+ Unfortunately we're not able to provide boxes for them in open source use
383+ because of licensing issues. Any Virtualbox image that has WinRM and Powershell
384+ enabled for remote users should work.
385+
386+ Testing on Windows requires the https://github.com/criteo/vagrant-winrm[vagrant-winrm] plugin.
387+
388+ ------------------------------------
389+ vagrant plugin install vagrant-winrm
390+ ------------------------------------
391+
392+ Specify the image IDs of the Windows boxes to gradle with the following environment
393+ variables. These are used by both the gradle build and Vagrant, so if they're exported
394+ the Windows boxes will be recognized when you run gradle commands, or Vagrant commands
395+ directly.
368396
369- * Windows Server 2012
397+ * `VAGRANT_WINDOWS_2012R2_BOX`
398+ * `VAGRANT_WINDOWS_2016_BOX`
399+
400+ These variables are required for Windows support in all gradle tasks that
401+ handle packaging tests. Either or both may be specified. Remember that to run tests
402+ on these boxes, they still need to be included in the value of `-Pvagrant.boxes`.
403+ When these properties are present, passing `-Pvagrant.boxes=all` will include the
404+ Windows boxes.
405+
406+ === Testing VMs are disposable
370407
371408It's important to think of VMs like cattle. If they become lame you just shoot
372409them and let vagrant reprovision them. Say you've hosed your precise VM:
@@ -399,54 +436,62 @@ vagrant destroy -f
399436`vagrant up` would normally start all the VMs but we've prevented that because
400437that'd consume a ton of ram.
401438
402- == Testing scripts more directly
439+ === Iterating on packaging tests
403440
404- In general its best to stick to testing in vagrant because the bats scripts are
405- destructive. When working with a single package it's generally faster to run its
406- tests in a tighter loop than Gradle provides. In one window:
441+ Running the packaging tests through gradle can take a while because it will start
442+ and stop the VM each time. You can iterate faster by keeping the VM up and running
443+ the tests directly.
407444
408- --------------------------------
409- ./gradlew :distribution:packages:rpm:assemble
410- --------------------------------
445+ The packaging tests use a random seed to determine which past version to use for
446+ testing upgrades. To use a single past version fix the test seed when running
447+ the commands below (see <<Seed and repetitions.>>)
411448
412- and in another window:
449+ First build the packaging tests and their dependencies
413450
414- ----------------------------------------------------
415- vagrant up centos-7 --provider virtualbox && vagrant ssh centos-7
416- cd $PACKAGING_ARCHIVES
417- sudo -E bats $BATS_TESTS/*rpm*.bats
418- ----------------------------------------------------
451+ --------------------------------------------
452+ ./gradlew :qa:vagrant:setupPackagingTest
453+ --------------------------------------------
419454
420- If you wanted to retest all the release artifacts on a single VM you could:
455+ Then choose the VM you want to test on and bring it up. For example, to bring
456+ up Debian 9 use the gradle command below. Bringing the box up with vagrant directly
457+ may not mount the packaging test project in the right place. Once the VM is up, ssh
458+ into it
421459
422- -------------------------------------------------
423- ./gradlew setupPackagingTest
424- cd qa/vagrant; vagrant up ubuntu-1404 --provider virtualbox && vagrant ssh ubuntu-1404
460+ --------------------------------------------
461+ ./gradlew :qa:vagrant:vagrantDebian9#up
462+ vagrant ssh debian-9
463+ --------------------------------------------
464+
465+ Now inside the VM, to run the https://github.com/sstephenson/bats[bats] packaging tests
466+
467+ --------------------------------------------
425468cd $PACKAGING_ARCHIVES
426- sudo -E bats $BATS_TESTS/*.bats
427- -------------------------------------------------
428469
429- You can also use Gradle to prepare the test environment and then starts a single VM:
470+ # runs all bats tests
471+ sudo bats $BATS_TESTS/*.bats
430472
431- -------------------------------------------------
432- ./gradlew vagrantFedora27#up
433- -------------------------------------------------
473+ # you can also pass specific test files
474+ sudo bats $BATS_TESTS/20_tar_package.bats $BATS_TESTS/25_tar_plugins.bats
475+ --------------------------------------------
434476
435- Or any of vagrantCentos6#up, vagrantCentos7#up, vagrantDebian8#up,
436- vagrantDebian9#up, vagrantFedora26#up, vagrantFedora27#up, vagrantOel6#up, vagrantOel7#up,
437- vagrantOpensuse42#up,vagrantSles12#up, vagrantUbuntu1404#up, vagrantUbuntu1604#up.
477+ To run the Java packaging tests, again inside the VM
438478
439- Once up, you can then connect to the VM using SSH from the elasticsearch directory:
479+ --------------------------------------------
480+ bash $PACKAGING_TESTS/run-tests.sh
481+ --------------------------------------------
440482
441- -------------------------------------------------
442- vagrant ssh fedora-27
443- -------------------------------------------------
483+ or on Windows
444484
445- Or from another directory:
485+ --------------------------------------------
486+ powershell -File $Env:PACKAGING_TESTS/run-tests.ps1
487+ --------------------------------------------
446488
447- -------------------------------------------------
448- VAGRANT_CWD=/path/to/elasticsearch vagrant ssh fedora-27
449- -------------------------------------------------
489+ When you've made changes you want to test, keep the VM up and reload the tests and
490+ distributions inside by running (on the host)
491+
492+ --------------------------------------------
493+ ./gradlew :qa:vagrant:clean :qa:vagrant:setupPackagingTest
494+ --------------------------------------------
450495
451496Note: Starting vagrant VM outside of the elasticsearch folder requires to
452497indicates the folder that contains the Vagrantfile using the VAGRANT_CWD
0 commit comments