Skip to content

Commit 3fa719d

Browse files
Serpentianylobankov
authored andcommitted
server: fix reset option in grep_log for Tarantool EE
server.grep_log() has 'reset' option, which allows to reset the result, when instance restart is found. It doesn't work on Tarantool EE, as it tries to find "Tarantool %d+.%d+.%d+-.*%d+-g.*" pattern, but EE has "Tarantool Enterprise ...". Let's use tarantool.package value instead of explicitly specifying, on which tarantool package restart is done. Closes #319
1 parent 3f13533 commit 3fa719d

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

luatest/server.lua

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ local http_client = require('http.client')
1212
local json = require('json')
1313
local log = require('log')
1414
local net_box = require('net.box')
15+
local tarantool = require('tarantool')
1516
local uri = require('uri')
1617
local _, luacov_runner = pcall(require, 'luacov.runner') -- luacov may not be installed
1718

@@ -722,7 +723,8 @@ function Server:grep_log(pattern, bytes_num, opts)
722723
line = table.concat(buf)
723724
buf = nil
724725
end
725-
if string.match(line, '> Tarantool %d+.%d+.%d+-.*%d+-g.*$') and reset then
726+
local package = tarantool.package or 'Tarantool'
727+
if string.match(line, '> ' .. package .. ' %d+.%d+.%d+-.*%d+-g.*$') and reset then
726728
found = nil -- server was restarted, reset the result
727729
else
728730
found = string.match(line, pattern) or found

test/server_test.lua

+22-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ local command = fio.pathjoin(root, 'test', 'server_instance.lua')
1515
local server = Server:new({
1616
command = command,
1717
workdir = fio.pathjoin(datadir, 'common'),
18-
env = {custom_env = 'test_value'},
18+
env = {
19+
TARANTOOL_LOG = fio.pathjoin(datadir, 'server_test.log'),
20+
custom_env = 'test_value',
21+
},
1922
http_port = 8182,
2023
net_box_port = 3133,
2124
})
@@ -476,3 +479,21 @@ end
476479
g.after_test('test_error_level_is_correct', function()
477480
g.s:drop()
478481
end)
482+
483+
g.test_grep_log = function()
484+
server:connect_net_box()
485+
486+
-- Test that grep_log just works.
487+
server:exec(function() require('log').info('test grep_log') end)
488+
t.assert(server:grep_log('test grep_log'))
489+
490+
-- By default opts.reset in server:grep_log() is true, so we
491+
-- should not find the message after instance restart.
492+
server:restart()
493+
t.helpers.retrying({}, function() server:http_request('get', '/ping') end)
494+
server:connect_net_box()
495+
t.assert_not(server:grep_log('test grep_log'))
496+
497+
server.net_box:close()
498+
server.net_box = nil
499+
end

0 commit comments

Comments
 (0)