Skip to content

Commit

Permalink
UTs for Out-forward and Out-file
Browse files Browse the repository at this point in the history
Signed-off-by: Athish Pranav D <[email protected]>
  • Loading branch information
Athishpranav2003 committed Nov 24, 2024
1 parent a385cce commit 627885b
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions test/plugin/test_out_forward.rb
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,15 @@ def try_write(chunk)
assert_equal :gzip, node.instance_variable_get(:@compress)
end

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

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

test 'set_compress_is_gzip_in_buffer_section' do
mock = flexmock($log)
mock.should_receive(:log).with("buffer is compressed. If you also want to save the bandwidth of a network, Add `compress` configuration in <match>")
Expand All @@ -359,6 +368,23 @@ def try_write(chunk)
assert_equal :text, node.instance_variable_get(:@compress)
end

test 'set_compress_is_zstd_in_buffer_section' do
mock = flexmock($log)
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 zstd
</buffer>
])
assert_equal :text, d.instance.compress
assert_equal :zstd, 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 Expand Up @@ -549,6 +575,36 @@ def try_write(chunk)
assert_equal ['test', time, records[1]], events[1]
end

test 'send_comprssed_message_pack_stream_if_compress_is_zstd' do
target_input_driver = create_target_input_driver

@d = d = create_driver(config + %[
flush_interval 1s
compress zstd
])

time = event_time('2011-01-02 13:14:15 UTC')

records = [
{"a" => 1},
{"a" => 2}
]
target_input_driver.run(expect_records: 2) do
d.run(default_tag: 'test') do
records.each do |record|
d.feed(time, record)
end
end
end

event_streams = target_input_driver.event_streams
assert_true event_streams[0][1].is_a?(Fluent::CompressedMessagePackEventStream)

events = target_input_driver.events
assert_equal ['test', time, records[0]], events[0]
assert_equal ['test', time, records[1]], events[1]
end

test 'send_to_a_node_supporting_responses' do
target_input_driver = create_target_input_driver

Expand Down

0 comments on commit 627885b

Please sign in to comment.