logstash/qa
github-actions[bot] ce8d43f39b
Don't honor VERSION_QUALIFIER if set but empty (#17032) (#17071)
PR #17006 revealed that the `VERSION_QUALIFIER` env var gets honored in
various scripts when present but empty.
This shouldn't be the case as the DRA process is designed to gracefully
ignore empty values for this variable.

This commit changes various ruby scripts to not treat "" as truthy.
Bash scripts (used by CI etc.) are already ok with this as part of
refactorings done in #16907.

---------

Co-authored-by: Andrea Selva <selva.andre@gmail.com>
(cherry picked from commit c7204fd7d6)

Co-authored-by: Dimitrios Liappis <dimitrios.liappis@gmail.com>
2025-02-12 15:55:29 +02:00
..
acceptance Follow up to #15900 -- fix remaining acceptance tests (#15907) 2024-02-15 11:33:17 +02:00
docker Don't honor VERSION_QUALIFIER if set but empty (#17032) (#17071) 2025-02-12 15:55:29 +02:00
integration Backport PR #15679 to 8.x: [Spacetime] Reimplement config Setting classe in java (#16490) 2024-10-11 08:54:03 +02:00
rspec Fix packaging service check failures (#15946) 2024-02-15 10:01:47 +02:00
scripts/windows Spelling fixes (#6806) 2017-03-29 19:33:26 -07:00
support Feature: health report api (#16520) 2024-10-09 09:48:12 -07:00
.gitignore relocate windows scripted tests into the qa folder 2016-05-12 06:56:25 +00:00
.rspec add .rspec file to the qa dir so the default formater is documentation 2016-06-29 04:47:15 -04:00
Gemfile Fix QA failure introduced by Health API changes and update rspec dependency of the QA package. (#16521) 2024-10-09 14:47:01 -07:00
Rakefile Refactor qa/acceptance tests to get away from vagrant (#15696) 2024-01-08 09:40:58 +02:00
README.md Refactor qa/acceptance tests to get away from vagrant (#15696) 2024-01-08 09:40:58 +02:00

Acceptance test Framework

The acceptance test framework for Logstash is intended to test the functionality of packages (.deb, .rpm) on various supported platforms.

In this small README we describe its features and the steps necessary for executing it and adding new tests.

Description

In summary this test framework is composed of:

  • A collection of rspec helpers and matchers that make creating tests easy.
  • Rspecs helpers that execute commands.

The tests are expected to be executed on the target environment e.g. an Ubuntu 22.04 vm.

Running tests/Prerequisites

To run the tests from a fresh Logstash checkout, you need to:

  1. ./gradlew clean boostrap 2a. Build the necessary package artifacts e.g. rake artifact:deb OR 2b. Supply a directory where pregenerated package artifacts exit via the LS_ARTIFACTS_PATH environment variable (relative and absolute paths are supported).
  2. cd qa
  3. bundle install

Now you are ready to kick off the tests:

  1. rake qa:acceptance:all.

Steps 1, 2b, 3, 4, 5 are executed by the ci/acceptance_tests.sh script.

Architecture of the Framework

Directory structure

  • acceptance/: all the specs definitions.
  • rspec: all framework parts necessary to get the test running. Includes the commands, the rspec matchers and a collection of useful helpers.

I want to add a test, what should I do?

To add a test you basically should start by the acceptance directory, here you will find an already created tests, most important locations here are:

  • lib here is where the tests are living. If a test is not going to be reused it should be created here.
  • shared_examples inside that directory should be living all tests that could be reused in different scenarios, like you can see the CLI ones.

but we want to write tests, here is an example of how do they look like, including the different moving parts we encounter in the framework.

    logstash = ServiceTester::Artifact.new()

    ## your test code goes here.

    # example:
    it_behaves_like "installable_with_jdk", logstash
    it_behaves_like "updated", logstash, from_release_branch="7.17"

Inside the rspec directory you will find a collection of commands, organized per operating system, which will let you operate and get your tests done.

You'll probably find enough supporting classes for different platforms, but if not, feel free to add more.

An example of an install command on debian looks like:

    def installed?(package)
      stdout = ""
      cmd = sudo_exec!("dpkg -s #{package}")
      stdout = cmd.stdout
      stdout.match(/^Package: #{package}$/)
      stdout.match(/^Status: install ok installed$/)
    end
  end

this is how we run operations and wrap them as ruby code.

Running a test (detailed level)

There is also the possibility to run your tests with more granularity by using the rspec command, this will let you for example run a single tests, a collection of them using filtering, etc.

Check https://relishapp.com/rspec/rspec-core/v/3-4/docs/command-line for more details, but here is a quick cheat sheet to run them:

Run the examples that get "is installed" in their description

  • bundle exec rspec acceptance/spec -e "is installed"

Run the example defined at line 11

  • bundle exec rspec acceptance/spec/lib/artifact_operation_spec.rb:11