logstash-devutils 2.0.2-java → 2.2.1-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 +16 -0
- data/Gemfile +1 -0
- data/Rakefile +1 -0
- data/lib/logstash/devutils/rspec/logstash_helpers.rb +29 -6
- data/lib/logstash/devutils/rspec/shared_examples.rb +5 -2
- data/lib/logstash/devutils/rspec/spec_helper.rb +1 -1
- data/lib/logstash/test_pipeline.rb +7 -1
- data/logstash-devutils.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5b3032f571207f629539ec5d700a503822fcdc926f99cf85b3a591ec1917a80d
|
4
|
+
data.tar.gz: 5f8ba35dd80a02f8a329f74b28c18ec3d8100eab6fd50c71ac01061e8ff7df20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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)
|
@@ -67,14 +87,17 @@ module LogStashHelper
|
|
67
87
|
end
|
68
88
|
|
69
89
|
let(:results) do
|
70
|
-
pipeline.filters
|
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
|
-
|
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("
|
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
|
-
|
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[
|
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)
|
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.
|
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:
|
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.
|
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
|