Skip to content

Commit

Permalink
Merge pull request #1057 from okkez/migrate-v0.14-api-out_null
Browse files Browse the repository at this point in the history
Migrate out_null plugin to v0.14 API
  • Loading branch information
tagomoris authored Jun 23, 2016
2 parents 17cec5b + a2986fc commit e6f1eb1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 6 deletions.
10 changes: 5 additions & 5 deletions lib/fluent/plugin/out_null.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
# limitations under the License.
#

require 'fluent/output'
require 'fluent/plugin/output'

module Fluent
module Fluent::Plugin
class NullOutput < Output
Plugin.register_output('null', self)
Fluent::Plugin.register_output('null', self)

def emit(tag, es, chain)
chain.next
def process(tag, es)
# Do nothing
end
end
end
1 change: 1 addition & 0 deletions lib/fluent/test/driver/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ def emit_error_event(tag, time, record, error)
end

def events(tag: nil)
return [] if @event_streams.nil?
selected = @event_streams.select{|e| tag.nil? ? true : e.tag == tag }
if block_given?
selected.each do |e|
Expand Down
29 changes: 29 additions & 0 deletions test/plugin/test_out_null.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require_relative '../helper'
require 'fluent/test/driver/output'
require 'fluent/plugin/out_null'

class NullOutputTest < Test::Unit::TestCase
def setup
Fluent::Test.setup
end

def create_driver(conf = "")
Fluent::Test::Driver::Output.new(Fluent::Plugin::NullOutput).configure(conf)
end

def test_configure
assert_nothing_raised do
create_driver
end
end

def test_process
d = create_driver
assert_nothing_raised do
d.run do
d.feed("test", Fluent::EventTime.now, {"test" => "null"})
end
end
assert_equal([], d.events(tag: "test"))
end
end
2 changes: 1 addition & 1 deletion test/test_root_agent.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def configure_ra(conf_str)
assert_equal ra, test_label.root_agent

error_label = ra.labels['@ERROR']
assert_kind_of NullOutput, error_label.outputs.first
assert_kind_of Fluent::Plugin::NullOutput, error_label.outputs.first
assert_kind_of RootAgent::RootAgentProxyWithoutErrorCollector, error_label.root_agent
end
end
Expand Down

0 comments on commit e6f1eb1

Please sign in to comment.