logstash-core 2.0.0.beta1-java → 2.0.0.beta2-java

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of logstash-core might be problematic. Click here for more details.

@@ -77,6 +77,10 @@ en:
77
77
  use to validate logstash's configuration before you choose
78
78
  to restart a running system.
79
79
  configuration:
80
+ obsolete: >-
81
+ The setting `%{name}` in plugin `%{plugin}` is obsolete and is no
82
+ longer available. %{extra} If you have any questions about this, you
83
+ are invited to visit https://discuss.elastic.co/c/logstash and ask.
80
84
  file-not-found: |-
81
85
  No config files found: %{path}
82
86
  Can you make sure this path is a logstash config file?
@@ -23,6 +23,8 @@ Gem::Specification.new do |gem|
23
23
  gem.add_runtime_dependency "clamp", "~> 0.6.5" #(MIT license) for command line args/flags
24
24
  gem.add_runtime_dependency "filesize", "0.0.4" #(MIT license) for :bytes config validator
25
25
  gem.add_runtime_dependency "gems", "~> 0.8.3" #(MIT license)
26
+ gem.add_runtime_dependency "concurrent-ruby", "~> 0.9.1"
27
+ gem.add_runtime_dependency "jruby-openssl", ">= 0.9.11" # Required to support TLSv1.2
26
28
 
27
29
  # TODO(sissel): Treetop 1.5.x doesn't seem to work well, but I haven't
28
30
  # investigated what the cause might be. -Jordan
@@ -37,7 +39,7 @@ Gem::Specification.new do |gem|
37
39
 
38
40
  if RUBY_PLATFORM == 'java'
39
41
  gem.platform = RUBY_PLATFORM
40
- gem.add_runtime_dependency "jrjackson", "~> 0.2.9" #(Apache 2.0 license)
42
+ gem.add_runtime_dependency "jrjackson", "~> 0.3.5" #(Apache 2.0 license)
41
43
  else
42
44
  gem.add_runtime_dependency "oj" #(MIT-style license)
43
45
  end
@@ -0,0 +1,123 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+ require "logstash/config/cpu_core_strategy"
4
+
5
+ describe LogStash::Config::CpuCoreStrategy do
6
+
7
+ before do
8
+ allow(LogStash::Config::Defaults).to receive(:cpu_cores).and_return(cores)
9
+ end
10
+
11
+ context 'when the machine has 6 cores' do
12
+ let(:cores) { 6 }
13
+
14
+ it ".maximum should return 6" do
15
+ expect(described_class.maximum).to eq(6)
16
+ end
17
+
18
+ it ".fifty_percent should return 3" do
19
+ expect(described_class.fifty_percent).to eq(3)
20
+ end
21
+
22
+ it ".seventy_five_percent should return 4" do
23
+ expect(described_class.seventy_five_percent).to eq(4)
24
+ end
25
+
26
+ it ".twenty_five_percent should return 1" do
27
+ expect(described_class.twenty_five_percent).to eq(1)
28
+ end
29
+
30
+ it ".max_minus_one should return 5" do
31
+ expect(described_class.max_minus_one).to eq(5)
32
+ end
33
+
34
+ it ".max_minus_two should return 4" do
35
+ expect(described_class.max_minus_two).to eq(4)
36
+ end
37
+ end
38
+
39
+ context 'when the machine has 4 cores' do
40
+ let(:cores) { 4 }
41
+
42
+ it ".maximum should return 4" do
43
+ expect(described_class.maximum).to eq(4)
44
+ end
45
+
46
+ it ".fifty_percent should return 2" do
47
+ expect(described_class.fifty_percent).to eq(2)
48
+ end
49
+
50
+ it ".seventy_five_percent should return 3" do
51
+ expect(described_class.seventy_five_percent).to eq(3)
52
+ end
53
+
54
+ it ".twenty_five_percent should return 1" do
55
+ expect(described_class.twenty_five_percent).to eq(1)
56
+ end
57
+
58
+ it ".max_minus_one should return 3" do
59
+ expect(described_class.max_minus_one).to eq(3)
60
+ end
61
+
62
+ it ".max_minus_two should return 2" do
63
+ expect(described_class.max_minus_two).to eq(2)
64
+ end
65
+ end
66
+
67
+ context 'when the machine has 2 cores' do
68
+ let(:cores) { 2 }
69
+
70
+ it ".maximum should return 2" do
71
+ expect(described_class.maximum).to eq(2)
72
+ end
73
+
74
+ it ".fifty_percent should return 1" do
75
+ expect(described_class.fifty_percent).to eq(1)
76
+ end
77
+
78
+ it ".seventy_five_percent should return 1" do
79
+ expect(described_class.seventy_five_percent).to eq(1)
80
+ end
81
+
82
+ it ".twenty_five_percent should return 1" do
83
+ expect(described_class.twenty_five_percent).to eq(1)
84
+ end
85
+
86
+ it ".max_minus_one should return 1" do
87
+ expect(described_class.max_minus_one).to eq(1)
88
+ end
89
+
90
+ it ".max_minus_two should return 1" do
91
+ expect(described_class.max_minus_two).to eq(1)
92
+ end
93
+ end
94
+
95
+ context 'when the machine has 1 core' do
96
+ let(:cores) { 1 }
97
+
98
+ it ".maximum should return 1" do
99
+ expect(described_class.maximum).to eq(1)
100
+ end
101
+
102
+ it ".fifty_percent should return 1" do
103
+ expect(described_class.fifty_percent).to eq(1)
104
+ end
105
+
106
+ it ".seventy_five_percent should return 1" do
107
+ expect(described_class.seventy_five_percent).to eq(1)
108
+ end
109
+
110
+ it ".twenty_five_percent should return 1" do
111
+ expect(described_class.twenty_five_percent).to eq(1)
112
+ end
113
+
114
+ it ".max_minus_one should return 1" do
115
+ expect(described_class.max_minus_one).to eq(1)
116
+ end
117
+
118
+ it ".max_minus_two should return 1" do
119
+ expect(described_class.max_minus_two).to eq(1)
120
+ end
121
+ end
122
+
123
+ end
@@ -0,0 +1,10 @@
1
+ # encoding: utf-8
2
+ require "spec_helper"
3
+ require "logstash/config/defaults"
4
+
5
+ describe LogStash::Config::Defaults do
6
+ it ".cpu_cores should return a positive integer" do
7
+ expect(described_class.cpu_cores.nil?).to be false
8
+ expect(described_class.cpu_cores.zero?).to be false
9
+ end
10
+ end
@@ -97,4 +97,58 @@ describe LogStash::Config::Mixin do
97
97
  expect(clone.password.value).to(be == secret)
98
98
  end
99
99
  end
100
+
101
+ describe "obsolete settings" do
102
+ let(:plugin_class) do
103
+ Class.new(LogStash::Inputs::Base) do
104
+ include LogStash::Config::Mixin
105
+ config_name "example"
106
+ config :foo, :validate => :string, :obsolete => "This feature was removed."
107
+ end
108
+ end
109
+
110
+ context "when using an obsolete setting" do
111
+ it "should cause a configuration error" do
112
+ expect {
113
+ plugin_class.new("foo" => "hello")
114
+ }.to raise_error(LogStash::ConfigurationError)
115
+ end
116
+ end
117
+
118
+ context "when using an obsolete settings from the parent class" do
119
+ it "should cause a configuration error" do
120
+ expect {
121
+ plugin_class.new("debug" => true)
122
+ }.to raise_error(LogStash::ConfigurationError)
123
+ end
124
+ end
125
+
126
+ context "when not using an obsolete setting" do
127
+ it "should not cause a configuration error" do
128
+ expect {
129
+ plugin_class.new({})
130
+ }.not_to raise_error
131
+ end
132
+ end
133
+ end
134
+
135
+ context "#params" do
136
+ let(:plugin_class) do
137
+ Class.new(LogStash::Filters::Base) do
138
+ config_name "fake"
139
+ config :password, :validate => :password
140
+ config :bad, :validate => :string, :default => "my default", :obsolete => "not here"
141
+ end
142
+ end
143
+
144
+ subject { plugin_class.new({ "password" => "secret" }) }
145
+
146
+ it "should not return the obsolete options" do
147
+ expect(subject.params).not_to include("bad")
148
+ end
149
+
150
+ it "should include any other params" do
151
+ expect(subject.params).to include("password")
152
+ end
153
+ end
100
154
  end
@@ -50,6 +50,10 @@ describe LogStash::Event do
50
50
  expect(subject.sprintf("%{+%s}")).to eq("1356998400")
51
51
  end
52
52
 
53
+ it "should work if there is no fieldref in the string" do
54
+ expect(subject.sprintf("bonjour")).to eq("bonjour")
55
+ end
56
+
53
57
  it "should raise error when formatting %{+%s} when @timestamp field is missing" do
54
58
  str = "hello-%{+%s}"
55
59
  subj = subject.clone
@@ -100,6 +104,10 @@ describe LogStash::Event do
100
104
  expect(subject.sprintf("%{[j][k3]}")).to eq("{\"4\":\"m\"}")
101
105
  end
102
106
 
107
+ it "should not strip last character" do
108
+ expect(subject.sprintf("%{type}%{message}|")).to eq("sprintfhello world|")
109
+ end
110
+
103
111
  context "#encoding" do
104
112
  it "should return known patterns as UTF-8" do
105
113
  expect(subject.sprintf("%{message}").encoding).to eq(Encoding::UTF_8)
@@ -11,7 +11,7 @@ class DummyInput < LogStash::Inputs::Base
11
11
  def run(queue)
12
12
  end
13
13
 
14
- def teardown
14
+ def close
15
15
  end
16
16
  end
17
17
 
@@ -27,7 +27,7 @@ class DummyCodec < LogStash::Codecs::Base
27
27
  event
28
28
  end
29
29
 
30
- def teardown
30
+ def close
31
31
  end
32
32
  end
33
33
 
@@ -35,11 +35,11 @@ class DummyOutput < LogStash::Outputs::Base
35
35
  config_name "dummyoutput"
36
36
  milestone 2
37
37
 
38
- attr_reader :num_teardowns
38
+ attr_reader :num_closes
39
39
 
40
40
  def initialize(params={})
41
41
  super
42
- @num_teardowns = 0
42
+ @num_closes = 0
43
43
  end
44
44
 
45
45
  def register
@@ -48,8 +48,8 @@ class DummyOutput < LogStash::Outputs::Base
48
48
  def receive(event)
49
49
  end
50
50
 
51
- def teardown
52
- @num_teardowns += 1
51
+ def close
52
+ @num_closes += 1
53
53
  end
54
54
  end
55
55
 
@@ -59,7 +59,7 @@ end
59
59
 
60
60
  describe LogStash::Pipeline do
61
61
 
62
- context "teardown" do
62
+ context "close" do
63
63
 
64
64
  before(:each) do
65
65
  allow(LogStash::Plugin).to receive(:lookup).with("input", "dummyinput").and_return(DummyInput)
@@ -93,24 +93,24 @@ context "teardown" do
93
93
  eos
94
94
  }
95
95
 
96
- context "output teardown" do
97
- it "should call teardown of output without output-workers" do
96
+ context "output close" do
97
+ it "should call close of output without output-workers" do
98
98
  pipeline = TestPipeline.new(test_config_without_output_workers)
99
99
  pipeline.run
100
100
 
101
101
  expect(pipeline.outputs.size ).to eq(1)
102
102
  expect(pipeline.outputs.first.worker_plugins.size ).to eq(1)
103
- expect(pipeline.outputs.first.worker_plugins.first.num_teardowns ).to eq(1)
103
+ expect(pipeline.outputs.first.worker_plugins.first.num_closes ).to eq(1)
104
104
  end
105
105
 
106
- it "should call output teardown correctly with output workers" do
106
+ it "should call output close correctly with output workers" do
107
107
  pipeline = TestPipeline.new(test_config_with_output_workers)
108
108
  pipeline.run
109
109
 
110
110
  expect(pipeline.outputs.size ).to eq(1)
111
- expect(pipeline.outputs.first.num_teardowns).to eq(0)
111
+ expect(pipeline.outputs.first.num_closes).to eq(0)
112
112
  pipeline.outputs.first.worker_plugins.each do |plugin|
113
- expect(plugin.num_teardowns ).to eq(1)
113
+ expect(plugin.num_closes ).to eq(1)
114
114
  end
115
115
  end
116
116
  end
@@ -24,7 +24,7 @@ describe LogStash::Filters::Base do
24
24
  end
25
25
 
26
26
  it "should provide class public API" do
27
- [:register, :filter, :multi_filter, :execute, :threadsafe?, :filter_matched, :filter?, :teardown].each do |method|
27
+ [:register, :filter, :multi_filter, :execute, :threadsafe?, :filter_matched, :filter?, :close].each do |method|
28
28
  expect(subject).to respond_to(method)
29
29
  end
30
30
  end
@@ -70,7 +70,6 @@ describe LogStash::Filters::NOOP do
70
70
  config <<-CONFIG
71
71
  filter {
72
72
  noop {
73
- type => "noop"
74
73
  add_tag => ["test"]
75
74
  }
76
75
  }
@@ -79,25 +78,19 @@ describe LogStash::Filters::NOOP do
79
78
  sample("type" => "noop") do
80
79
  insist { subject["tags"] } == ["test"]
81
80
  end
82
-
83
- sample("type" => "not_noop") do
84
- insist { subject["tags"] }.nil?
85
- end
86
81
  end
87
82
 
88
83
  describe "tags parsing with one tag" do
89
84
  config <<-CONFIG
90
85
  filter {
91
86
  noop {
92
- type => "noop"
93
- tags => ["t1"]
94
87
  add_tag => ["test"]
95
88
  }
96
89
  }
97
90
  CONFIG
98
91
 
99
92
  sample("type" => "noop") do
100
- insist { subject["tags"] }.nil?
93
+ insist { subject["tags"] } == ["test"]
101
94
  end
102
95
 
103
96
  sample("type" => "noop", "tags" => ["t1", "t2"]) do
@@ -109,19 +102,17 @@ describe LogStash::Filters::NOOP do
109
102
  config <<-CONFIG
110
103
  filter {
111
104
  noop {
112
- type => "noop"
113
- tags => ["t1", "t2"]
114
105
  add_tag => ["test"]
115
106
  }
116
107
  }
117
108
  CONFIG
118
109
 
119
110
  sample("type" => "noop") do
120
- insist { subject["tags"] }.nil?
111
+ insist { subject["tags"] } == ["test"]
121
112
  end
122
113
 
123
114
  sample("type" => "noop", "tags" => ["t1"]) do
124
- insist { subject["tags"] } == ["t1"]
115
+ insist { subject["tags"] } == ["t1", "test"]
125
116
  end
126
117
 
127
118
  sample("type" => "noop", "tags" => ["t1", "t2"]) do
@@ -133,62 +124,10 @@ describe LogStash::Filters::NOOP do
133
124
  end
134
125
  end
135
126
 
136
- describe "exclude_tags with 1 tag" do
137
- config <<-CONFIG
138
- filter {
139
- noop {
140
- type => "noop"
141
- tags => ["t1"]
142
- add_tag => ["test"]
143
- exclude_tags => ["t2"]
144
- }
145
- }
146
- CONFIG
147
-
148
- sample("type" => "noop") do
149
- insist { subject["tags"] }.nil?
150
- end
151
-
152
- sample("type" => "noop", "tags" => ["t1"]) do
153
- insist { subject["tags"] } == ["t1", "test"]
154
- end
155
-
156
- sample("type" => "noop", "tags" => ["t1", "t2"]) do
157
- insist { subject["tags"] } == ["t1", "t2"]
158
- end
159
- end
160
-
161
- describe "exclude_tags with >1 tags" do
162
- config <<-CONFIG
163
- filter {
164
- noop {
165
- type => "noop"
166
- tags => ["t1"]
167
- add_tag => ["test"]
168
- exclude_tags => ["t2", "t3"]
169
- }
170
- }
171
- CONFIG
172
-
173
- sample("type" => "noop", "tags" => ["t1", "t2", "t4"]) do
174
- insist { subject["tags"] } == ["t1", "t2", "t4"]
175
- end
176
-
177
- sample("type" => "noop", "tags" => ["t1", "t3", "t4"]) do
178
- insist { subject["tags"] } == ["t1", "t3", "t4"]
179
- end
180
-
181
- sample("type" => "noop", "tags" => ["t1", "t4", "t5"]) do
182
- insist { subject["tags"] } == ["t1", "t4", "t5", "test"]
183
- end
184
- end
185
-
186
127
  describe "remove_tag" do
187
128
  config <<-CONFIG
188
129
  filter {
189
130
  noop {
190
- type => "noop"
191
- tags => ["t1"]
192
131
  remove_tag => ["t2", "t3"]
193
132
  }
194
133
  }
@@ -223,8 +162,6 @@ describe LogStash::Filters::NOOP do
223
162
  config <<-CONFIG
224
163
  filter {
225
164
  noop {
226
- type => "noop"
227
- tags => ["t1"]
228
165
  remove_tag => ["%{blackhole}"]
229
166
  }
230
167
  }
@@ -245,7 +182,6 @@ describe LogStash::Filters::NOOP do
245
182
  config <<-CONFIG
246
183
  filter {
247
184
  noop {
248
- type => "noop"
249
185
  remove_field => ["t2", "t3"]
250
186
  }
251
187
  }
@@ -271,7 +207,6 @@ describe LogStash::Filters::NOOP do
271
207
  config <<-CONFIG
272
208
  filter {
273
209
  noop {
274
- type => "noop"
275
210
  remove_field => ["[t1][t2]"]
276
211
  }
277
212
  }
@@ -288,7 +223,6 @@ describe LogStash::Filters::NOOP do
288
223
  config <<-CONFIG
289
224
  filter {
290
225
  noop {
291
- type => "noop"
292
226
  remove_field => ["[t1][0]"]
293
227
  }
294
228
  }
@@ -304,7 +238,6 @@ describe LogStash::Filters::NOOP do
304
238
  config <<-CONFIG
305
239
  filter {
306
240
  noop {
307
- type => "noop"
308
241
  remove_field => ["%{blackhole}"]
309
242
  }
310
243
  }