Skip to content

Commit

Permalink
Merge pull request #1979 from fluent/fix-unstable-backup-test
Browse files Browse the repository at this point in the history
Fix unstable tests of backup feature
  • Loading branch information
repeatedly authored May 9, 2018
2 parents b76c9d2 + 199abb6 commit 9738a42
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/plugin/test_output_as_buffered_backup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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") } }
Expand All @@ -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") } }
Expand Down Expand Up @@ -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") } }
Expand All @@ -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") } }
Expand Down

0 comments on commit 9738a42

Please sign in to comment.