mirror of
https://github.com/elastic/logstash.git
synced 2025-04-24 14:47:19 -04:00
initial spec for pipe input
removed logging fixed encoding header closes 1385
This commit is contained in:
parent
408c724bb7
commit
ccb453d557
2 changed files with 62 additions and 0 deletions
|
@ -46,6 +46,8 @@ class LogStash::Inputs::Pipe < LogStash::Inputs::Base
|
|||
queue << event
|
||||
end
|
||||
end
|
||||
rescue LogStash::ShutdownSignal => e
|
||||
break
|
||||
rescue Exception => e
|
||||
@logger.error("Exception while running command", :e => e, :backtrace => e.backtrace)
|
||||
end
|
||||
|
|
60
spec/inputs/pipe.rb
Normal file
60
spec/inputs/pipe.rb
Normal file
|
@ -0,0 +1,60 @@
|
|||
# encoding: utf-8
|
||||
require "test_utils"
|
||||
require "tempfile"
|
||||
|
||||
describe "inputs/pipe" do
|
||||
extend LogStash::RSpec
|
||||
|
||||
describe "echo" do
|
||||
event_count = 1
|
||||
tmp_file = Tempfile.new('logstash-spec-input-pipe')
|
||||
|
||||
config <<-CONFIG
|
||||
input {
|
||||
pipe {
|
||||
command => "echo ☹"
|
||||
}
|
||||
}
|
||||
CONFIG
|
||||
|
||||
input do |pipeline, queue|
|
||||
Thread.new { pipeline.run }
|
||||
sleep 0.1 while !pipeline.ready?
|
||||
|
||||
events = event_count.times.collect { queue.pop }
|
||||
event_count.times do |i|
|
||||
insist { events[i]["message"] } == "☹"
|
||||
end
|
||||
end # input
|
||||
end
|
||||
|
||||
describe "tail -f" do
|
||||
event_count = 10
|
||||
tmp_file = Tempfile.new('logstash-spec-input-pipe')
|
||||
|
||||
config <<-CONFIG
|
||||
input {
|
||||
pipe {
|
||||
command => "tail -f #{tmp_file.path}"
|
||||
}
|
||||
}
|
||||
CONFIG
|
||||
|
||||
input do |pipeline, queue|
|
||||
Thread.new { pipeline.run }
|
||||
sleep 0.1 while !pipeline.ready?
|
||||
|
||||
File.open(tmp_file, "a") do |fd|
|
||||
event_count.times do |i|
|
||||
# unicode smiley for testing unicode support!
|
||||
fd.puts("#{i} ☹")
|
||||
end
|
||||
end
|
||||
events = event_count.times.collect { queue.pop }
|
||||
event_count.times do |i|
|
||||
insist { events[i]["message"] } == "#{i} ☹"
|
||||
end
|
||||
end # input
|
||||
end
|
||||
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue