@@ -302,15 +302,22 @@ comma separated list of nodes to connect to (e.g. localhost:9300). A transport c
302
302
be created based on that and used for all the before|after test operations, and to extract
303
303
the http addresses of the nodes so that REST requests can be sent to them.
304
304
305
- == Testing scripts
305
+ == Testing distributions and packaging
306
306
307
- The simplest way to test scripts and the packaged distributions is to use
308
- Vagrant. You can get started by following there five easy steps:
307
+ The packaging tests use Vagrant virtual machines to verify that installing
308
+ and running elasticsearch distributions works correctly on supported operating systems.
309
+ These tests should really only be run in vagrant vms because they're destructive.
310
+
311
+ The existing packaging tests are written with https://github.com/sstephenson/bats[Bats]
312
+ and run on Linux boxes. These tests are being ported to a Groovy project that will
313
+ run on all boxes.
314
+
315
+ To set up your environment and run the packaging tests, follow these steps:
309
316
310
317
. Install Virtual Box and Vagrant.
311
318
312
- . (Optional) Install vagrant-cachier to squeeze a bit more performance out of
313
- the process:
319
+ . (Optional) Install https://github.com/fgrehm/ vagrant-cachier[vagrant-cachier] to squeeze
320
+ a bit more performance out of the process:
314
321
315
322
--------------------------------------
316
323
vagrant plugin install vagrant-cachier
@@ -322,10 +329,9 @@ vagrant plugin install vagrant-cachier
322
329
gradle :qa:vagrant:vagrantCheckVersion
323
330
-------------------------------------
324
331
325
- . Download and smoke test the VMs with `gradle vagrantSmokeTest` or
326
- `gradle -Pvagrant.boxes=all vagrantSmokeTest`. The first time you run this it will
327
- download the base images and provision the boxes and immediately quit. If you
328
- you this again it'll skip the download step.
332
+ . Download and smoke test the VMs with `gradle vagrantSmokeTest`. The first time
333
+ you run this it will download the base images and provision the boxes and immediately
334
+ quit. If run again it will use the boxes already downloaded.
329
335
330
336
. Run the tests with `gradle packagingTest`. This will cause gradle to build
331
337
the tar, zip, and deb packages and all the plugins. It will then run the tests
@@ -343,7 +349,7 @@ All the regular vagrant commands should just work so you can get a shell in a
343
349
VM running trusty by running
344
350
`vagrant up ubuntu-1404 --provider virtualbox && vagrant ssh ubuntu-1404`.
345
351
346
- These are the linux flavors the Vagrantfile currently supports:
352
+ These are the linux flavors supported, all of which have boxes provided
347
353
348
354
* ubuntu-1404 aka trusty
349
355
* ubuntu-1604 aka xenial
@@ -363,12 +369,42 @@ quality boxes available in vagrant atlas:
363
369
364
370
* sles-11
365
371
366
- We're missing the following because our tests are very linux/bash centric:
372
+ === Testing packaging on Windows
373
+
374
+ The packaging tests also support Windows Server 2012R2 and Windows Server 2016.
375
+ Unfortunately we're not able to provide boxes for them in open source use
376
+ because of licensing issues. Any Virtualbox image that has WinRM enabled
377
+ for remote management and supports Powershell for remote users should work.
378
+
379
+ Testing on Windows requires the https://github.com/criteo/vagrant-winrm[vagrant-winrm] plugin.
380
+
381
+ ------------------------------------
382
+ vagrant plugin install vagrant-winrm
383
+ ------------------------------------
384
+
385
+ To specify the Windows boxes to use, pass the project properties to gradle:
386
+
387
+ * `-Pvagrant.windows.2012r2.box`
388
+ * `-Pvagrant.windows.2016.box`
389
+
390
+ These properties are required for Windows support in all gradle tasks that
391
+ handle packaging tests. Either or both may be specified. Remember that to run tests
392
+ on these boxes, they still need to be included in the value of `-Pvagrant.boxes`.
393
+ When these properties are present, passing `-Pvagrant.boxes=all` will include the
394
+ Windows boxes. You can also use `-Pvagrant.boxes=windows-all` to only test on Windows boxes.
395
+
396
+ If running vagrant directly, pass the box names in the environment variables:
367
397
368
- * Windows Server 2012
398
+ * `VAGRANT_WINDOWS_2012R2_BOX`
399
+ * `VAGRANT_WINDOWS_2016_BOX`
369
400
370
- It's important to think of VMs like cattle. If they become lame you just shoot
371
- them and let vagrant reprovision them. Say you've hosed your precise VM:
401
+ === Testing VMs are disposable
402
+
403
+ If your testing VM gets into a bad state, just destroy it and let Vagrant
404
+ create a new one. It only takes a minute or two and Vagrant handles all
405
+ the provisioning for you.
406
+
407
+ Let's say you've hosed your Ubuntu Precise VM:
372
408
373
409
----------------------------------------------------
374
410
vagrant ssh ubuntu-1404 -c 'sudo rm -rf /bin'; echo oops
@@ -380,9 +416,6 @@ All you've got to do to get another one is
380
416
vagrant destroy -f ubuntu-1404 && vagrant up ubuntu-1404 --provider virtualbox
381
417
----------------------------------------------
382
418
383
- The whole process takes a minute and a half on a modern laptop, two and a half
384
- without vagrant-cachier.
385
-
386
419
Its possible that some downloads will fail and it'll be impossible to restart
387
420
them. This is a bug in vagrant. See the instructions here for how to work
388
421
around it:
@@ -398,58 +431,72 @@ vagrant destroy -f
398
431
`vagrant up` would normally start all the VMs but we've prevented that because
399
432
that'd consume a ton of ram.
400
433
401
- == Testing scripts more directly
434
+ === Running packaging tests more directly
402
435
403
- In general its best to stick to testing in vagrant because the bats scripts are
404
- destructive. When working with a single package it's generally faster to run its
405
- tests in a tighter loop than gradle provides. In one window:
436
+ Gradle's full packaging test build takes a while, but you can iterate faster
437
+ by managing the VM and running the tests yourself.
438
+
439
+ To get the build ready for the packaging tests, run (on the host)
406
440
407
441
--------------------------------
408
- gradle :distribution:rpm:assemble
442
+ gradle :qa:vagrant:setupPackaging :qa:vagrant:prepareGradleBuild
409
443
--------------------------------
410
444
411
- and in another window:
445
+ and in another window, run the gradle task to bring up the VM. In this
446
+ example let's test on Centos 7
447
+
448
+ -------------------------------------------------
449
+ gradle :qa:vagrant:vagrantCentos7#up
450
+ -------------------------------------------------
451
+
452
+ This task is available for all boxes specified with `-Pvagrant.boxes` -
453
+ to see what's available, run `gradle :qa:vagrant:tasks --all`.
454
+
455
+ Then in another terminal, ssh into the VM
456
+
457
+ ----------------------------------------------------
458
+ vagrant ssh centos-7
459
+ ----------------------------------------------------
460
+
461
+ To run the Bats tests for just the RPM package (on the guest)
412
462
413
463
----------------------------------------------------
414
- vagrant up centos-7 --provider virtualbox && vagrant ssh centos-7
415
464
cd $BATS_ARCHIVES
416
465
sudo -E bats $BATS_TESTS/*rpm*.bats
417
466
----------------------------------------------------
418
467
419
- If you wanted to retest all the release artifacts on a single VM you could:
468
+ Or to retest all the release artifacts on a single VM (on the guest)
420
469
421
470
-------------------------------------------------
422
- gradle setupBats
423
- cd qa/vagrant; vagrant up ubuntu-1404 --provider virtualbox && vagrant ssh ubuntu-1404
424
471
cd $BATS_ARCHIVES
425
472
sudo -E bats $BATS_TESTS/*.bats
426
473
-------------------------------------------------
427
474
428
- You can also use Gradle to prepare the test environment and then starts a single VM:
429
-
430
- -------------------------------------------------
431
- gradle vagrantFedora27#up
432
- -------------------------------------------------
433
-
434
- Or any of vagrantCentos6#up, vagrantCentos7#up, vagrantDebian8#up,
435
- vagrantDebian9#up, vagrantFedora26#up, vagrantFedora27#up, vagrantOel6#up, vagrantOel7#up,
436
- vagrantOpensuse42#up,vagrantSles12#up, vagrantUbuntu1404#up, vagrantUbuntu1604#up.
437
-
438
- Once up, you can then connect to the VM using SSH from the elasticsearch directory:
475
+ To run the Groovy packaging tests, run (on the guest)
439
476
440
- -------------------------------------------------
441
- vagrant ssh fedora-27
442
- -------------------------------------------------
443
-
444
- Or from another directory:
445
-
446
- -------------------------------------------------
447
- VAGRANT_CWD=/path/to/elasticsearch vagrant ssh fedora-27
448
- -------------------------------------------------
477
+ ------------------------------------------------
478
+ cd ~/.elasticsearch && gradle :qa:packaging:run
479
+ ------------------------------------------------
449
480
450
- Note: Starting vagrant VM outside of the elasticsearch folder requires to
451
- indicates the folder that contains the Vagrantfile using the VAGRANT_CWD
452
- environment variable.
481
+ === Testing plugins in packaging tests
482
+
483
+ If you're building plugins in an `elasticsearch-extra` directory, the Vagrantfile
484
+ will mount that directory to the VM so it's included in the VM's gradle build. If
485
+ your plugin's build needs some additional setup steps before it runs, you can add
486
+ task dependencies to the `#prepareGradleBuild` tasks. For example
487
+
488
+ [source, groovy]
489
+ ----------------------------------------
490
+ project(':qa:vagrant).tasks.findAll { t -> t.name.endsWith('prepareGradleBuild') }.each { task ->
491
+ Task myPluginSetupTask = project.tasks.create(task.replace('prepareGradleBuild, 'mySetup')) {
492
+ doLast {
493
+ String vagrantBox = task.ext.box
494
+ // vagrant command to setup box
495
+ }
496
+ }
497
+ task.dependsOn(myPluginSetupTask)
498
+ }
499
+ ----------------------------------------
453
500
454
501
== Testing backwards compatibility
455
502
0 commit comments