logstash/qa/integration
urso 8f4b317dcc Rename filebeat.prospectors to filebeat.inputs
In filebeat prospectors settings have been renamed to inputs. When
prospectors is used a deprecation warning is printed. With 7.0
`filebeat.prospectors` will be removed.

This change updates all uses of prospectors with inputs. For now
filebeat events report `prospector.type` and `input.type` for
compatibility reasons.

Fixes #10711
2019-04-23 17:38:16 +00:00
..
fixtures Java 11 support (#10279) 2019-02-04 16:36:11 -08:00
framework #8004 fix load order to start webserver after pipeline 2018-04-18 16:51:11 +00:00
patch Java 11 support (#10279) 2019-02-04 16:36:11 -08:00
services Update Kafka version to fix build 2019-03-28 19:37:17 +00:00
specs Rename filebeat.prospectors to filebeat.inputs 2019-04-23 17:38:16 +00:00
src/test/java/org/logstash/integration BUILD: Stop using Exec tasks for ITs 2018-04-17 14:02:55 +00: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 BUILD: Stop using Exec tasks for ITs 2018-04-17 14:02:55 +00: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 MINOR: Make ITs use same RSpec version used by the main project 2017-11-22 18:23:39 +00:00
logstash.keystore Rspec integration tests for secret store 2018-01-16 16:46:42 +00:00
README.md Rspec integration tests for secret store 2018-01-16 16:46:42 +00:00
rspec.rb Java 11 support (#10279) 2019-02-04 16:36:11 -08: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 set of tests are full integration tests as in: they can start LS from a binary, run configs using -e and can use any external services like Kafka, ES and S3. 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.

Running integration tests locally (Mac/Linux)

Dependencies

  • JRuby
  • rspec
  • rake
  • bundler

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)

Running integration tests locally via Docker

Dependencies

  • Docker

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

Running integration tests locally from Windows

The integration tests need to be run from MacOS or Linux. However, the tests may be run locally within Docker.

Docker clean up (Mac/Linux)

! Warning this will remove all images and containers except for the logstash-base container !

  • ci/docker_prune.sh

Directory Layout

  • fixtures: In this dir you will test settings in form of test_name.yml. Here you specify services to run, LS config, test specific scripts ala .travis.yml
  • services: This dir has bash scripts that download and bootstrap binaries for services. This is where services like ES will be downloaded and run from. 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

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.