logstash-devutils 2.0.2-java → 2.2.1-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bea3aed46049f9e213c68ff3f0271bdb6f32253f59368a5dbec6c94988c99693
4
- data.tar.gz: af4b9f342648b1dc8c346f450eeb311a64a9985847e069b1978cbe7ea1175c87
3
+ metadata.gz: 5b3032f571207f629539ec5d700a503822fcdc926f99cf85b3a591ec1917a80d
4
+ data.tar.gz: 5f8ba35dd80a02f8a329f74b28c18ec3d8100eab6fd50c71ac01061e8ff7df20
5
5
  SHA512:
6
- metadata.gz: deba0abca9bae4f1650874649e4be4e58e1ed7e1f2e32e98dca578f01aafb3b217a552644786b7d687767c393e23b489eb0ae1e795f3774a4b8de8f28a39c49d
7
- data.tar.gz: 3e35bb4b9e1c4c11d83d5d1ce65751339c10374706e19442241fd2b4ae957c6ce0bf3a61f85a29778affc1efb94dfdf52538d6b80c7996eccb0f2d18424e30e7
6
+ metadata.gz: ae858d1af44e21974fab7c43b8b90b8311e9e765493e67ecbfd4e6f0cbb3e39be8b647a16e083edfce109352115204f5ed92403c5b58edf3d5b6fcda92aa11f2
7
+ data.tar.gz: 0c70d08d421648b23f7004a2aa2eb7e6c1d3790a580ee0827eed44cad3b3417e4f56b232a496029e79bd9e6ea6684be60545121ad14f7c9b4b55e69d2d2ae52f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,19 @@
1
+ ## 2.2.1
2
+ - Fixed `LogStashHelpers#sample` to work with pipelines whose filters add, clone, and cancel events.
3
+
4
+ ## 2.2.0
5
+ - Add `allowed_lag` config for shared input interruptiblity spec
6
+
7
+ ## 2.1.0
8
+ - Remove ruby pipeline dependency
9
+
10
+ ## 2.0.4
11
+ - Fix: avoid double registering filters on `sample` spec helper
12
+
13
+ ## 2.0.3
14
+ - Fix: add missing `events` method to QueuedBatchDelegator, which was causing test failures
15
+ after https://github.com/elastic/logstash/pull/11737 was committed.
16
+
1
17
  ## 2.0.2
2
18
  - Fix: add plain codec as runtime dependency for TestPipeline helper
3
19
 
data/Gemfile CHANGED
@@ -3,4 +3,5 @@ gemspec
3
3
 
4
4
  if Dir.exist?(logstash_path = ENV["LOGSTASH_PATH"])
5
5
  gem 'logstash-core', path: "#{logstash_path}/logstash-core"
6
+ gem 'logstash-core-plugin-api', path: "#{logstash_path}/logstash-core-plugin-api"
6
7
  end
data/Rakefile CHANGED
@@ -1,2 +1,3 @@
1
1
  raise "only JRuby is supported" unless defined? JRUBY_VERSION
2
2
  require 'bundler/gem_tasks'
3
+ require 'logstash/devutils/rake'
@@ -1,6 +1,7 @@
1
1
  require "logstash/agent"
2
2
  require "logstash/event"
3
3
  require "logstash/test_pipeline"
4
+ require "logstash/outputs/test_sink"
4
5
 
5
6
  require "stud/try"
6
7
  require "rspec/expectations"
@@ -52,11 +53,30 @@ module LogStashHelper
52
53
  deprecated "tags(#{tags.inspect}) - let(:default_tags) are not used"
53
54
  end
54
55
 
55
- def sample(sample_event, &block)
56
+ ##
57
+ # Creates a single-example example group in the current rspec context to validate the results of filter operations.
58
+ # The current group is expected to use `LogStashHelpers#config` to provide a pipeline configuration.
59
+ #
60
+ # The provided block has access to an [Array] `results`, and also sets an unnamed `subject` that is either a
61
+ # single `LogStash::Event` or an `[Array[LogStash::Event]]` containing at least two entries.
62
+ #
63
+ # @param sample_event [String, #to_json]
64
+ # @param validation_source [:output, :queue]
65
+ # @yield creates an example with expectations provided by the block
66
+ # @return [void]
67
+ def sample(sample_event, validation_source: :output, &block)
68
+ validation_sources = [:output, :queue].freeze
69
+ fail(ArgumentError, "Unexpected source `#{validation_source.inspect}`, expected one of #{validation_sources.inspect}") unless validation_sources.include?(validation_source)
70
+
56
71
  name = sample_event.is_a?(String) ? sample_event : LogStash::Json.dump(sample_event)
57
72
  name = name[0..50] + "..." if name.length > 50
58
73
 
59
- describe "\"#{name}\"" do
74
+ describe name.inspect do
75
+ if validation_source == :output
76
+ let(:test_sink) { LogStash::Outputs::TestSink.new("release_on_close" => false, "store_events" => true) }
77
+ before { expect(LogStash::Outputs::TestSink).to receive(:new).and_return(test_sink) }
78
+ end
79
+
60
80
  let(:pipeline) { new_pipeline_from_string(config) }
61
81
  let(:event) do
62
82
  sample_event = [sample_event] unless sample_event.is_a?(Array)
@@ -67,14 +87,17 @@ module LogStashHelper
67
87
  end
68
88
 
69
89
  let(:results) do
70
- pipeline.filters.each(&:register)
71
-
90
+ # Java pipeline (since 6.1) registers filters from start_workers
72
91
  pipeline.run_with(event)
73
92
 
74
93
  # flush makes sure to empty any buffered events in the filter
75
94
  pipeline.flush_filters(:final => true) { |flushed_event| results << flushed_event }
76
95
 
77
- pipeline.filter_queue_client.processed_events
96
+ case validation_source
97
+ when :queue then pipeline.filter_queue_client.processed_events # legacy?
98
+ when :output then test_sink.event_store.to_a
99
+ else fail NotImplementedError("validation source `#{validation_source}` not implemented.")
100
+ end
78
101
  end
79
102
 
80
103
  # starting at logstash-core 5.3 an initialized pipeline need to be closed
@@ -84,7 +107,7 @@ module LogStashHelper
84
107
 
85
108
  subject { results.length > 1 ? results : results.first }
86
109
 
87
- it("when processed", &block)
110
+ it("processes events as specified", &block)
88
111
  end
89
112
  end # def sample
90
113
 
@@ -1,6 +1,10 @@
1
1
  require 'rspec/wait'
2
2
 
3
3
  RSpec.shared_examples "an interruptible input plugin" do
4
+ # why 3? 2 is not enough, 4 is too much..
5
+ # a plugin that is known to be slower can override
6
+ let(:allowed_lag) { 3 }
7
+
4
8
  describe "#stop" do
5
9
  let(:queue) { SizedQueue.new(20) }
6
10
  subject { described_class.new(config) }
@@ -14,8 +18,7 @@ RSpec.shared_examples "an interruptible input plugin" do
14
18
  expect(plugin_thread).to be_alive
15
19
  # now let's actually stop the plugin
16
20
  subject.do_stop
17
- # why 3? 2 is not enough, 4 is too much..
18
- wait(3).for { plugin_thread }.to_not be_alive
21
+ wait(allowed_lag).for { plugin_thread }.to_not be_alive
19
22
  end
20
23
  end
21
24
  end
@@ -29,7 +29,7 @@ if RUBY_VERSION < "2.3"
29
29
  raise LoadError.new("Ruby >= 2.3.0 or later is required. (You are running: " + RUBY_VERSION + ")")
30
30
  end
31
31
 
32
- if level = (ENV["TEST_DEBUG"] || ENV['LOGGER_LEVEL'])
32
+ if level = (ENV['LOG_LEVEL'] || ENV['LOGGER_LEVEL'] || ENV["TEST_DEBUG"])
33
33
  logger, level = level.split('=') # 'logstash.filters.grok=DEBUG'
34
34
  level, logger = logger, nil if level.nil? # only level given e.g. 'DEBUG'
35
35
  level = org.apache.logging.log4j.Level.toLevel(level, org.apache.logging.log4j.Level::WARN)
@@ -1,4 +1,3 @@
1
- require "logstash/pipeline"
2
1
  require "logstash/java_pipeline"
3
2
 
4
3
  module LogStash
@@ -151,6 +150,13 @@ module LogStash
151
150
  @delegate.to_java.filtered_size
152
151
  end
153
152
 
153
+ def events
154
+ @delegate.events.tap do |events|
155
+ # filters out rogue (cancelled) events
156
+ @event_tracker.filtered_events events
157
+ end
158
+ end
159
+
154
160
  # @override void merge(IRubyObject event);
155
161
  def merge(event)
156
162
  @delegate.merge(event)
@@ -4,7 +4,7 @@ Gem::Specification.new do |spec|
4
4
  files = %x{git ls-files}.split("\n")
5
5
 
6
6
  spec.name = "logstash-devutils"
7
- spec.version = "2.0.2"
7
+ spec.version = "2.2.1"
8
8
  spec.license = "Apache-2.0"
9
9
  spec.authors = ["Elastic"]
10
10
  spec.email = "info@elastic.co"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-devutils
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.2.1
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-18 00:00:00.000000000 Z
11
+ date: 2021-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -192,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
192
192
  version: '0'
193
193
  requirements: []
194
194
  rubyforge_project:
195
- rubygems_version: 2.7.10
195
+ rubygems_version: 2.6.13
196
196
  signing_key:
197
197
  specification_version: 4
198
198
  summary: An assortment of tooling/libraries to make Logstash plugin development and