logstash-devutils 2.0.4-java → 2.3.0-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d34e698203e399da96e7498c7582dd598768b295943c23ee4030affcf1ca4f6
4
- data.tar.gz: 2f92614519c0663e305f5c346cce5a6438eed765b4e429f814fc3317b91031a0
3
+ metadata.gz: 5ef657a14adf95e2a926763dc1fee0ad934eb0b94671cb91c25fa64401de14ad
4
+ data.tar.gz: 23c0a0173b7ca9f8e6e2dde1c388a426c28630ea50f56848b660c5f59a8fbfb9
5
5
  SHA512:
6
- metadata.gz: 7fb5f164892910850f3240d31461de6b357820871f90845c2815f6320ef4599b9be2e9c8bb902aa0229de29b07a5c745599283d675f94d9048ad22eb355063bb
7
- data.tar.gz: 71db99f7105959af5e641b75cfb55306dbb2afe677f352a4f85ccb6fabb0e0c074d64137b0fd2d001b2c2165346c63d7242b3f5894d31acc5487052de976fcab
6
+ metadata.gz: 51f2121d23bdd714670035b0eb92cb134cb4a1ee424408974303b2ea272bc804654df8045a2a77a0529db8da209cedee2f4632c7be3ab645ad7d84044010fd60
7
+ data.tar.gz: 8b8341622d83cf83a93bbc0d9cfd6674d7d9e39da0bcba4690873dc1047ef33d0587985fae3b4c380b100a5aef2abc3b19a34e9b6f0ac79b933df70a44204696
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 2.3.0
2
+ - Introduce `be_a_logstash_timestamp_equivalent_to` RSpec matcher to compare LogStash::Timestamp [#99](https://github.com/elastic/logstash-devutils/pull/99)
3
+
4
+ ## 2.2.1
5
+ - Fixed `LogStashHelpers#sample` to work with pipelines whose filters add, clone, and cancel events.
6
+
7
+ ## 2.2.0
8
+ - Add `allowed_lag` config for shared input interruptiblity spec
9
+
10
+ ## 2.1.0
11
+ - Remove ruby pipeline dependency
12
+
1
13
  ## 2.0.4
2
14
  - Fix: avoid double registering filters on `sample` spec helper
3
15
 
@@ -16,15 +28,15 @@
16
28
  - [BREAKING] changes:
17
29
  * `plugin_input` helper no longer works - simply fails with a not implemented error
18
30
  * `type` and `tags` helpers have no effect - they will print a deprecation warning
19
- * using gem **insist** is discouraged and has to be pulled in manually
31
+ * using gem **insist** is discouraged and has to be pulled in manually
20
32
  (in *plugin.gemspec* `add_development_dependency 'insist'` and `require "insist"`)
21
33
  * shared examples need to be explicitly required, as they are not re-used that much
22
34
  (in spec_helper.rb `require "logstash/devutils/rspec/shared_examples"'`)
23
35
  * `input` helper now yields a Queue-like collection (with `Queue#pop` blocking semantics)
24
- with a default timeout polling mechanism to guard against potential dead-locks
36
+ with a default timeout polling mechanism to guard against potential dead-locks
25
37
 
26
38
  ## 1.3.6
27
- - Revert the removal (e.g. add back) of the log4j spec helper. It is still needed for 5.x builds.
39
+ - Revert the removal (e.g. add back) of the log4j spec helper. It is still needed for 5.x builds.
28
40
 
29
41
  ## 1.3.5
30
42
  - Fix spec helper method `input` generating an invalid `output_func` that returned `nil` instead of an array
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)
@@ -73,7 +93,11 @@ module LogStashHelper
73
93
  # flush makes sure to empty any buffered events in the filter
74
94
  pipeline.flush_filters(:final => true) { |flushed_event| results << flushed_event }
75
95
 
76
- 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
77
101
  end
78
102
 
79
103
  # starting at logstash-core 5.3 an initialized pipeline need to be closed
@@ -83,7 +107,7 @@ module LogStashHelper
83
107
 
84
108
  subject { results.length > 1 ? results : results.first }
85
109
 
86
- it("when processed", &block)
110
+ it("processes events as specified", &block)
87
111
  end
88
112
  end # def sample
89
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
@@ -38,6 +38,16 @@ else
38
38
  LogStash::Logging::Logger::configure_logging('ERROR')
39
39
  end
40
40
 
41
+ RSpec::Matchers.define :be_a_logstash_timestamp_equivalent_to do |expected|
42
+ # use the Timestamp compare to avoid suffering of precision loss of time format
43
+ expected = LogStash::Timestamp.new(expected) unless expected.kind_of?(LogStash::Timestamp)
44
+ description { "be a LogStash::Timestamp equivalent to #{expected}" }
45
+
46
+ match do |actual|
47
+ actual.kind_of?(LogStash::Timestamp) && actual == expected
48
+ end
49
+ end
50
+
41
51
  RSpec.configure do |config|
42
52
  # for now both include and extend are required because the newly refactored "input" helper method need to be visible in a "it" block
43
53
  # and this is only possible by calling include on LogStashHelper
@@ -57,4 +67,3 @@ RSpec.configure do |config|
57
67
  # --seed 1234
58
68
  config.order = :random
59
69
  end
60
-
@@ -1,4 +1,3 @@
1
- require "logstash/pipeline"
2
1
  require "logstash/java_pipeline"
3
2
 
4
3
  module LogStash
@@ -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.4"
7
+ spec.version = "2.3.0"
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.4
4
+ version: 2.3.0
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-07 00:00:00.000000000 Z
11
+ date: 2021-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -191,8 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
191
  - !ruby/object:Gem::Version
192
192
  version: '0'
193
193
  requirements: []
194
- rubyforge_project:
195
- rubygems_version: 2.6.13
194
+ rubygems_version: 3.1.6
196
195
  signing_key:
197
196
  specification_version: 4
198
197
  summary: An assortment of tooling/libraries to make Logstash plugin development and