Skip to content

Clean up after unit tests - #4050

Merged
ashie merged 5 commits into
fluent:masterfrom
abetomo:clean-up-after-unit-tests
Feb 17, 2023
Merged

Clean up after unit tests#4050
ashie merged 5 commits into
fluent:masterfrom
abetomo:clean-up-after-unit-tests

Conversation

@abetomo

@abetomo abetomo commented Feb 10, 2023

Copy link
Copy Markdown
Contributor

Which issue(s) this PR fixes:

Fixes #4048

What this PR does / why we need it:

After unit testing, clean up in /tmp.

(If you cannot terminate with SIGTERM and terminate with SIGKILL, some files cannot be cleaned up. #4050 (comment) #4050 (comment))

Docs Changes:

None

Release Note:

None

@socket_manager_server ->
@socket_manager_path

Signed-off-by: abetomo <abe@enzou.tokyo>
Files created in `/tmp` are deleted.

Signed-off-by: abetomo <abe@enzou.tokyo>
Comment thread lib/fluent/test/driver/base.rb
Comment thread test/plugin/test_in_tcp.rb Outdated
Comment thread test/plugin/test_output.rb Outdated
Backup files are generated in `/tmp` and remain there.
Set `root_dir` to generate backup files in the specified directory.

Signed-off-by: abetomo <abe@enzou.tokyo>
@abetomo
abetomo force-pushed the clean-up-after-unit-tests branch from 0e647ed to a6b02da Compare February 13, 2023 13:08
@abetomo

abetomo commented Feb 13, 2023

Copy link
Copy Markdown
Contributor Author

With the committed changes and the following changes, all files were cleaned.

diff --git a/test/command/test_fluentd.rb b/test/command/test_fluentd.rb
index 461e19ef..9d62cd40 100644
--- a/test/command/test_fluentd.rb
+++ b/test/command/test_fluentd.rb
@@ -85,12 +85,12 @@ class TestFluentdCommand < ::Test::Unit::TestCase
         yield pid, io
         # p(here: "execute command", pid: pid, worker_pids: @worker_pids)
       ensure
-        Process.kill(:KILL, pid) rescue nil
+        Process.kill(:TERM, pid) rescue nil
         if @supervisor_pid
-          Process.kill(:KILL, @supervisor_pid) rescue nil
+          Process.kill(:TERM, @supervisor_pid) rescue nil
         end
         @worker_pids.each do |cpid|
-          Process.kill(:KILL, cpid) rescue nil
+          Process.kill(:TERM, cpid) rescue nil
         end
         # p(here: "execute command", pid: pid, exist: process_exist?(pid), worker_pids: @worker_pids, exists: @worker_pids.map{|i| process_exist?(i) })
         Timeout.timeout(10){ sleep 0.1 while process_exist?(pid) }

When you exit with SIGTERM, the shutdown process runs and the files are deleted.
However, the test was not stable because the process could not terminate in some cases.

`instance_shutdown` in `ensure` block.

Signed-off-by: abetomo <abe@enzou.tokyo>
@ashie

ashie commented Feb 15, 2023

Copy link
Copy Markdown
Member

How about trying SIGTERM first then SIGKILL after timeout?
Although we should make it stable but not needed to do it in this PR.

@abetomo

abetomo commented Feb 15, 2023

Copy link
Copy Markdown
Contributor Author

@ashie Thanks!
I’ll give it a try.

With SIGTERM, the shutdown process runs.
`SERVERENGINE_SOCKETMANAGER_*` etc. will be removed in the shutdown process.

When it cannot be terminated by SIGTERM, it is terminated by SIGKILL.

Signed-off-by: abetomo <abe@enzou.tokyo>
@abetomo
abetomo marked this pull request as ready for review February 16, 2023 14:51

@ashie ashie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ashie

ashie commented Feb 17, 2023

Copy link
Copy Markdown
Member

Retrying some unstable tests not concerned with this PR...

@daipom daipom left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the fix!

@ashie
ashie merged commit 07e3ad1 into fluent:master Feb 17, 2023
@ashie

ashie commented Feb 17, 2023

Copy link
Copy Markdown
Member

Thanks!

@abetomo
abetomo deleted the clean-up-after-unit-tests branch February 17, 2023 23:53
@abetomo

abetomo commented Feb 17, 2023

Copy link
Copy Markdown
Contributor Author

Thanks for your review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Files used in unit tests remain in /tmp

3 participants