From 199abb6c9bbee8a6a276d6acaa0e7c9ffd65d1e6 Mon Sep 17 00:00:00 2001 From: Masahiro Nakagawa Date: Wed, 9 May 2018 09:13:58 +0900 Subject: [PATCH] Fix unstable tests of backup feature Signed-off-by: Masahiro Nakagawa --- test/plugin/test_output_as_buffered_backup.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/plugin/test_output_as_buffered_backup.rb b/test/plugin/test_output_as_buffered_backup.rb index 885ad35041..1c0dfed145 100644 --- a/test/plugin/test_output_as_buffered_backup.rb +++ b/test/plugin/test_output_as_buffered_backup.rb @@ -169,6 +169,14 @@ def flush_chunks @i.flush_thread_wakeup end + def wait_flush(target_file) + waiting(5) { + target_dir = File.join(File.dirname(target_file), "*") + while Dir.glob(target_dir).size.zero? + end + } + end + test 'backup chunk without secondary' do Fluent::SystemConfig.overwrite_system_config('root_dir' => TMP_DIR) do id = 'backup_test' @@ -186,6 +194,7 @@ def flush_chunks flush_chunks target = "#{TMP_DIR}/backup/worker0/#{id}/#{@i.dump_unique_id_hex(chunk_id)}.log" + wait_flush(target) assert_true File.exist?(target) logs = @i.log.out.logs assert { logs.any? { |l| l.include?("got unrecoverable error in primary and no secondary") } } @@ -210,6 +219,7 @@ def flush_chunks flush_chunks target = "#{TMP_DIR}/backup/worker0/#{id}/#{@i.dump_unique_id_hex(chunk_id)}.log" + wait_flush(target) assert_true File.exist?(target) logs = @i.log.out.logs assert { logs.any? { |l| l.include?("got unrecoverable error in primary and secondary type is same as primary") } } @@ -237,6 +247,7 @@ def flush_chunks flush_chunks target = "#{TMP_DIR}/backup/worker0/#{id}/#{@i.dump_unique_id_hex(chunk_id)}.log" + wait_flush(target) assert_true File.exist?(target) logs = @i.log.out.logs assert { logs.any? { |l| l.include?("got unrecoverable error in primary. Skip retry and flush chunk to secondary") } } @@ -262,6 +273,7 @@ def flush_chunks flush_chunks target = "#{TMP_DIR}/backup/worker0/#{id}/#{@i.dump_unique_id_hex(chunk_id)}.log" + wait_flush(target) assert_true File.exist?(target) logs = @i.log.out.logs assert { logs.any? { |l| l.include?("got unrecoverable error in primary and secondary is async output") } }