From 0e647ed8961a9c7353257b163f4f042bc0e4abf7 Mon Sep 17 00:00:00 2001 From: abetomo Date: Sat, 11 Feb 2023 23:27:50 +0900 Subject: [PATCH] test: set `root_dir` Backup files are generated in `/tmp` and remain there. Set `root_dir` to generate backup files in the specified directory. Signed-off-by: abetomo --- test/plugin/test_out_http.rb | 1 + test/plugin/test_output.rb | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/test/plugin/test_out_http.rb b/test/plugin/test_out_http.rb index e245f74524..b0e1a469a7 100644 --- a/test/plugin/test_out_http.rb +++ b/test/plugin/test_out_http.rb @@ -378,6 +378,7 @@ def test_basic_auth_with_invalid_auth password hello? ]) + d.instance.system_config_override(root_dir: TMP_DIR) # Backup files are generated in TMP_DIR. d.run(default_tag: 'test.http', shutdown: false) do test_events.each { |event| d.feed(event) diff --git a/test/plugin/test_output.rb b/test/plugin/test_output.rb index c25c7b1afb..6ae44254ae 100644 --- a/test/plugin/test_output.rb +++ b/test/plugin/test_output.rb @@ -803,7 +803,10 @@ def waiting(seconds) end test 'output plugin will call #try_write for plugin supports delayed commit only to flush buffer chunks' do + tmp_dir = File.join(__dir__, '../tmp/test_output') + i = create_output(:delayed) + i.system_config_override(root_dir: tmp_dir) # Backup files are generated in `tmp_dir`. try_write_called = false i.register(:try_write){|chunk| try_write_called = true; commit_write(chunk.unique_id) } @@ -820,6 +823,7 @@ def waiting(seconds) assert try_write_called i.stop; i.before_shutdown; i.shutdown; i.after_shutdown; i.close; i.terminate + FileUtils.rm_rf(tmp_dir) end test '#prefer_delayed_commit (returns false) decides delayed commit is disabled if both are implemented' do @@ -849,7 +853,10 @@ def waiting(seconds) end test '#prefer_delayed_commit (returns true) decides delayed commit is enabled if both are implemented' do + tmp_dir = File.join(__dir__, '../tmp/test_output') + i = create_output(:full) + i.system_config_override(root_dir: tmp_dir) # Backup files are generated in `tmp_dir`. write_called = false try_write_called = false i.register(:write){ |chunk| write_called = true } @@ -872,6 +879,7 @@ def waiting(seconds) assert try_write_called i.stop; i.before_shutdown; i.shutdown; i.after_shutdown; i.close; i.terminate + FileUtils.rm_rf(tmp_dir) end test 'flush_interval is ignored when flush_mode is not interval' do