From: Sergey Bronnikov via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Artem Starshov <artemreyt@tarantool.org>,
Alexander Turenko <alexander.turenko@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCHv4 3/3] test: change -e assert(false) test using process_timeout module
Date: Thu, 21 Jan 2021 19:23:24 +0300 [thread overview]
Message-ID: <5ac4ae75-ce23-3f84-e91d-f0c4f4a50763@tarantool.org> (raw)
In-Reply-To: <c96810a7a2edb06273a7de6c19b69a0442bf79bb.1610973390.git.artemreyt@tarantool.org>
Thanks for the patch!
LGTM
I see no reasons to chaneg for latest two patches.
At least review would be much more easier with a single patch.
On 18.01.2021 15:45, Artem Starshov wrote:
> Removed definitions of functions with timeout. Now they are used
> from separated module process_timeout.lua
>
> Follows up #4983
> ---
> .../gh-4983-tnt-e-assert-false-hangs.test.lua | 62 +++----------------
> 1 file changed, 9 insertions(+), 53 deletions(-)
>
> diff --git a/test/app-tap/gh-4983-tnt-e-assert-false-hangs.test.lua b/test/app-tap/gh-4983-tnt-e-assert-false-hangs.test.lua
> index c8313770e..20046d7a5 100755
> --- a/test/app-tap/gh-4983-tnt-e-assert-false-hangs.test.lua
> +++ b/test/app-tap/gh-4983-tnt-e-assert-false-hangs.test.lua
> @@ -1,61 +1,17 @@
> #!/usr/bin/env tarantool
>
> -local fiber = require('fiber')
> -local clock = require('clock')
> -local ffi = require('ffi')
> -local fio = require('fio')
> -local errno = require('errno')
> +-- Using io.popen and self written module process_timeout
> +-- in presence of the 'popen' built-in module because the
> +-- last one isn't available in 1.10
> +local process_timeout = require('process_timeout')
> local tap = require('tap')
> +local fio = require('fio')
> +local ffi = require('ffi')
>
> --
> -- gh-4983: tarantool -e 'assert(false)' hangs
> --
>
> --- For process_is_alive.
> -ffi.cdef([[
> - int kill(pid_t pid, int sig);
> -]])
> -
> ---- Verify whether a process is alive.
> -local function process_is_alive(pid)
> - local rc = ffi.C.kill(pid, 0)
> - return rc == 0 or errno() ~= errno.ESRCH
> -end
> -
> ---- Returns true if process completed before timeout, false otherwise.
> -local function wait_process_completion(pid, timeout)
> - local start_time = clock.monotonic()
> - local process_completed = false
> - while clock.monotonic() - start_time < timeout do
> - if not process_is_alive(pid) then
> - process_completed = true
> - break
> - end
> - end
> - return process_completed
> -end
> -
> ---- Open file on reading with timeout.
> -local function open_with_timeout(filename, timeout)
> - local fh
> - local start_time = clock.monotonic()
> - while not fh and clock.monotonic() - start_time < timeout do
> - fh = fio.open(filename, {'O_RDONLY'})
> - end
> - return fh
> -end
> -
> ---- Try to read from file with timeout with interval.
> -local function read_with_timeout(fh, timeout, interval)
> - local data = ''
> - local start_time = clock.monotonic()
> - while #data == 0 and clock.monotonic() - start_time < timeout do
> - data = fh:read()
> - if #data == 0 then fiber.sleep(interval) end
> - end
> - return data
> -end
> -
> local TARANTOOL_PATH = arg[-1]
> local output_file = fio.abspath('out.txt')
> local line = ('%s -e "assert(false)" > %s 2>&1 & echo $!'):
> @@ -73,7 +29,7 @@ local res = tap.test('gh-4983-tnt-e-assert-false-hangs', function(test)
> local pid = tonumber(io.popen(line):read('*line'))
> assert(pid, 'pid of proccess can\'t be recieved')
>
> - local process_completed = wait_process_completion(pid,
> + local process_completed = process_timeout.wait_process_completion(pid,
> process_waiting_timeout)
>
> test:ok(process_completed,
> @@ -82,10 +38,10 @@ local res = tap.test('gh-4983-tnt-e-assert-false-hangs', function(test)
> -- Kill process if hangs.
> if not process_completed then ffi.C.kill(pid, 9) end
>
> - local fh = open_with_timeout(output_file, file_open_timeout)
> + local fh = process_timeout.open_with_timeout(output_file, file_open_timeout)
> assert(fh, 'error while opening ' .. output_file)
>
> - local data = read_with_timeout(fh, file_read_timeout, file_read_interval)
> + local data = process_timeout.read_with_timeout(fh, file_read_timeout, file_read_interval)
> test:like(data, 'assertion failed', 'assertion failure is displayed')
>
> fh:close()
next prev parent reply other threads:[~2021-01-21 16:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-18 12:45 [Tarantool-patches] [PATCHv4 0/3] test: -e assert(false) fixup Artem Starshov via Tarantool-patches
2021-01-18 12:45 ` [Tarantool-patches] [PATCHv4 1/3] test: change timeout in -e assert(false) test Artem Starshov via Tarantool-patches
2021-01-21 16:20 ` Sergey Bronnikov via Tarantool-patches
2021-01-26 10:26 ` Artem via Tarantool-patches
2021-01-18 12:45 ` [Tarantool-patches] [PATCHv4 2/3] test: add separated module for proccess operations with timeout Artem Starshov via Tarantool-patches
2021-01-18 12:45 ` [Tarantool-patches] [PATCHv4 3/3] test: change -e assert(false) test using process_timeout module Artem Starshov via Tarantool-patches
2021-01-21 16:23 ` Sergey Bronnikov via Tarantool-patches [this message]
2021-01-26 10:25 ` Artem via Tarantool-patches
2021-01-18 12:47 ` [Tarantool-patches] [PATCHv4 0/3] test: -e assert(false) fixup Artem via Tarantool-patches
2021-01-21 16:23 ` Sergey Bronnikov via Tarantool-patches
2021-01-27 13:19 ` Kirill Yukhin via Tarantool-patches
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=5ac4ae75-ce23-3f84-e91d-f0c4f4a50763@tarantool.org \
--to=tarantool-patches@dev.tarantool.org \
--cc=alexander.turenko@tarantool.org \
--cc=artemreyt@tarantool.org \
--cc=sergeyb@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCHv4 3/3] test: change -e assert(false) test using process_timeout module' \
/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