-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Script to run all plugins tests and try an install, rooting in local Logstash #15018
Script to run all plugins tests and try an install, rooting in local Logstash #15018
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will be super useful, and spent a bit of time bike-shedding where the list of supported plugins should be (I don't believe the current nested structured embedding is the "right" place).
I ran into a bit of a problem though because this script pollutes the Gemfile
and Gemfile.lock
files that are used by Logstash's plugin manager, and the ci/test_supported_plugins.sh
entry-point invokes ./gradlew installDefaultGems
which ensures that most (all?) of these gems are already previously installed from their relevant rubygems artifact.
Questions to that end:
- do we expect this to run on top of the default gem installation, and if so, what are we doing to validate that the local-git-checkout of the plugin is what is effectively installed?
- are we trying to test installing each in isolation (that is, snapshot the
Gemfile
andGemfile.lock
before each plugin we are validating and restore the snapshot before proceeding to the next), or are we trying to test installing them together (if so, we should likely randomize the order in which we do so)
Thanks @yaauie for reviewing it!
Ahh right, but the
You are right, maybe before installing the locally created gem the script should remove the plugin from Logstash with a
|
…ns or provide directly the name of the plugin
Co-authored-by: Ry Biesemeyer <[email protected]>
2d5568d
to
0d263fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent.
It would be good to have a singular canonical reference of plugins by support tier that can be referenced by this script instead of hard-coding it, but that can be deferred to a separate effort.
def git_clone | ||
if File.directory?(plugin_name) | ||
puts "#{plugin_name} already cloned locally" | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we git pull
in this case? do we need to worry about "dirty" repositories with untracked or modified files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, great idea thanks. Implemented with commit e23677b
ci/test_supported_plugins.rb
Outdated
|
||
# it has to be out of logstash local close else plugins' Gradle script | ||
# would interfere with Logstash's one | ||
base_folder = "/tmp" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- I would rather avoid dumping into
/tmp
, so maybe an environment variable would be a good hook point? - We should use the OS-independent
Dir::tmpdir
instead of hard-coding/tmp
:
base_folder = "/tmp" | |
base_folder = ENV['LOGSTASH_PLUGINS_TMP'] || (require 'tmpdir'; Dir.tmpdir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, fixed with commit d3df637
# Test the | ||
# - build (rspec), | ||
# - packaging (gem build) | ||
# - and deploy (bin/logstash-plugin install) | ||
# of a plugins inside the current Logstash, using its JRuby | ||
# Usage example: | ||
# bin/ruby ci/test_supported_plugins.rb -p logstash-integration-jdbc | ||
# bin/ruby ci/test_supported_plugins.rb -t tier1 -k input,codec,integration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 the usage is missing a note about needing a clean bootstrap + installDevelopmentGems
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need the Logstash JRuby to be present, so at least here we should execute ./gradlew assemble
, to setup the environment to be able to run the Ruby script.
We can split this in 2:
- in the shell script invoke the minimal Gradle task that setup the environment to be able to run the Ruby script
- in the Ruby script executes all the steps that are fundamental to have Logstash in right posture to execute the tests; which means executing the Gradle's
installDevelopmentGems
tasks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handled with b30ad38
ci/test_supported_plugins.sh
Outdated
export JRUBY_OPTS="-J-Xmx1g" | ||
export GRADLE_OPTS="-Xmx4g -Dorg.gradle.jvmargs=-Xmx4g -Dorg.gradle.daemon=false -Dorg.gradle.logging.level=info -Dfile.encoding=UTF-8" | ||
|
||
./gradlew installDevelopmentGems |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be simpler to move this pre-requisite over to the ruby script so that everything is all in one place?
Co-authored-by: Ry Biesemeyer <[email protected]>
…plugin repository was already cloned
…er for all plugin cloning activities
…table from the phase to setup a local Logstash to be used in the test
Hi @yaauie
I agree with you. My idea would be to move those tiers and plugins inventory into a separate YAML file, maybe in the root of the Logstash project. A sample could be: tier1:
inputs:
- logstash-input-azure_event_hubs
- logstash-input-beats
codecs:
- logstash-codec-generator
filters:
- ...
outputs:
- ...
integrations:
- logstash_integration_kafka
tier2: ... I think that would be better addressed in a follow up PR. WDYT? |
Eventually we could use this: https://github.com/elastic/logstash/blob/main/rakelib/plugins-metadata.json as plugin repository. Every plugins that has |
Hi @yaauie , sorry to nudge you, let me know what you think about latest changes to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation LGTM.
Let's merge as-is file an issue about the shared source-of-truth for plugins and their tiers so we don't lose track of it.
Created the follow up issue #15190 to track the request to use a common plugins inventory. |
Release notes
[rn:skip]
What does this PR do?
Implements a script to test all supported plugins against Logstash/JRuby, in particular it uses the JRuby(and JDK) bundled with Logstash to execute the unit tests, create the gem and install the gem on local Logstash.
This doesn't start a real pipeline run into the local Logstash, but should be enough to reveal macroscopic Ruby syntax compatibility errors.
Why is it important/What is the impact to the user?
The introduced script permit to test supported plugins in the context of Logstash.
It provides a couple of command line options to select the plugins to test.
Using
-p
followed by a plugin name verify only that plugin. To testlogstash-integration-jdbc
it can be specified as:Using
-t
(tier) and-k
(kind) a set of plugins can be selected, for example: all input and output plugins of tier1 and tier2 could expressed as-h
(halt) option is a boolean switch to stop on the first error instead of continue with all the plugins.Checklist
[ ] 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 worksAuthor's Checklist
How to test this PR locally
Related issues
Use cases
Screenshots
Logs