From 572d656c1d9a936aa56b34678aea39e07bf8edcb Mon Sep 17 00:00:00 2001 From: TAGOMORI Satoshi Date: Tue, 15 Nov 2016 18:17:23 +0900 Subject: [PATCH] fix not to raise error when out_forward is initialized as secondary --- lib/fluent/plugin/out_forward.rb | 10 ++++++---- test/plugin/test_out_forward.rb | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/lib/fluent/plugin/out_forward.rb b/lib/fluent/plugin/out_forward.rb index 4f8d89fed2..11db4dce9a 100644 --- a/lib/fluent/plugin/out_forward.rb +++ b/lib/fluent/plugin/out_forward.rb @@ -138,10 +138,12 @@ def configure(conf) end end - if @compress == :gzip && @buffer.compress == :text - @buffer.compress = :gzip - elsif @compress == :text && @buffer.compress == :gzip - log.info "buffer is compressed. If you also want to save the bandwidth of a network, Add `compress` configuration in " + unless @as_secondary + if @compress == :gzip && @buffer.compress == :text + @buffer.compress = :gzip + elsif @compress == :text && @buffer.compress == :gzip + log.info "buffer is compressed. If you also want to save the bandwidth of a network, Add `compress` configuration in " + end end if @nodes.empty? diff --git a/test/plugin/test_out_forward.rb b/test/plugin/test_out_forward.rb index 8d0a4c932b..b97cd0e494 100644 --- a/test/plugin/test_out_forward.rb +++ b/test/plugin/test_out_forward.rb @@ -573,4 +573,23 @@ def test_heartbeat_type_udp timer.disable # call send_heartbeat at just once timer.on_timer end + + def test_acts_as_secondary + i = Fluent::Plugin::ForwardOutput.new + conf = config_element( + 'match', + 'primary.**', + {'@type' => 'forward'}, + [ + config_element('server', '', {'host' => '127.0.0.1'}), + config_element('secondary', '', {}, [ + config_element('server', '', {'host' => '192.168.1.2'}), + config_element('server', '', {'host' => '192.168.1.3'}) + ]), + ] + ) + assert_nothing_raised do + i.configure(conf) + end + end end