From 5e147360b6570eaad2a81221bfaa4191cf23075d Mon Sep 17 00:00:00 2001
From: Oleg Chaplashkin <ochaplashkin@tarantool.org>
Date: Wed, 11 Oct 2023 12:29:03 +0400
Subject: [PATCH] test: update gh_8083, gh_8445 and gh_7434 tests

These tests fail after the commit [1] has been added to the Luatest:

- app-luatest/gh_8083_fatal_signal_handler_test.lua
- app-luatest/gh_8445_crash_during_crash_report_test.lua
- box-luatest/gh_7434_yield_in_on_shutdown_trigger_test.lua

The issue is due to lack of necessary directories:

    sh: 1: cd: can't cd to /tmp/t/001_app-luatest/server-XXX

Just update tests on the simple `fio` module instead `luatest.server`.

[1] tarantool/luatest@7d1358c

NO_CHANGELOG=internal
NO_DOC=internal

(cherry picked from commit 23b61351dce4b930dad795d064cc1053a6624091)
---
 .../gh_8083_fatal_signal_handler_test.lua            |  8 ++++----
 .../gh_8445_crash_during_crash_report_test.lua       | 12 ++++++------
 .../gh_7434_yield_in_on_shutdown_trigger_test.lua    |  9 ++++++---
 3 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/test/app-luatest/gh_8083_fatal_signal_handler_test.lua b/test/app-luatest/gh_8083_fatal_signal_handler_test.lua
index c77d78d7ba..bee19624f7 100644
--- a/test/app-luatest/gh_8083_fatal_signal_handler_test.lua
+++ b/test/app-luatest/gh_8083_fatal_signal_handler_test.lua
@@ -1,15 +1,15 @@
+local fio = require('fio')
 local t = require('luatest')
 
 local g = t.group('gh-8083', {{errinj = 'ERRINJ_SIGILL_MAIN_THREAD'},
                               {errinj = 'ERRINJ_SIGILL_NONMAIN_THREAD'}})
 
 g.before_each(function(cg)
-    local server = require('luatest.server')
-    cg.server = server:new({alias = 'master'})
+    cg.tempdir = fio.tempdir()
 end)
 
 g.after_each(function(cg)
-    cg.server:drop()
+    fio.rmtree(cg.tempdir)
 end)
 
 -- Check that forked Tarantool creates a crash report on the illegal instruction
@@ -24,7 +24,7 @@ g.test_fatal_signal_handler = function(cg)
     -- Use `cd' and `shell = true' due to lack of cwd option in popen (gh-5633),
     -- `feedback_enabled = false' to avoid forking for sending feedback.
     local fmt = 'cd %s && %s -e "box.cfg{feedback_enabled = false} os.exit()"'
-    local cmd = string.format(fmt, cg.server.workdir, tarantool_exe)
+    local cmd = string.format(fmt, cg.tempdir, tarantool_exe)
     local ph = popen.new({cmd}, {stderr = popen.opts.PIPE, env = tarantool_env,
                                  shell = true})
     t.assert(ph)
diff --git a/test/app-luatest/gh_8445_crash_during_crash_report_test.lua b/test/app-luatest/gh_8445_crash_during_crash_report_test.lua
index d2af12d04e..4b76ce5bfb 100644
--- a/test/app-luatest/gh_8445_crash_during_crash_report_test.lua
+++ b/test/app-luatest/gh_8445_crash_during_crash_report_test.lua
@@ -1,13 +1,13 @@
+local fio = require('fio')
 local t = require('luatest')
 local g = t.group('gh-8445')
 
-g.before_all(function(cg)
-    local server = require('luatest.server')
-    cg.server = server:new({alias = 'gh-8445'})
+g.before_each(function(cg)
+    cg.tempdir = fio.tempdir()
 end)
 
-g.after_all(function(cg)
-    cg.server:drop()
+g.after_each(function(cg)
+    fio.rmtree(cg.tempdir)
 end)
 
 -- Check that forked Tarantool doesn't crash when preparing a crash report.
@@ -17,7 +17,7 @@ g.test_crash_during_crash_report = function(cg)
 
     -- Use `cd' and `shell = true' due to lack of cwd option in popen (gh-5633).
     local exe = arg[-1]
-    local dir = cg.server.workdir
+    local dir = cg.tempdir
     local cmd = [[
         cd %s && %s -e "box.cfg{} require('log').info('pid = ' .. box.info.pid)"
     ]]
diff --git a/test/box-luatest/gh_7434_yield_in_on_shutdown_trigger_test.lua b/test/box-luatest/gh_7434_yield_in_on_shutdown_trigger_test.lua
index 345fc57b85..aac59814f0 100644
--- a/test/box-luatest/gh_7434_yield_in_on_shutdown_trigger_test.lua
+++ b/test/box-luatest/gh_7434_yield_in_on_shutdown_trigger_test.lua
@@ -10,15 +10,18 @@ local script = os.getenv('SOURCEDIR') .. '/test/box-luatest/gh_7434_child.lua'
 local output_file
 
 g.before_all(function(cg)
-    local server = require('luatest.server')
-    cg.server = server:new({alias = 'master'})
-    output_file = cg.server.workdir .. '/on_shutdown_completed.txt'
+    cg.tempdir = fio.tempdir()
+    output_file = cg.tempdir .. '/on_shutdown_completed.txt'
 end)
 
 g.after_each(function()
     os.remove(output_file)
 end)
 
+g.after_all(function(cg)
+    fio.rmtree(cg.tempdir)
+end)
+
 -- Shutdown by reaching the end of the script
 g.test_finish = function()
     local ph = popen.new({tarantool, script, output_file})
-- 
GitLab