Skip to content

Commit

Permalink
Merge pull request #1032 from fluent/default-secondary-type-v14
Browse files Browse the repository at this point in the history
fix bug not to use primary plugin type in default
  • Loading branch information
tagomoris committed Jun 7, 2016
2 parents aaf0dfd + d8af45e commit 0088a30
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/fluent/plugin/output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,9 @@ def configure(conf)
raise Fluent::ConfigError, "<secondary> section and 'retry_forever' are exclusive" if @buffer_config.retry_forever

secondary_type = @secondary_config[:@type]
unless secondary_type
secondary_type = conf['@type'] # primary plugin type
end
secondary_conf = conf.elements(name: 'secondary').first
@secondary = Plugin.new_output(secondary_type)
@secondary.acts_as_secondary(self)
Expand Down
13 changes: 13 additions & 0 deletions test/plugin/test_output_as_buffered_secondary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ def dummy_event_stream
end
end

test 'uses same plugin type with primary if @type is missing in secondary' do
bufconf = config_element('buffer','tag',{'flush_interval' => 1, 'retry_type' => :periodic, 'retry_wait' => 3, 'retry_timeout' => 30, 'retry_randomize' => false})
secconf = config_element('secondary','',{})
priconf = config_element('ROOT', '', {'@type' => 'output_secondary_test'}, [bufconf, secconf])
i = create_output()
assert_nothing_raised do
i.configure(priconf)
end
logs = i.log.out.logs
assert{ logs.empty? }
assert{ i.secondary.is_a? FluentPluginOutputAsBufferedSecondaryTest::DummyFullFeatureOutput }
end

test 'warns if secondary plugin is different type from primary one' do
priconf = config_element('buffer','tag',{'flush_interval' => 1, 'retry_type' => :periodic, 'retry_wait' => 3, 'retry_timeout' => 30, 'retry_randomize' => false})
secconf = config_element('secondary','',{'@type' => 'output_secondary_test2'})
Expand Down

0 comments on commit 0088a30

Please sign in to comment.