Skip to content

Commit

Permalink
test: fix flakiness in gh_6128_background_mode_test
Browse files Browse the repository at this point in the history
Previous attempt to fix flakiness in commit 6a2c73f ("test: fix
flakiness in gh_6128_background_mode_test") used a constant buffer size
in check_err_msg function. Tarantool 2.10 has a bit bigger log before a
desired message that other versions of Tarantool and it leads to a this
resulted in a truncated message ("entering the even" instead of
"entering the event loop"). Patch replaces check_err_msg()
implementation to grep_log used in luatest, it reads the whole log.

Also patch renames check_err_msg to check_msg, because "entering the
event loop" is not an error message.

Follows up tarantool#6128

NO_CHANGELOG=fix test
NO_DOC=fix test
  • Loading branch information
ligurio committed Jul 3, 2023
1 parent 9041d7e commit 4601403
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions test/app-luatest/gh_6128_background_mode_test.lua
Expand Up @@ -14,16 +14,13 @@ end

-- Check presence of string 'msg' in file 'file'.
-- Returns true when string is found and false otherwise.
-- Function is not as smart as grep_log in a luatest (luatest/server.lua)
-- and reads the whole log file every time, but this log file has a small
-- size so it is ok.
-- Function uses grep_log() defined in a luatest (luatest/server.lua).
-- grep_log is a class method, so it is required to create a Server instance.
-- https://github.com/tarantool/luatest/blob/89da427f8bb3bb66e01d2a7b5a9370d0428d8c52/luatest/server.lua#L660-L727
local function check_err_msg(file, msg)
local f = fio.open(file, {'O_RDONLY', 'O_NONBLOCK'})
t.assert_not_equals(f, nil)
local content = f:read(2048)
f:close()
return (string.match(content, msg) and true) or false
local function check_msg(file, msg)
local server = t.Server:new({})
local res = server:grep_log(msg, 1024, {filename = file})
return (res == msg_opt_processing and true) or false
end

local TARANTOOL_PATH = tarantool_path(arg)
Expand Down Expand Up @@ -67,7 +64,7 @@ end)

g.test_background_mode_box_cfg = function(cg)
t.helpers.retrying({timeout = 2, delay = 0.01}, function()
assert(check_err_msg(cg.log_path, msg_opt_processing) == true)
assert(check_msg(cg.log_path, msg_opt_processing) == true)
end, cg.log_path, cg.ph)
end

Expand Down Expand Up @@ -108,7 +105,7 @@ end)

g.test_background_mode_env_vars = function(cg)
t.helpers.retrying({timeout = 2, delay = 0.01}, function()
assert(check_err_msg(cg.log_path, msg_opt_processing) == true)
assert(check_msg(cg.log_path, msg_opt_processing) == true)
end, cg.log_path, cg.ph)
check_err_msg(cg.log_path, msg_opt_processing)
check_msg(cg.log_path, msg_opt_processing)
end

0 comments on commit 4601403

Please sign in to comment.