Skip to content

Commit b44b054

Browse files
committed
test_buf_file: separate the test cases
Signed-off-by: Shizuo Fujita <[email protected]>
1 parent c78f7a5 commit b44b054

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

test/plugin/test_buf_file.rb

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,32 +1320,36 @@ def compare_log(plugin, msg)
13201320
compare_log(@p, 'enqueued meta file is broken')
13211321
assert { not File.exist?(p2) }
13221322
assert { File.exist?("#{@bufdir}/backup/worker0/#{@id_output}/#{@d.dump_unique_id_hex(c2id)}.log") }
1323+
end
13231324

1324-
# broken id, c, m fields in meta data
1325-
c3id, p3 = create_first_chunk('q')
1326-
metadata = File.read(p3 + '.meta')
1327-
File.open(p3 + '.meta', 'wb') { |f| f.write(metadata[0..6] + "\0" * (metadata.size - 6)) } # create enqueued broken meta file
1325+
test '#resume backups enqueued broken metadata which has broken id, c, m fields' do
1326+
setup_plugins({'path' => @bufpath})
1327+
cid, path = create_first_chunk('q')
1328+
metadata = File.read(path + '.meta')
1329+
File.open(path + '.meta', 'wb') { |f| f.write(metadata[0..6] + "\0" * (metadata.size - 6)) } # create enqueued broken meta file
13281330

13291331
Fluent::SystemConfig.overwrite_system_config('root_dir' => @bufdir) do
13301332
@p.start
13311333
end
13321334

13331335
compare_log(@p, 'enqueued meta file is broken')
1334-
assert { not File.exist?(p3) }
1335-
assert { File.exist?("#{@bufdir}/backup/worker0/#{@id_output}/#{@d.dump_unique_id_hex(c3id)}.log") }
1336+
assert { not File.exist?(path) }
1337+
assert { File.exist?("#{@bufdir}/backup/worker0/#{@id_output}/#{@d.dump_unique_id_hex(cid)}.log") }
1338+
end
13361339

1337-
# truncate meta data
1338-
c4id, p4 = create_first_chunk('q')
1339-
metadata = File.read(p4 + '.meta')
1340-
File.open(p4 + '.meta', 'wb') { |f| f.write(metadata[0..-2]) } # create enqueued broken meta file with last byte truncated
1340+
test '#resume backups enqueued broken metadata by truncated' do
1341+
setup_plugins({'path' => @bufpath})
1342+
cid, path = create_first_chunk('q')
1343+
metadata = File.read(path + '.meta')
1344+
File.open(path + '.meta', 'wb') { |f| f.write(metadata[0..-2]) } # create enqueued broken meta file with last byte truncated
13411345

13421346
Fluent::SystemConfig.overwrite_system_config('root_dir' => @bufdir) do
13431347
@p.start
13441348
end
13451349

13461350
compare_log(@p, 'enqueued meta file is broken')
1347-
assert { not File.exist?(p4) }
1348-
assert { File.exist?("#{@bufdir}/backup/worker0/#{@id_output}/#{@d.dump_unique_id_hex(c4id)}.log") }
1351+
assert { not File.exist?(path) }
1352+
assert { File.exist?("#{@bufdir}/backup/worker0/#{@id_output}/#{@d.dump_unique_id_hex(cid)}.log") }
13491353
end
13501354

13511355
test '#resume throws away broken chunk with disable_chunk_backup' do

0 commit comments

Comments
 (0)