[patches] [log 1/1] log: Fix logger.test.lua

Georgy Kirichenko georgy at tarantool.org
Thu Mar 15 11:18:54 MSK 2018


Changes seems to be Ok, but there is still more travis issues:
https://travis-ci.org/tarantool/tarantool/jobs/353306464

On Wednesday, March 14, 2018 11:53:56 AM MSK Ilya Markov wrote:
> 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.
> 
> branch imarkov/fix-logger-test
> ---
>  test/app-tap/logger.test.lua | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/test/app-tap/logger.test.lua b/test/app-tap/logger.test.lua
> index 72d13d3..45ce791 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
> @@ -108,7 +109,9 @@ log.log_format("json")
>  os.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 do line = file:read() fiber.sleep(0.0001) end
>  index = line:find('\n')
>  line = line:sub(1, index)
>  message = json.decode(line)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20180315/b06a2569/attachment.sig>


More information about the Tarantool-patches mailing list