Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 36 additions & 34 deletions test/plugin/test_out_forward.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,42 @@ def try_write(chunk)
assert{ logs.any?{|log| log.include?(expected_log) && log.include?(expected_detail) } }
end

sub_test_case 'configure compress' do
data('default', ['', :text])
data('gzip', ['compress gzip', :gzip])
test 'should be applied' do |(option, expected)|
@d = d = create_driver(config + option)
node = d.instance.nodes.first

assert_equal(
[expected, expected],
[d.instance.compress, node.instance_variable_get(:@compress)]
)
end

# TODO add tests that we cannot configure the different compress type between owner and buffer except for :text
data('gzip', ['compress gzip', :text, :gzip])
test 'can configure buffer compress separately when owner uses :text' do |(buffer_option, expected_owner_compress, expected_buffer_compress)|
@d = d = create_driver(config + %[
<buffer>
type memory
#{buffer_option}
</buffer>
])
node = d.instance.nodes.first

assert_equal(
[expected_owner_compress, expected_owner_compress, expected_buffer_compress],
[d.instance.compress, node.instance_variable_get(:@compress), d.instance.buffer.compress],
)

log_message = "buffer is compressed. If you also want to save the bandwidth of a network, Add `compress` configuration in <match>"
assert do
d.logs.any? { |log| log.include?(log_message) }
end
end
end

data('CA cert' => 'tls_ca_cert_path',
'non CA cert' => 'tls_cert_path')
test 'configure tls_cert_path/tls_ca_cert_path' do |param|
Expand Down Expand Up @@ -326,40 +362,6 @@ def try_write(chunk)
assert_equal 1234, d.instance.discovery_manager.services[0].port
end

test 'compress_default_value' do
@d = d = create_driver
assert_equal :text, d.instance.compress

node = d.instance.nodes.first
assert_equal :text, node.instance_variable_get(:@compress)
end

test 'set_compress_is_gzip' do
@d = d = create_driver(config + %[compress gzip])
assert_equal :gzip, d.instance.compress
assert_equal :gzip, d.instance.buffer.compress

node = d.instance.nodes.first
assert_equal :gzip, node.instance_variable_get(:@compress)
end

test 'set_compress_is_gzip_in_buffer_section' do
mock = flexmock($log.dup)
mock.should_receive(:log).with("buffer is compressed. If you also want to save the bandwidth of a network, Add `compress` configuration in <match>")

@d = d = create_driver(config + %[
<buffer>
type memory
compress gzip
</buffer>
])
assert_equal :text, d.instance.compress
assert_equal :gzip, d.instance.buffer.compress

node = d.instance.nodes.first
assert_equal :text, node.instance_variable_get(:@compress)
end

test 'phi_failure_detector disabled' do
@d = d = create_driver(config + %[phi_failure_detector false \n phi_threshold 0])
node = d.instance.nodes.first
Expand Down
Loading