Skip to content

qa: use clean expansion of LS tarball per fixture instance#17082

Merged
yaauie merged 2 commits intoelastic:mainfrom
yaauie:qa-clean-logstash-service-per-fixture-instance
Feb 14, 2025
Merged

qa: use clean expansion of LS tarball per fixture instance#17082
yaauie merged 2 commits intoelastic:mainfrom
yaauie:qa-clean-logstash-service-per-fixture-instance

Conversation

@yaauie
Copy link
Copy Markdown
Member

@yaauie yaauie commented Feb 13, 2025

Release notes

[rn: skip]

What does this PR do?

Ensures that Logstash integration tests are run against a clean expansion of the built tarball.

Why is it important/What is the impact to the user?

Because QA tests can modify the Logstash installation (e.g. those that invoke the plugin manager), it is important that the service wrapper begins with a clean expansion of the logstash tarball.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • [ ] I have made corresponding changes to the documentation
  • [ ] I have made corresponding change to the default configuration files (and/or docker env variables)
  • [ ] I have added tests that prove my fix is effective or that my feature works

How to test this PR locally

Run integration tests that invoke the Logstash service (or any of its sub-command features like the plugin manager):

ci/integration_tests.sh specs/cli/remove_spec.rb

Logs

see expunging, indicating that the old was removed
see expanding, indicating a fresh expansion
see Using...as LS_HOME, indicating that the fresh expansion is being used

    CLI > logstash-plugin remove
    expunging(/Users/rye/src/elastic/logstash@main/build/qa-fixture/logstash-9.1.0-SNAPSHOT)
    expanding(/Users/rye/src/elastic/logstash@main/build/logstash-9.1.0-SNAPSHOT.tar.gz)
    Using /Users/rye/src/elastic/logstash@main/build/qa-fixture/logstash-9.1.0-SNAPSHOT as LS_HOME
    Setting up services
    Setting up logstash service
    Setup script not found for logstash
    logstash service setup complete
      when other plugins depends on this plugin
        refuses to remove the plugin and display the plugin that depends on it.
      when no other plugins depends on this plugin
        successfully remove the plugin

    Finished in 2 minutes 0.2 seconds (files took 0.98941 seconds to load)
    2 examples, 0 failures

Because QA tests can _modify_ the Logstash installation (e.g. those that
invoke the plugin manager), it is important that the service wrapper
begins with a clean expansion of the logstash tarball.
@yaauie yaauie added the tests label Feb 13, 2025
@yaauie
Copy link
Copy Markdown
Member Author

yaauie commented Feb 13, 2025

2025-02-13 16:52:01 UTC	    An error occurred in an `after(:context)` hook.
2025-02-13 16:52:01 UTC	    Failure/Error: FileUtils.mv("#{@fixture.get_service('logstash').application_settings_file}.original", @fixture.get_service('logstash').application_settings_
file)
2025-02-13 16:52:01 UTC	
2025-02-13 16:52:01 UTC	    Errno::ENOENT:
2025-02-13 16:52:01 UTC	      No such file or directory - /buildkite/builds/bk-agent-prod-k8s-1739464416407722128/elastic/logstash-pull-request-pipeline/build/qa-fixture/logstash-9.1.0
-SNAPSHOT/config/logstash.yml.original or /buildkite/builds/bk-agent-prod-k8s-1739464416407722128/elastic/logstash-pull-request-pipeline/build/qa-fixture/logsta
sh-9.1.0-SNAPSHOT/config/logstash.yml
2025-02-13 16:52:01 UTC	    # ./specs/logstash_to_logstash_spec.rb:35:in `block in <main>'
2025-02-13 16:52:01 UTC	    # ./rspec.rb:36:in `<main>'

-- https://buildkite.com/elastic/logstash-pull-request-pipeline/builds/2300#01950028-7702-4dcf-b3ee-8b5ebbda643f/2070-3724

The specs/logstash_to_logstash_spec.rb does LogstashService::new directly, twice, and the mid-test expunge in LogstashService#initialize deletes files that it expects to still exist.

I'll need to re-work that test, or accommodate it somehow.

@fixture.teardown
}

def change_logstash_setting(logstash_service, name, value)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stomps on the existing config in the logstash installation under test, which is shared across multiple tests and may contain useful bits in the event of feature flags.

Since it is only ever used to set the api.http.port in advance of spawning the logstash process, we can simply use the equivalent --api.http.port command-line flag and avoid modifying the logstash config.

@elastic-sonarqube
Copy link
Copy Markdown

Quality Gate passed Quality Gate passed

Issues
0 New issues
0 Fixed issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarQube

end

def run_logstash_instance(config_name, options = {})
api_port = 9600 + rand(1000)
Copy link
Copy Markdown
Member Author

@yaauie yaauie Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

random allocation means occasional collisions.

I've elected to keep track of an offset in a range of 1000, looping back to 0 if we ever have enough tests to do so.

@elasticmachine
Copy link
Copy Markdown

💚 Build Succeeded

History

Copy link
Copy Markdown
Member

@robbavey robbavey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@yaauie yaauie merged commit d20eb4d into elastic:main Feb 14, 2025
@yaauie
Copy link
Copy Markdown
Member Author

yaauie commented Feb 14, 2025

@logstashmachine backport 8.x

@yaauie
Copy link
Copy Markdown
Member Author

yaauie commented Feb 14, 2025

@logstashmachine backport 8.18

github-actions bot pushed a commit that referenced this pull request Feb 14, 2025
* qa: use clean expansion of LS tarball per fixture instance

Because QA tests can _modify_ the Logstash installation (e.g. those that
invoke the plugin manager), it is important that the service wrapper
begins with a clean expansion of the logstash tarball.

* qa: enable safe reuse of ls_home in ls_to_ls tests

(cherry picked from commit d20eb4d)
github-actions bot pushed a commit that referenced this pull request Feb 14, 2025
* qa: use clean expansion of LS tarball per fixture instance

Because QA tests can _modify_ the Logstash installation (e.g. those that
invoke the plugin manager), it is important that the service wrapper
begins with a clean expansion of the logstash tarball.

* qa: enable safe reuse of ls_home in ls_to_ls tests

(cherry picked from commit d20eb4d)
yaauie added a commit that referenced this pull request Feb 14, 2025
…17094)

* qa: use clean expansion of LS tarball per fixture instance

Because QA tests can _modify_ the Logstash installation (e.g. those that
invoke the plugin manager), it is important that the service wrapper
begins with a clean expansion of the logstash tarball.

* qa: enable safe reuse of ls_home in ls_to_ls tests

(cherry picked from commit d20eb4d)

Co-authored-by: Ry Biesemeyer <yaauie@users.noreply.github.com>
yaauie added a commit that referenced this pull request Feb 14, 2025
…17095)

* qa: use clean expansion of LS tarball per fixture instance

Because QA tests can _modify_ the Logstash installation (e.g. those that
invoke the plugin manager), it is important that the service wrapper
begins with a clean expansion of the logstash tarball.

* qa: enable safe reuse of ls_home in ls_to_ls tests

(cherry picked from commit d20eb4d)

Co-authored-by: Ry Biesemeyer <yaauie@users.noreply.github.com>
@yaauie
Copy link
Copy Markdown
Member Author

yaauie commented Feb 18, 2025

@logstashmachine backport 9.0

github-actions bot pushed a commit that referenced this pull request Feb 18, 2025
* qa: use clean expansion of LS tarball per fixture instance

Because QA tests can _modify_ the Logstash installation (e.g. those that
invoke the plugin manager), it is important that the service wrapper
begins with a clean expansion of the logstash tarball.

* qa: enable safe reuse of ls_home in ls_to_ls tests

(cherry picked from commit d20eb4d)
mashhurs pushed a commit that referenced this pull request Feb 19, 2025
…17113)

* qa: use clean expansion of LS tarball per fixture instance

Because QA tests can _modify_ the Logstash installation (e.g. those that
invoke the plugin manager), it is important that the service wrapper
begins with a clean expansion of the logstash tarball.

* qa: enable safe reuse of ls_home in ls_to_ls tests

(cherry picked from commit d20eb4d)

Co-authored-by: Ry Biesemeyer <yaauie@users.noreply.github.com>
v1v pushed a commit to v1v/logstash that referenced this pull request Feb 25, 2025
…7082)

* qa: use clean expansion of LS tarball per fixture instance

Because QA tests can _modify_ the Logstash installation (e.g. those that
invoke the plugin manager), it is important that the service wrapper
begins with a clean expansion of the logstash tarball.

* qa: enable safe reuse of ls_home in ls_to_ls tests
v1v added a commit to v1v/logstash that referenced this pull request Feb 25, 2025
…gify

* upstream/main: (27 commits)
  Add Windows 2025 to CI (elastic#17133)
  Update container acceptance tests with stdout/stderr changes (elastic#17138)
  entrypoint: avoid polluting stdout (elastic#17125)
  Fix acceptance test assertions for updated plugin remove (elastic#17126)
  Fix acceptance test assertions for updated plugin `remove` (elastic#17122)
  plugins: improve `remove` command to support multiple plugins (elastic#17030)
  spec: improve ls2ls spec (elastic#17114)
  allow concurrent Batch deserialization (elastic#17050)
  CPM handle 404 response gracefully with user-friendly log (elastic#17052)
  qa: use clean expansion of LS tarball per fixture instance (elastic#17082)
  Allow capturing heap dumps in DRA BK jobs (elastic#17081)
  Use centralized source of truth for active branches (elastic#17063)
  Update logstash_releases.json (elastic#17055)
  fix logstash-keystore to accept spaces in values when added via stdin (elastic#17039)
  Don't honor VERSION_QUALIFIER if set but empty (elastic#17032)
  Release note placeholder might be empty, making parsing lines nil tolerant. (elastic#17026)
  Fix BufferedTokenizer to properly resume after a buffer full condition respecting the encoding of the input string (elastic#16968)
  Add short living 9.0 next and update main in CI release version definition. (elastic#17008)
  Core version bump to 9.1.0 (elastic#16991)
  Add 9.0 branch to the CI branches definition (elastic#16997)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants