From: "Ilya Markov" <imarkov@tarantool.org> To: tarantool-patches@freelists.org Subject: [tarantool-patches] Fwd: [patches] [log 1/2] log: Fix logger.test.lua Date: Wed, 28 Mar 2018 11:05:47 +0300 [thread overview] Message-ID: <1522224347.398152764@f25.i.mail.ru> (raw) [-- Attachment #1: Type: text/plain, Size: 1630 bytes --] -------- Пересылаемое сообщение -------- От кого: Ilya Markov <imarkov@tarantool.org> Кому: georgy@tarantool.org Копия: patches@tarantool.org Дата: Вторник, 27 марта 2018, 17:09 +03:00 Тема: [patches] [log 1/2] log: Fix logger.test.lua Fix race condition in test on log_rotate. Test opened file that must be created by log_rotate and read from it. But as log_rotate is executed in separate thread, file may be not created or log may be not written yet by the time of opening in test. Fix this with waiting creation and reading the line. --- test/app-tap/logger.test.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/app-tap/logger.test.lua b/test/app-tap/logger.test.lua index 72d13d3..76b3598 100755 --- a/test/app-tap/logger.test.lua +++ b/test/app-tap/logger.test.lua @@ -15,6 +15,7 @@ box.cfg{ local log = require('log') local fio = require('fio') local json = require('json') +local fiber = require('fiber') local file = io.open(filename) while file:read() do end @@ -105,10 +106,12 @@ file:close() log.log_format("json") -os.rename(filename, filename .. "2") +fio.rename(filename, filename .. "2") log.rotate() file = fio.open(filename) +while file == nil do file = fio.open(filename) fiber.sleep(0.0001) end line = file:read() +while line == nil or line == "" do line = file:read() fiber.sleep(0.0001) end index = line:find('\n') line = line:sub(1, index) message = json.decode(line) -- 2.7.4 ---------------------------------------------------------------------- -- Thank you, Ilya Markov [-- Attachment #2: Type: text/html, Size: 2163 bytes --]
reply other threads:[~2018-03-28 8:05 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1522224347.398152764@f25.i.mail.ru \ --to=imarkov@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [tarantool-patches] Fwd: [patches] [log 1/2] log: Fix logger.test.lua' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox