From d6c7d007468d8d679b4428e751012ff06df20525 Mon Sep 17 00:00:00 2001 From: TAGOMORI Satoshi Date: Mon, 24 Oct 2016 12:09:49 +0900 Subject: [PATCH] make sure to set binary mode on #open, and to wait write operation --- lib/fluent/command/binlog_reader.rb | 2 +- test/command/test_binlog_reader.rb | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/fluent/command/binlog_reader.rb b/lib/fluent/command/binlog_reader.rb index 5e8447cdbd..92500d7703 100644 --- a/lib/fluent/command/binlog_reader.rb +++ b/lib/fluent/command/binlog_reader.rb @@ -164,7 +164,7 @@ def initialize(argv = ARGV) def call @formatter = lookup_formatter(@options[:format], @options[:config_params]) - File.open(@path, 'r') do |io| + File.open(@path, 'rb') do |io| i = 1 Fluent::MessagePackFactory.unpacker(io).each do |(time, record)| print @formatter.format(@path, time, record) # path is used for tag diff --git a/test/command/test_binlog_reader.rb b/test/command/test_binlog_reader.rb index c945fc807c..51ff0c7d28 100644 --- a/test/command/test_binlog_reader.rb +++ b/test/command/test_binlog_reader.rb @@ -58,9 +58,13 @@ class TestBaseCommand < ::Test::Unit::TestCase def create_message_packed_file(path, times = [event_time], records = [{ 'message' => 'dummy' }]) es = Fluent::MultiEventStream.new(times, records) v = es.to_msgpack_stream - File.open("#{TMP_DIR}/#{path}", 'w') do |f| + out_path = "#{TMP_DIR}/#{path}" + File.open(out_path, 'wb') do |f| f.print(v) end + waiting(5) do + sleep 0.5 until File.size(out_path) == v.bytesize + end end def setup