Skip to content

Commit 52104d2

Browse files
committed
Merge remote-tracking branch 'origin/feature/plugin-api-2_0'
2 parents 18e13dc + ccd4204 commit 52104d2

File tree

4 files changed

+38
-26
lines changed

4 files changed

+38
-26
lines changed

.travis.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
---
12
sudo: false
23
language: ruby
34
cache: bundler
45
rvm:
5-
- jruby-1.7.23
6-
script:
7-
- bundle exec rspec spec
6+
- jruby-1.7.25
7+
script:
8+
- bundle exec rspec spec
9+
jdk: oraclejdk8
10+
before_install:
11+
- git clone -b feature/event_interface https://github.com/elastic/logstash

Gemfile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
source 'https://rubygems.org'
2-
gemspec
2+
gemspec
3+
gem "logstash-core", :path => "./logstash/logstash-core"
4+
gem "logstash-core-plugin-api", :path => "./logstash/logstash-core-plugin-api"
5+
gem "logstash-core-event-java", :path => "./logstash/logstash-core-event-java"
6+
gem "logstash-devutils", :github => "elastic/logstash-devutils", :branch => "feature/plugin-api-2_0"
7+
gem "logstash-codec-json_lines", :github => "logstash-plugins/logstash-codec-json_lines", :branch => "feature/plugin-api-2_0"
8+
gem "logstash-codec-line", :github => "logstash-plugins/logstash-codec-line", :branch => "feature/plugin-api-2_0"
9+
gem "logstash-input-generator", :github => "logstash-plugins/logstash-input-generator", :branch => "feature/plugin-api-2_0"
10+
gem "logstash-codec-plain", :github => "logstash-plugins/logstash-codec-plain", :branch => "feature/plugin-api-2_0"

logstash-output-file.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
2020
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
2121

2222
# Gem dependencies
23-
s.add_runtime_dependency "logstash-core-plugin-api", "~> 1.0"
23+
s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
2424
s.add_runtime_dependency 'logstash-codec-json_lines'
2525
s.add_runtime_dependency 'logstash-codec-line'
2626

spec/outputs/file_spec.rb

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434

3535
# Now check all events for order and correctness.
3636
events = tmp_file.map {|line| LogStash::Event.new(LogStash::Json.load(line))}
37-
sorted = events.sort_by {|e| e['sequence']}
37+
sorted = events.sort_by {|e| e.get('sequence')}
3838
sorted.each do |event|
39-
insist {event["message"]} == "hello world"
40-
insist {event["sequence"]} == line_num
39+
insist {event.get("message")} == "hello world"
40+
insist {event.get("sequence")} == line_num
4141
line_num += 1
4242
end
4343

@@ -69,10 +69,10 @@
6969
line_num = 0
7070
# Now check all events for order and correctness.
7171
events = Zlib::GzipReader.open(tmp_file.path).map {|line| LogStash::Event.new(LogStash::Json.load(line)) }
72-
sorted = events.sort_by {|e| e["sequence"]}
72+
sorted = events.sort_by {|e| e.get("sequence")}
7373
sorted.each do |event|
74-
insist {event["message"]} == "hello world"
75-
insist {event["sequence"]} == line_num
74+
insist {event.get("message")} == "hello world"
75+
insist {event.get("sequence")} == line_num
7676
line_num += 1
7777
end
7878
insist {line_num} == event_count
@@ -166,7 +166,7 @@
166166
context "when trying to write outside the files root directory" do
167167
let(:bad_event) do
168168
event = LogStash::Event.new
169-
event['error'] = '../uncool/directory'
169+
event.set('error', '../uncool/directory')
170170
event
171171
end
172172

@@ -179,7 +179,7 @@
179179

180180
# Trying to write outside the file root
181181
outside_path = "#{'../' * path.split(File::SEPARATOR).size}notcool"
182-
bad_event["error"] = outside_path
182+
bad_event.set("error", outside_path)
183183

184184

185185
output = LogStash::Outputs::File.new(config)
@@ -201,10 +201,10 @@
201201
output = LogStash::Outputs::File.new({ "path" => "/#{path}/%{error}"})
202202
output.register
203203

204-
bad_event['error'] = encoded_once
204+
bad_event.set('error', encoded_once)
205205
output.receive(bad_event)
206206

207-
bad_event['error'] = encoded_twice
207+
bad_event.set('error', encoded_twice)
208208
output.receive(bad_event)
209209

210210
expect(Dir.glob(File.join(path, "*")).size).to eq(2)
@@ -217,7 +217,7 @@
217217
output = LogStash::Outputs::File.new({ "path" => "/#{path}/%{error}"})
218218
output.register
219219

220-
bad_event['error'] = '../..//test'
220+
bad_event.set('error', '../..//test')
221221
output.receive(bad_event)
222222

223223
expect(Dir.glob(File.join(path, "*")).size).to eq(1)
@@ -229,15 +229,15 @@
229229
context 'when trying to write inside the file root directory' do
230230
it 'write the event to the generated filename' do
231231
good_event = LogStash::Event.new
232-
good_event['error'] = '42.txt'
232+
good_event.set('error', '42.txt')
233233

234234
Stud::Temporary.directory do |path|
235235
config = { "path" => "#{path}/%{error}" }
236236
output = LogStash::Outputs::File.new(config)
237237
output.register
238238
output.receive(good_event)
239239

240-
good_file = File.join(path, good_event['error'])
240+
good_file = File.join(path, good_event.get('error'))
241241
expect(File.exist?(good_file)).to eq(true)
242242
output.close
243243
end
@@ -285,15 +285,15 @@
285285

286286
it 'write the event to the generated filename with multiple deep' do
287287
good_event = LogStash::Event.new
288-
good_event['error'] = '/inside/errors/42.txt'
288+
good_event.set('error', '/inside/errors/42.txt')
289289

290290
Stud::Temporary.directory do |path|
291291
config = { "path" => "#{path}/%{error}" }
292292
output = LogStash::Outputs::File.new(config)
293293
output.register
294294
output.receive(good_event)
295295

296-
good_file = File.join(path, good_event['error'])
296+
good_file = File.join(path, good_event.get('error'))
297297
expect(File.exist?(good_file)).to eq(true)
298298
output.close
299299
end
@@ -304,7 +304,7 @@
304304
context "when using default configuration" do
305305
it 'write the event as a json line' do
306306
good_event = LogStash::Event.new
307-
good_event['message'] = 'hello world'
307+
good_event.set('message', 'hello world')
308308

309309
Stud::Temporary.directory do |path|
310310
config = { "path" => "#{path}/output.txt" }
@@ -316,15 +316,15 @@
316316
output.close #teardown first to allow reading the file
317317
File.open(good_file) {|f|
318318
event = LogStash::Event.new(LogStash::Json.load(f.readline))
319-
expect(event["message"]).to eq("hello world")
319+
expect(event.get("message")).to eq("hello world")
320320
}
321321
end
322322
end
323323
end
324324
context "when using line codec" do
325325
it 'writes event using specified format' do
326326
good_event = LogStash::Event.new
327-
good_event['message'] = "hello world"
327+
good_event.set('message', "hello world")
328328

329329
Stud::Temporary.directory do |path|
330330
config = { "path" => "#{path}/output.txt" }
@@ -345,7 +345,7 @@
345345
context "when using deprecated message_format config" do
346346
it 'falls back to line codec' do
347347
good_event = LogStash::Event.new
348-
good_event['message'] = 'hello world'
348+
good_event.set('message', 'hello world')
349349

350350
Stud::Temporary.directory do |path|
351351
config = { "path" => "#{path}/output.txt", "message_format" => "Custom format: %{message}" }
@@ -365,7 +365,7 @@
365365
context "when using file and dir modes" do
366366
it 'dirs and files are created with correct atypical permissions' do
367367
good_event = LogStash::Event.new
368-
good_event['message'] = "hello world"
368+
good_event.set('message', "hello world")
369369

370370
Stud::Temporary.directory do |path|
371371
config = {
@@ -386,7 +386,7 @@
386386
output.close #teardown first to allow reading the file
387387
File.open(good_file) {|f|
388388
event = LogStash::Event.new(LogStash::Json.load(f.readline))
389-
expect(event["message"]).to eq("hello world")
389+
expect(event.get("message")).to eq("hello world")
390390
}
391391
end
392392
end

0 commit comments

Comments
 (0)