-
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
Added test to cover the installation of aliased plugins #12967
Added test to cover the installation of aliased plugins #12967
Conversation
# expect(cmd).to receive(:validate_cli_options!).and_return(nil) | ||
# expect(cmd).to receive(:plugins_gems).and_return([["logstash-input-elastic_agent", nil]]) | ||
# expect(cmd).to receive(:install_gems_list!).and_return(nil) | ||
# expect(cmd).to receive(:remove_unused_locally_installed_gems!).and_return(nil) | ||
# cmd.verify = true |
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.
# expect(cmd).to receive(:validate_cli_options!).and_return(nil) | |
# expect(cmd).to receive(:plugins_gems).and_return([["logstash-input-elastic_agent", nil]]) | |
# expect(cmd).to receive(:install_gems_list!).and_return(nil) | |
# expect(cmd).to receive(:remove_unused_locally_installed_gems!).and_return(nil) | |
# cmd.verify = true |
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.
Thank you @jsvd, my bad, missed to polish the commented stuff
expect(cmd).to receive(:validate_cli_options!).and_return(nil) | ||
expect(cmd).to receive(:plugins_gems).and_return([["logstash-input-elastic_agent", nil]]) | ||
expect(cmd).to receive(:install_gems_list!).and_return(nil) | ||
expect(cmd).to receive(:remove_unused_locally_installed_gems!).and_return(nil) |
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.
Maybe a small explanation here on why all of this mocking is needed?
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.
are mainly inherited by the above test that verify the installation of a dummy gem, but in this case uses a real alias name shipped into the plugin_aliases.yml
file
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.
mainly those mocks are used to provide data to command (in an indirect form) and to control the path of execution go straight to the verify_remote!
method
# expect(cmd).to receive(:validate_cli_options!).and_return(nil) | ||
# expect(cmd).to receive(:plugins_gems).and_return([["logstash-input-elastic_agent", nil]]) | ||
# expect(cmd).to receive(:install_gems_list!).and_return(nil) | ||
# expect(cmd).to receive(:remove_unused_locally_installed_gems!).and_return(nil) | ||
# cmd.verify = true | ||
|
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.
# expect(cmd).to receive(:validate_cli_options!).and_return(nil) | |
# expect(cmd).to receive(:plugins_gems).and_return([["logstash-input-elastic_agent", nil]]) | |
# expect(cmd).to receive(:install_gems_list!).and_return(nil) | |
# expect(cmd).to receive(:remove_unused_locally_installed_gems!).and_return(nil) | |
# cmd.verify = true |
|
||
# it "validate_plugin method should return false for a gem that's not a plugin" do | ||
# expect(cmd).to receive(:validate_cli_options!).and_return(nil) | ||
# # expect(cmd).to receive(:plugins_gems).and_return([["logstash-filters-aliased_filter", nil]]) | ||
# # expect(cmd).to receive(:plugins_gems).and_return([["logstash-input-elastic_agent", nil]]) | ||
# expect(cmd).to receive(:install_gems_list!).and_return(nil) | ||
# expect(cmd).to receive(:remove_unused_locally_installed_gems!).and_return(nil) | ||
# cmd.verify = true | ||
# | ||
# res = cmd.validate_plugin([["logstash-input-elastic_agent", nil]]) | ||
# | ||
# expect(res).to be false | ||
# end |
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.
# it "validate_plugin method should return false for a gem that's not a plugin" do | |
# expect(cmd).to receive(:validate_cli_options!).and_return(nil) | |
# # expect(cmd).to receive(:plugins_gems).and_return([["logstash-filters-aliased_filter", nil]]) | |
# # expect(cmd).to receive(:plugins_gems).and_return([["logstash-input-elastic_agent", nil]]) | |
# expect(cmd).to receive(:install_gems_list!).and_return(nil) | |
# expect(cmd).to receive(:remove_unused_locally_installed_gems!).and_return(nil) | |
# cmd.verify = true | |
# | |
# res = cmd.validate_plugin([["logstash-input-elastic_agent", nil]]) | |
# | |
# expect(res).to be false | |
# end |
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.
LGTM
Added test to cover the installation of aliased plugins when exists a gem with same name but that's not a Logstash plugin. In this case the alias is resolved to the original, skipping the gem retrieved from RubyGems. (cherry picked from commit cafbf03)
) Added test to cover the installation of aliased plugins when exists a gem with same name but that's not a Logstash plugin. In this case the alias is resolved to the original, skipping the gem retrieved from RubyGems. (cherry picked from commit cafbf03)
* master: (41 commits) Test: resolve integration failure due ECS mode (elastic#13044) Feat: event factory support (elastic#13017) Doc: Add geoip database API to node stats (elastic#13019) Add geoip database metrics to /node/stats API (elastic#13004) ecs: on-by-default plus docs (elastic#12830) ispec: fix cross-spec leak from fatal error integration specs (elastic#13002) Fix UBI source URL (elastic#13008) update fpm to allow pkg creation on jdk11+jruby 9.2 (elastic#13005) Add unit test to grant that production aliases correspond to a published RubyGem (elastic#12993) Fix logstash.bat not setting exit code (elastic#12948) Use the OS separator to invoke gradlew from Rake script (elastic#13000) Allow per-pipeline config of ECS Compatibility mode via Central Management (elastic#12861) Update jinja2 dependency in docker build (elastic#12994) fix database manager with multiple pipelines (elastic#12862) Fix Reflections stack traces when process yml files in classpath and debug is enabled (elastic#12991) Fix/log4j routing to avoid create spurious file (elastic#12965) Deps: update JRuby to 9.2.19.0 (elastic#12989) Doc: Add tip for checking for existing field (elastic#12899) Added test to cover the installation of aliased plugins (elastic#12967) CI: Update logstash_release.json after 7.3.12 (elastic#12986) ...
Release notes
[rn:skip]
What does this PR do?
Adds test coverage for plugin manager when it installs aliased plugins
Why is it important/What is the impact to the user?
No impact for the user
Checklist
I have commented my code, particularly in hard-to-understand areasI have made corresponding changes to the documentationI have made corresponding change to the default configuration files (and/or docker env variables)Author's Checklist
How to test this PR locally
Related issues
Use cases
Screenshots
Logs