Skip to content

ispec: fix cross-spec leak from fatal error integration specs#13002

Merged
yaauie merged 1 commit intoelastic:masterfrom
yaauie:fix-cross-spec-leak-in-pq-variant-specs
Jun 21, 2021
Merged

ispec: fix cross-spec leak from fatal error integration specs#13002
yaauie merged 1 commit intoelastic:masterfrom
yaauie:fix-cross-spec-leak-in-pq-variant-specs

Conversation

@yaauie
Copy link
Member

@yaauie yaauie commented Jun 17, 2021

Release notes

[rn:skip]

What does this PR do?

FIxes cross-spec leak from "fatal error" integration specs

Because the "Fatal Error" specs specifically inject fatal errors during
execution, and do so by reacting to a "poison" event, the fatal error prevents
the poison event from being ACK'd in the underlying queue.

By specifying a one-off temporary data directory in these specs and cleaning up
after ourselves, we ensure that a PQ containing un-ACK'd events isn't leaked to
the next spec to run.

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

Resolves random flaky tests that were caused by being executed immediately after one of the "fatal error" tests.

In the following specific test run, the Test Logstash configuration expands environment variables in all plugin blocks spec immediately followed one of the "fatal error" specs, which had left a "poison" event containing the message "a fatal error". Since only the "fatal error" spec knew how to convert this message into an actual fatal error, the event was processed "normally". Unfortunately, the spec being executed didn't expect it to be there and its assertions failed.

14:28:29       1) Test Logstash configuration expands environment variables in all plugin blocks
14:28:29          Failure/Error: Unable to find matching line from backtrace
14:28:29          
14:28:29            expected: "74.125.176.147 - - [11/Sep/2014:21:50:37 +0000] \"GET /?flav=rss20 HTTP/1.1\" 200 29941 \"-\" \"FeedBurner/1.0 (http://www.FeedBurner.com)\" blah,environment_variables_are_evil"
14:28:29                 got: "a fatal error blah,environment_variables_are_evil74.125.176.147 - - [11/Sep/2014:21:50:37 +0000] \"G... 200 29941 \"-\" \"FeedBurner/1.0 (http://www.FeedBurner.com)\" blah,environment_variables_are_evil"
14:28:29          
14:28:29            (compared using ==)

Depending on what the next test to run validated, this "leak" may or may not end up breaking one of its unrelated assertions.

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

14:28:29       1) Test Logstash configuration expands environment variables in all plugin blocks
14:28:29          Failure/Error: Unable to find matching line from backtrace
14:28:29          
14:28:29            expected: "74.125.176.147 - - [11/Sep/2014:21:50:37 +0000] \"GET /?flav=rss20 HTTP/1.1\" 200 29941 \"-\" \"FeedBurner/1.0 (http://www.FeedBurner.com)\" blah,environment_variables_are_evil"
14:28:29                 got: "a fatal error blah,environment_variables_are_evil74.125.176.147 - - [11/Sep/2014:21:50:37 +0000] \"G... 200 29941 \"-\" \"FeedBurner/1.0 (http://www.FeedBurner.com)\" blah,environment_variables_are_evil"
14:28:29          
14:28:29            (compared using ==)

Related issues

Use cases

Screenshots

Logs

Because the "Fatal Error" specs specifically inject fatal errors during
execution, and do so by reacting to a "poison" event, the fatal error prevents
the poison event from being ACK'd in the underlying queue.

By specifying a one-off temporary data directory in these specs and cleaning up
after ourselves, we ensure that a PQ containing un-ACK'd events isn't leaked to
the next spec to run.
Copy link
Member

@jsvd jsvd left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@kares kares left a comment

Choose a reason for hiding this comment

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

❤️ so much, haven't thought about these consequences at all

@yaauie yaauie merged commit 6032e5f into elastic:master Jun 21, 2021
yaauie added a commit that referenced this pull request Jun 21, 2021
Because the "Fatal Error" specs specifically inject fatal errors during
execution, and do so by reacting to a "poison" event, the fatal error prevents
the poison event from being ACK'd in the underlying queue.

By specifying a one-off temporary data directory in these specs and cleaning up
after ourselves, we ensure that a PQ containing un-ACK'd events isn't leaked to
the next spec to run.

(cherry picked from commit 6032e5f)
@yaauie yaauie added the v7.14.0 label Jun 21, 2021
yaauie added a commit that referenced this pull request Jun 21, 2021
#13013)

Because the "Fatal Error" specs specifically inject fatal errors during
execution, and do so by reacting to a "poison" event, the fatal error prevents
the poison event from being ACK'd in the underlying queue.

By specifying a one-off temporary data directory in these specs and cleaning up
after ourselves, we ensure that a PQ containing un-ACK'd events isn't leaked to
the next spec to run.

(cherry picked from commit 6032e5f)
kares added a commit to kares/logstash that referenced this pull request Jul 1, 2021
* 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)
  ...
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.

4 participants