logstash/qa/integration
Cas Donoghue 0e99f526c4
Bump jruby 9.4.13.0 (#17696)
* upgrade jruby to 9.4.11.0

* follow up cleanups

* follow up cleanups

* follow up cleanups

* follow up cleanups

* add licenses

* Update rakelib/plugins-metadata.json

* attempt to fix rubygems

* attempt to fix rubygems

* attempt to fix rubygems

* tweaks for jruby 9.4.12.0 and sha256 validation

* attempt at fixing rubygems

* attempt at fixing rubygems

* attempt at fixing rubygems

* attempt at fixing rubygems

* Bump jruby to 9.4.12.1

* Explicitly require 'set' to make `to_set` available

Something appears to have changed in code loading where this require
is no longer in the call chain. Explicitly require it here.

* Fix up dependency mapper

* Update bundler code with latest rubygems release

This commit makes 2 changes:

1. We were sending a `Gem::Platform` instance to Thor parser instead of a
string. Convert to string version of a platform name. With newly added checks in
Thor, we were getting `noMethodError` for `Gem::Platform`.

2.  It looks like there was a patch to get around a bug in bundler that was
reaching out to the network for local gems. This appears to have been fixed
upstream, this removes the patch.

* Restore patch

* Remove patch (TODO, link to full writeup)

* SPIKE: Take up jruby 9.4.13.0

* Patch bundler cache

Still validating this. Essentially ensure we check local gems when calling cache using
the updated rubygems class.

* WIP: test patch for acceptance tests

* Skip when unable to cache

* Cache every gem

* Fix acceptance test

* Force another route through builtin

* Fixup idea (it returns nil, not raise)

* Fix missing version update

* Fix qatest filter plugin

Without including a gemspec with a locally built gem logstash-plugin list
will not show it in the output.

* Use vendored gem instead of reaching out to rubygems

We vendor an udpated test gem for local install. Use that instead of
reaching out to rubygems.

* Document and comment on the patched bundler code

* Fix test

instead of downloading the "broken" one from rubygems (downloading the `.gem` file directly
does show up in plugin-list), using a vendored one polutes the cache. Use a new vendored
gem

---------

Co-authored-by: João Duarte <jsvduarte@gmail.com>
Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
2025-06-24 15:24:52 -07:00
..
fixtures Bump jruby 9.4.13.0 (#17696) 2025-06-24 15:24:52 -07:00
framework qa: use clean expansion of LS tarball per fixture instance (#17082) 2025-02-14 07:53:52 -08:00
services Ensure elasticsearch logs and data dirs exist before startup (#17531) 2025-04-09 13:32:32 -07:00
specs Upgrade elasticsearch-ruby client. (#17161) 2025-03-13 10:03:07 -07:00
src/test/java/org/logstash/integration Refactor: drop redundant (jruby-complete.jar) dependency (#13159) 2022-02-02 06:55:26 +01:00
.gitignore Add bin/logstash-plugin prepare-offline-pack command 2017-01-03 13:59:49 -05:00
.rspec Add new tests and some helpers 2016-10-14 18:27:44 -04:00
build.gradle qa: don't bypass plugin manger tests on linux (#17171) 2025-02-27 13:24:04 -08:00
Gemfile #8177 break cyclic dependency on old Logstash core in ITs and properly load it before service setup 2017-09-12 21:24:25 +00:00
gradle.properties Add license reporting task 2018-05-02 15:35:42 +00:00
integration_tests.gemspec Pin childprocess gem to major version 4 (#15758) 2024-01-08 18:08:46 +02:00
logstash.keystore Rspec integration tests for secret store 2018-01-16 16:46:42 +00:00
README.md Doc:Update qa readme with BUILD_JAVA_HOME setting info (#11985) 2022-02-15 18:44:58 -05:00
rspec.rb Rubocop: Enable various EmptyLine cops (#15194) 2023-07-18 16:49:16 -04:00
settings.gradle BUILD: Stop using Exec tasks for ITs 2018-04-17 14:02:55 +00:00
suite.yml Add feature flag support for RATS (#6328) 2016-12-01 11:29:16 -08:00

Logstash Integration Tests aka RATS

These test sets are full integration tests. They can:

  • start Logstash from a binary,
  • run configs using -e, and
  • use external services such as Kafka, Elasticsearch, and Beats.

This framework is hybrid -- a combination of bash scripts (to mainly setup services), Ruby service files, and RSpec. All test assertions are done in RSpec.

Environment setup

Directory Layout

  • fixtures: Specify services to run, Logstash config, and test specific scripts ala .travis.yml. You test settings in form of test_name.yml.
  • services: This directory has bash scripts that download and bootstrap binaries for services. This is where services like Elasticsearch will be downloaded and run. Service can have 3 files: <service>_setup.sh, <service>_teardown.sh and <service>.rb. The bash scripts deal with downloading and bootstrapping, but the ruby source will trigger them from the test as a shell out (using backticks). The tests are blocked until the setup/teardown completes. For example, Elasticsearch service has elasticsearch_setup.sh, elasticsearch_teardown.sh and elasticsearch.rb. The service name in yml is "elasticsearch".
  • framework: Test framework source code.
  • specs: Rspec tests that use services and validates stuff

Setup Java

The integration test scripts use gradle to run the tests. Gradle requires a valid version of Java either on the system path, or specified using the JAVA_HOME environment variable pointing to the location of a valid JDK.

To run integration tests using a different version of Java, set the BUILD_JAVA_HOME environment variable to the location of the JDK that you wish to test with.

Testing on Mac/Linux

Dependencies

  • JRuby
  • rspec
  • rake
  • bundler

Running integration tests locally (Mac/Linux)

Run tests from the Logstash root directory.

  • Run all tests:

    ci/integration_tests.sh

  • Run a single test:

    ci/integration_tests.sh specs/es_output_how_spec.rb

  • Debug tests:

    ci/integration_tests.sh setup 
    cd qa/integration
    bundle exec rspec specs/es_output_how_spec.rb (single test)
    bundle exec rspec specs/*  (all tests)
    

Testing with Docker

Dependencies

  • Docker

Running integration tests locally using Docker

Run tests from the Logstash root directory.

  • Run all tests:

    docker build  -t logstash-integration-tests .
    docker run -it --rm logstash-integration-tests ci/integration_tests.sh 
    
  • Run a single test:

docker build  -t logstash-integration-tests .
docker run -it --rm logstash-integration-tests ci/integration_tests.sh specs/es_output_how_spec.rb
  • Debug tests:
(Mac/Linux) docker ps --all -q -f status=exited | xargs docker rm  
(Windows) `docker ps -a` and take note of any exited containers, then `docker rm <container-id>`
docker build -t logstash-integration-tests . 
docker run -d --name debug logstash-integration-tests tail -f /dev/null
docker exec -it debug ci/integration_tests.sh setup 
docker exec -it debug bash
cd qa/integration
bundle exec rspec specs/es_output_how_spec.rb
exit
docker kill debug
docker rm debug

Docker clean up (Mac/Linux)

WARNING: Docker cleanup removes all images and containers except for the logstash-base container!

  • ci/docker_prune.sh

Testing on Windows

The integration tests should be run from MacOS or Linux. However, the tests can be run locally within Docker on Windows.

Adding a new test

  1. Creating a new test -- lets use as example. Call it "test_file_input" which brings up LS to read from a file and assert file contents (file output) were as expected.
  2. You'll have to create a yml file in fixtures called test_file_input_spec.yml. Here you define any external services you need and any LS config.
  3. Create a corresponding test_file_input_spec.rb in specs folder and use the fixtures object to get all services, config etc. The .yml and rspec file has to be the same name for the settings to be picked up. You can start LS inside the tests and assume all external services have already been started.
  4. Write rspec code to validate.