From 806c8a1faae6e6384ed5fe22929998f2bf7b2a9c Mon Sep 17 00:00:00 2001 From: Joao Duarte Date: Wed, 18 Mar 2020 11:42:11 +0000 Subject: [PATCH] set helper pipeline workers to 1 this removes potential race conditions and makes testing logic easier by removing concurrency from the filter+output pipeline stage --- CHANGELOG.md | 3 +++ lib/logstash/devutils/rspec/logstash_helpers.rb | 8 +++++++- logstash-devutils.gemspec | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33a72bc..0767382 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2.0.2 + - Set number of pipeline workers to 1 in helper pipelines to facilitate plugin testing + ## 2.0.0 - Reinvented helpers using Java pipeline, only LS >= 6.x (JRuby >= 9.1) is supported. - [BREAKING] changes: diff --git a/lib/logstash/devutils/rspec/logstash_helpers.rb b/lib/logstash/devutils/rspec/logstash_helpers.rb index e0a651a..f26110f 100644 --- a/lib/logstash/devutils/rspec/logstash_helpers.rb +++ b/lib/logstash/devutils/rspec/logstash_helpers.rb @@ -52,6 +52,12 @@ def tags(*tags) deprecated "tags(#{tags.inspect}) - let(:default_tags) are not used" end + def default_pipeline_settings(hash = {}) + settings = ::LogStash::SETTINGS.clone + settings.set_value("pipeline.workers", 1) + settings + end + def sample(sample_event, &block) name = sample_event.is_a?(String) ? sample_event : LogStash::Json.dump(sample_event) name = name[0..50] + "..." if name.length > 50 @@ -144,7 +150,7 @@ def new_pipeline_from_string(config_string, pipeline_id: :main, test_sink: {}) new_pipeline(config_parts, pipeline_id) end - def new_pipeline(config_parts, pipeline_id = :main, settings = ::LogStash::SETTINGS.clone) + def new_pipeline(config_parts, pipeline_id = :main, settings = default_pipeline_settings()) pipeline_config = LogStash::Config::PipelineConfig.new(LogStash::Config::Source::Local, pipeline_id, config_parts, settings) TestPipeline.new(pipeline_config) end diff --git a/logstash-devutils.gemspec b/logstash-devutils.gemspec index b82b1d1..0c5e4e4 100644 --- a/logstash-devutils.gemspec +++ b/logstash-devutils.gemspec @@ -4,7 +4,7 @@ Gem::Specification.new do |spec| files = %x{git ls-files}.split("\n") spec.name = "logstash-devutils" - spec.version = "2.0.1" + spec.version = "2.0.2" spec.license = "Apache-2.0" spec.authors = ["Elastic"] spec.email = "info@elastic.co"