Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make compress test stable #2899

Merged
merged 2 commits into from
Mar 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions test/plugin/test_compressable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
class CompressableTest < Test::Unit::TestCase
include Fluent::Plugin::Compressable

def compress_assert_equal(expected, actual)
e = Zlib::GzipReader.new(StringIO.new(expected)).read
a = Zlib::GzipReader.new(StringIO.new(actual)).read
assert_equal(e, a)
end

sub_test_case '#compress' do
setup do
@src = 'text data for compressing' * 5
Expand All @@ -18,8 +24,7 @@ class CompressableTest < Test::Unit::TestCase
test 'write compressed data to IO with output_io option' do
io = StringIO.new
compress(@src, output_io: io)
waiting(10){ sleep 0.1 until @gzipped_src == io.string }
assert_equal @gzipped_src, io.string
compress_assert_equal @gzipped_src, io.string
end
end

Expand All @@ -36,7 +41,6 @@ class CompressableTest < Test::Unit::TestCase
test 'write decompressed data to IO with output_io option' do
io = StringIO.new
decompress(@gzipped_src, output_io: io)
waiting(10){ sleep 0.1 until @src == io.string }
assert_equal @src, io.string
end

Expand All @@ -58,7 +62,6 @@ class CompressableTest < Test::Unit::TestCase
output_io = StringIO.new

decompress(input_io: input_io, output_io: output_io)
waiting(10){ sleep 0.1 until @src == output_io.string }
assert_equal @src, output_io.string
end

Expand Down