Skip to content

Conversation

@donoghuc
Copy link
Member

Release notes

[rn:skip]

What does this PR do?

Previously unit tests were run with a subset of gems. This masked issues where conflicts (specifically with loading jar-dependencies) with gem load/activation were causing issues. This updates the tests to install the full gem set for unit tests. The added test time is minimal (less than a minute) and should give us a more consistent gem environment for testing.

See #17873 for more details.

Previously unit tests were run with a subset of gems. This masked issues where
conflicts (specifically with loading jar-dependencies) with gem load/activation
were causing issues. This updates the tests to install the full gem set for unit
tests. The added test time is minimal (less than a minute) and should give us a
more consistent gem environment for testing.
@github-actions
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

@mergify
Copy link
Contributor

mergify bot commented Oct 21, 2025

This pull request does not have a backport label. Could you fix it @donoghuc? 🙏
To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-8./d is the label to automatically backport to the 8./d branch. /d is the digit.
  • If no backport is necessary, please add the backport-skip label

@donoghuc donoghuc added the backport-active-all Automated backport with mergify to all the active branches label Oct 21, 2025
@elasticmachine
Copy link

💚 Build Succeeded

donoghuc added a commit to donoghuc/logstash that referenced this pull request Nov 4, 2025
This commit adds the installDefaultGems task to the unit test tasks. This
ensures that the gem env tested at the unit level matches the deduplicated one
at the integration/acceptance level. Takes over elastic#18330
@donoghuc
Copy link
Member Author

donoghuc commented Nov 4, 2025

Closing as this is now coming in to play with #18340. We want to ensure at the unit level that the deduplicated gem set is used.

@donoghuc donoghuc closed this Nov 4, 2025
donoghuc added a commit to donoghuc/logstash that referenced this pull request Nov 26, 2025
This commit adds the installDefaultGems task to the unit test tasks. This
ensures that the gem env tested at the unit level matches the deduplicated one
at the integration/acceptance level. Takes over elastic#18330
jsvd pushed a commit that referenced this pull request Dec 2, 2025
This commit adds the installDefaultGems task to the unit test tasks. This
ensures that the gem env tested at the unit level matches the deduplicated one
at the integration/acceptance level. Takes over #18330
donoghuc added a commit to donoghuc/logstash that referenced this pull request Dec 10, 2025
This commit adds the installDefaultGems task to the unit test tasks. This
ensures that the gem env tested at the unit level matches the deduplicated one
at the integration/acceptance level. Takes over elastic#18330
donoghuc added a commit that referenced this pull request Dec 10, 2025
* Remove duplicate gems when producting logstash artifacts

Bundler is used to manage a gem environment that is shipped with logstash
artifacts. By default, bundler will install newer/duplicate gems than shipped
with ruby distributions (in logstash's case jruby). Duplicate gems in the
shipped environment can cause issues with code loading with ambiguous gem specs
or gem activation issues. This commit adds a step to compute the duplicate gems
managed with bundler (and therefore direct/transitive dependencies of
logstash/plugins) and *removes* copies shipped with jruby. Note that there are
two locations to do the deduplication at. Both the stdlib gems as well as what
jruby refers to as "bundled" gems. The existing pattern for excluding files from
artifacts is used to implement the deduplication.

* only remove gemspecs for duplicated stdlib gems

* Make deduplicate a separate rake task and prevent gradle errors

Deduplication should happen as a depenedency of installing default gems. In the
current workflow we have a top level gradle task for packaging which calls out
to rake. Rake then invokes a *separate* gradle process. When we modify the jruby
default, when the separate gradle process goes to check of jruby is installed,
it sees a modified jruby and tries to re-install. We work around this by
changing how gradle detects if jruby is required to be installed.

* Ensure the set of gems tested at unit level matches packages

This commit adds the installDefaultGems task to the unit test tasks. This
ensures that the gem env tested at the unit level matches the deduplicated one
at the integration/acceptance level. Takes over #18330

* WIP: Use logstash_gem_home for gemInstaller

This commit changes gemInstaller such that the centralized gem_home from
Logstash::Environment is used instead of hard coding in a fragile path. The
tests were the only consumer of the optional positional parameter in the
`install` class method.

* Fix gem env setup for ruby unit tests

After some deeeeeeeep diving into comparing the state of running logstash from a
compiled artifact vs the unit tests i finally figured out that the use of the
bundler `setup!` method in unit tests is imcompatible with a couple of tests.
Specifically that method puts bundler installed gems ahead of the standard lib
gems in the load path. This commit solves that by re-positioning the standarl
lib back to the front of the load path.

* Show how using `--prefer-local` causes issues

Ideally bundler will consider default/stdlib gems when doing dependency resolution
to avoid duplication in the first place. this seems to break the pluginmanager.
Verify this happens in CI...

* Revert "Show how using `--prefer-local` causes issues"

This reverts commit 5a3b2bb.

* fix rebase error
mergify bot pushed a commit that referenced this pull request Dec 10, 2025
* Remove duplicate gems when producting logstash artifacts

Bundler is used to manage a gem environment that is shipped with logstash
artifacts. By default, bundler will install newer/duplicate gems than shipped
with ruby distributions (in logstash's case jruby). Duplicate gems in the
shipped environment can cause issues with code loading with ambiguous gem specs
or gem activation issues. This commit adds a step to compute the duplicate gems
managed with bundler (and therefore direct/transitive dependencies of
logstash/plugins) and *removes* copies shipped with jruby. Note that there are
two locations to do the deduplication at. Both the stdlib gems as well as what
jruby refers to as "bundled" gems. The existing pattern for excluding files from
artifacts is used to implement the deduplication.

* only remove gemspecs for duplicated stdlib gems

* Make deduplicate a separate rake task and prevent gradle errors

Deduplication should happen as a depenedency of installing default gems. In the
current workflow we have a top level gradle task for packaging which calls out
to rake. Rake then invokes a *separate* gradle process. When we modify the jruby
default, when the separate gradle process goes to check of jruby is installed,
it sees a modified jruby and tries to re-install. We work around this by
changing how gradle detects if jruby is required to be installed.

* Ensure the set of gems tested at unit level matches packages

This commit adds the installDefaultGems task to the unit test tasks. This
ensures that the gem env tested at the unit level matches the deduplicated one
at the integration/acceptance level. Takes over #18330

* WIP: Use logstash_gem_home for gemInstaller

This commit changes gemInstaller such that the centralized gem_home from
Logstash::Environment is used instead of hard coding in a fragile path. The
tests were the only consumer of the optional positional parameter in the
`install` class method.

* Fix gem env setup for ruby unit tests

After some deeeeeeeep diving into comparing the state of running logstash from a
compiled artifact vs the unit tests i finally figured out that the use of the
bundler `setup!` method in unit tests is imcompatible with a couple of tests.
Specifically that method puts bundler installed gems ahead of the standard lib
gems in the load path. This commit solves that by re-positioning the standarl
lib back to the front of the load path.

* Show how using `--prefer-local` causes issues

Ideally bundler will consider default/stdlib gems when doing dependency resolution
to avoid duplication in the first place. this seems to break the pluginmanager.
Verify this happens in CI...

* Revert "Show how using `--prefer-local` causes issues"

This reverts commit 5a3b2bb.

* fix rebase error

(cherry picked from commit e08abb8)
mergify bot pushed a commit that referenced this pull request Dec 10, 2025
* Remove duplicate gems when producting logstash artifacts

Bundler is used to manage a gem environment that is shipped with logstash
artifacts. By default, bundler will install newer/duplicate gems than shipped
with ruby distributions (in logstash's case jruby). Duplicate gems in the
shipped environment can cause issues with code loading with ambiguous gem specs
or gem activation issues. This commit adds a step to compute the duplicate gems
managed with bundler (and therefore direct/transitive dependencies of
logstash/plugins) and *removes* copies shipped with jruby. Note that there are
two locations to do the deduplication at. Both the stdlib gems as well as what
jruby refers to as "bundled" gems. The existing pattern for excluding files from
artifacts is used to implement the deduplication.

* only remove gemspecs for duplicated stdlib gems

* Make deduplicate a separate rake task and prevent gradle errors

Deduplication should happen as a depenedency of installing default gems. In the
current workflow we have a top level gradle task for packaging which calls out
to rake. Rake then invokes a *separate* gradle process. When we modify the jruby
default, when the separate gradle process goes to check of jruby is installed,
it sees a modified jruby and tries to re-install. We work around this by
changing how gradle detects if jruby is required to be installed.

* Ensure the set of gems tested at unit level matches packages

This commit adds the installDefaultGems task to the unit test tasks. This
ensures that the gem env tested at the unit level matches the deduplicated one
at the integration/acceptance level. Takes over #18330

* WIP: Use logstash_gem_home for gemInstaller

This commit changes gemInstaller such that the centralized gem_home from
Logstash::Environment is used instead of hard coding in a fragile path. The
tests were the only consumer of the optional positional parameter in the
`install` class method.

* Fix gem env setup for ruby unit tests

After some deeeeeeeep diving into comparing the state of running logstash from a
compiled artifact vs the unit tests i finally figured out that the use of the
bundler `setup!` method in unit tests is imcompatible with a couple of tests.
Specifically that method puts bundler installed gems ahead of the standard lib
gems in the load path. This commit solves that by re-positioning the standarl
lib back to the front of the load path.

* Show how using `--prefer-local` causes issues

Ideally bundler will consider default/stdlib gems when doing dependency resolution
to avoid duplication in the first place. this seems to break the pluginmanager.
Verify this happens in CI...

* Revert "Show how using `--prefer-local` causes issues"

This reverts commit 5a3b2bb.

* fix rebase error

(cherry picked from commit e08abb8)
mergify bot pushed a commit that referenced this pull request Dec 10, 2025
* Remove duplicate gems when producting logstash artifacts

Bundler is used to manage a gem environment that is shipped with logstash
artifacts. By default, bundler will install newer/duplicate gems than shipped
with ruby distributions (in logstash's case jruby). Duplicate gems in the
shipped environment can cause issues with code loading with ambiguous gem specs
or gem activation issues. This commit adds a step to compute the duplicate gems
managed with bundler (and therefore direct/transitive dependencies of
logstash/plugins) and *removes* copies shipped with jruby. Note that there are
two locations to do the deduplication at. Both the stdlib gems as well as what
jruby refers to as "bundled" gems. The existing pattern for excluding files from
artifacts is used to implement the deduplication.

* only remove gemspecs for duplicated stdlib gems

* Make deduplicate a separate rake task and prevent gradle errors

Deduplication should happen as a depenedency of installing default gems. In the
current workflow we have a top level gradle task for packaging which calls out
to rake. Rake then invokes a *separate* gradle process. When we modify the jruby
default, when the separate gradle process goes to check of jruby is installed,
it sees a modified jruby and tries to re-install. We work around this by
changing how gradle detects if jruby is required to be installed.

* Ensure the set of gems tested at unit level matches packages

This commit adds the installDefaultGems task to the unit test tasks. This
ensures that the gem env tested at the unit level matches the deduplicated one
at the integration/acceptance level. Takes over #18330

* WIP: Use logstash_gem_home for gemInstaller

This commit changes gemInstaller such that the centralized gem_home from
Logstash::Environment is used instead of hard coding in a fragile path. The
tests were the only consumer of the optional positional parameter in the
`install` class method.

* Fix gem env setup for ruby unit tests

After some deeeeeeeep diving into comparing the state of running logstash from a
compiled artifact vs the unit tests i finally figured out that the use of the
bundler `setup!` method in unit tests is imcompatible with a couple of tests.
Specifically that method puts bundler installed gems ahead of the standard lib
gems in the load path. This commit solves that by re-positioning the standarl
lib back to the front of the load path.

* Show how using `--prefer-local` causes issues

Ideally bundler will consider default/stdlib gems when doing dependency resolution
to avoid duplication in the first place. this seems to break the pluginmanager.
Verify this happens in CI...

* Revert "Show how using `--prefer-local` causes issues"

This reverts commit 5a3b2bb.

* fix rebase error

(cherry picked from commit e08abb8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-all Automated backport with mergify to all the active branches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants