diff --git a/lib/fluent/agent.rb b/lib/fluent/agent.rb
index 3fea70c3f1..4a655ba332 100644
--- a/lib/fluent/agent.rb
+++ b/lib/fluent/agent.rb
@@ -134,6 +134,9 @@ def add_match(type, pattern, conf)
output.router = @event_router if output.respond_to?(:router=)
output.configure(conf)
@outputs << output
+ if output.respond_to?(:outputs) && (output.is_a?(Fluent::Plugin::MultiOutput) || output.is_a?(Fluent::MultiOutput))
+ @outputs.push(*output.outputs)
+ end
@event_router.add_rule(pattern, output)
output
diff --git a/test/test_plugin_classes.rb b/test/test_plugin_classes.rb
index 8778f139de..0f1bd1afca 100644
--- a/test/test_plugin_classes.rb
+++ b/test/test_plugin_classes.rb
@@ -10,11 +10,13 @@ class FluentTestInput < ::Fluent::Input
attr_reader :started
def start
+ super
@started = true
end
def shutdown
@started = false
+ super
end
end
@@ -30,11 +32,13 @@ def initialize
attr_reader :started
def start
+ super
@started = true
end
def shutdown
@started = false
+ super
end
def emit(tag, es, chain)
@@ -69,11 +73,13 @@ def initialize(field = '__test__')
attr_reader :started
def start
+ super
@started = true
end
def shutdown
@started = false
+ super
end
def filter(tag, time, record)
@@ -96,11 +102,13 @@ def initialize(field = '__test__')
attr_reader :started
def start
+ super
@started = true
end
def shutdown
@started = false
+ super
end
def filter(tag, time, record)
diff --git a/test/test_root_agent.rb b/test/test_root_agent.rb
index 890e5e8dff..174334d96e 100644
--- a/test/test_root_agent.rb
+++ b/test/test_root_agent.rb
@@ -129,4 +129,146 @@ def configure_ra(conf_str)
assert_false @ra.outputs.first.started
end
end
+
+ sub_test_case 'configured with MultiOutput plugins' do
+ setup do
+ @ra = RootAgent.new(log: $log)
+ stub(Engine).root_agent { @ra }
+ @ra.configure(Config.parse(<<-EOC, "(test)", "(test_dir)", true))
+
+
+ @type test_filter
+ @id test_filter
+
+
+ @type copy
+ @id test_copy
+
+ @type test_out
+ @id test_out1
+
+
+ @type test_out
+ @id test_out2
+
+
+EOC
+ @ra
+ end
+
+ test 'plugin status with multi output' do
+ assert_equal 1, @ra.inputs.size
+ assert_equal 1, @ra.filters.size
+ assert_equal 3, @ra.outputs.size
+
+ @ra.start
+ assert_equal [true], @ra.inputs.map{|i| i.started? }
+ assert_equal [true], @ra.filters.map{|i| i.started? }
+ assert_equal [true, true, true], @ra.outputs.map{|i| i.started? }
+
+ @ra.shutdown
+ assert_equal [true], @ra.inputs.map{|i| i.stopped? }
+ assert_equal [true], @ra.filters.map{|i| i.stopped? }
+ assert_equal [true, true, true], @ra.outputs.map{|i| i.stopped? }
+
+ assert_equal [true], @ra.inputs.map{|i| i.before_shutdown? }
+ assert_equal [true], @ra.filters.map{|i| i.before_shutdown? }
+ assert_equal [true, true, true], @ra.outputs.map{|i| i.before_shutdown? }
+
+ assert_equal [true], @ra.inputs.map{|i| i.shutdown? }
+ assert_equal [true], @ra.filters.map{|i| i.shutdown? }
+ assert_equal [true, true, true], @ra.outputs.map{|i| i.shutdown? }
+
+ assert_equal [true], @ra.inputs.map{|i| i.after_shutdown? }
+ assert_equal [true], @ra.filters.map{|i| i.after_shutdown? }
+ assert_equal [true, true, true], @ra.outputs.map{|i| i.after_shutdown? }
+
+ assert_equal [true], @ra.inputs.map{|i| i.closed? }
+ assert_equal [true], @ra.filters.map{|i| i.closed? }
+ assert_equal [true, true, true], @ra.outputs.map{|i| i.closed? }
+
+ assert_equal [true], @ra.inputs.map{|i| i.terminated? }
+ assert_equal [true], @ra.filters.map{|i| i.terminated? }
+ assert_equal [true, true, true], @ra.outputs.map{|i| i.terminated? }
+ end
+ end
+
+ sub_test_case 'configured with MultiOutput plugins and labels' do
+ setup do
+ @ra = RootAgent.new(log: $log)
+ stub(Engine).root_agent { @ra }
+ @ra.configure(Config.parse(<<-EOC, "(test)", "(test_dir)", true))
+
+
+EOC
+ @ra
+ end
+
+ test 'plugin status with multi output' do
+ assert_equal 1, @ra.inputs.size
+ assert_equal 0, @ra.filters.size
+ assert_equal 0, @ra.outputs.size
+ assert_equal 1, @ra.labels.size
+ assert_equal '@testing', @ra.labels.keys.first
+ assert_equal 1, @ra.labels.values.first.filters.size
+ assert_equal 3, @ra.labels.values.first.outputs.size
+
+ label_filters = @ra.labels.values.first.filters
+ label_outputs = @ra.labels.values.first.outputs
+
+ @ra.start
+ assert_equal [true], @ra.inputs.map{|i| i.started? }
+ assert_equal [true], label_filters.map{|i| i.started? }
+ assert_equal [true, true, true], label_outputs.map{|i| i.started? }
+
+ @ra.shutdown
+ assert_equal [true], @ra.inputs.map{|i| i.stopped? }
+ assert_equal [true], label_filters.map{|i| i.stopped? }
+ assert_equal [true, true, true], label_outputs.map{|i| i.stopped? }
+
+ assert_equal [true], @ra.inputs.map{|i| i.before_shutdown? }
+ assert_equal [true], label_filters.map{|i| i.before_shutdown? }
+ assert_equal [true, true, true], label_outputs.map{|i| i.before_shutdown? }
+
+ assert_equal [true], @ra.inputs.map{|i| i.shutdown? }
+ assert_equal [true], label_filters.map{|i| i.shutdown? }
+ assert_equal [true, true, true], label_outputs.map{|i| i.shutdown? }
+
+ assert_equal [true], @ra.inputs.map{|i| i.after_shutdown? }
+ assert_equal [true], label_filters.map{|i| i.after_shutdown? }
+ assert_equal [true, true, true], label_outputs.map{|i| i.after_shutdown? }
+
+ assert_equal [true], @ra.inputs.map{|i| i.closed? }
+ assert_equal [true], label_filters.map{|i| i.closed? }
+ assert_equal [true, true, true], label_outputs.map{|i| i.closed? }
+
+ assert_equal [true], @ra.inputs.map{|i| i.terminated? }
+ assert_equal [true], label_filters.map{|i| i.terminated? }
+ assert_equal [true, true, true], label_outputs.map{|i| i.terminated? }
+ end
+ end
end