Skip to content

Commit

Permalink
test: fix tarantool process teardown
Browse files Browse the repository at this point in the history
Test uses a popen module that starts tarantool process in background
mode. Tarantool process started in background mode forks a new process
and closes a parent, after that popen loses a PID of the started process
and `ph:kill()` and `ph:terminate()` doesn't work anymore. It leads to
non-terminated tarantool processes after running the test.

Patch fixes that by running `kill` using os.execute with a PID of
tarantool process written to a pid file.

Follows up tarantool#6128

NO_CHANGELOG=fix test
NO_DOC=fix test
  • Loading branch information
ligurio committed Jul 5, 2023
1 parent 9041d7e commit ace933e
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions test/app-luatest/gh_6128_background_mode_test.lua
Expand Up @@ -53,12 +53,11 @@ pid_file='%s', background=true, work_dir='%s', log='%s',
t.helpers.retrying({timeout = 2, delay = 0.01}, function(path)
assert(fio.path.exists(path) == true)
end, g.log_path)
g.pid = fio.open(g.pid_path):read()
end)

g.after_test("test_background_mode_box_cfg", function(cg)
cg.ph:terminate()
cg.ph:wait()
cg.ph:close()
os.execute("kill -9 " .. cg.pid)
fio.unlink(cg.pid_path)
fio.unlink(cg.log_path)
os.remove("*.xlog")
Expand Down Expand Up @@ -94,12 +93,11 @@ g.before_test("test_background_mode_env_vars", function()
t.helpers.retrying({timeout = 2, delay = 0.01}, function(path)
assert(fio.path.exists(path) == true)
end, g.log_path)
g.pid = fio.open(g.pid_path):read()
end)

g.after_test("test_background_mode_env_vars", function(cg)
cg.ph:terminate()
cg.ph:wait()
cg.ph:close()
os.execute("kill -9 " .. cg.pid)
fio.unlink(cg.pid_path)
fio.unlink(cg.log_path)
os.remove("*.xlog")
Expand Down

0 comments on commit ace933e

Please sign in to comment.