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 +4 -4
- data/CHANGELOG.md +15 -3
- data/Rakefile +1 -0
- data/lib/logstash/devutils/rspec/logstash_helpers.rb +28 -4
- data/lib/logstash/devutils/rspec/shared_examples.rb +5 -2
- data/lib/logstash/devutils/rspec/spec_helper.rb +10 -1
- data/lib/logstash/test_pipeline.rb +0 -1
- data/logstash-devutils.gemspec +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ef657a14adf95e2a926763dc1fee0ad934eb0b94671cb91c25fa64401de14ad
|
4
|
+
data.tar.gz: 23c0a0173b7ca9f8e6e2dde1c388a426c28630ea50f56848b660c5f59a8fbfb9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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,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
|
-
|
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
|
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
|
-
|
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("
|
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
|
-
|
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
|
-
|
data/logstash-devutils.gemspec
CHANGED
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
|
+
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:
|
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
|
-
|
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
|