Skip to content

Commit

Permalink
test: set root_dir
Browse files Browse the repository at this point in the history
Backup files are generated in `/tmp` and remain there.
Set `root_dir` to generate backup files in the specified directory.

Signed-off-by: abetomo <[email protected]>
  • Loading branch information
abetomo committed Feb 11, 2023
1 parent c806fa9 commit 0e647ed
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/plugin/test_out_http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ def test_basic_auth_with_invalid_auth
password hello?
</auth>
])
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)
Expand Down
8 changes: 8 additions & 0 deletions test/plugin/test_output.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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) }

Expand All @@ -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
Expand Down Expand Up @@ -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 }
Expand All @@ -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
Expand Down

0 comments on commit 0e647ed

Please sign in to comment.