From: Vladislav Shpilevoy via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Serge Petrenko <sergepetrenko@tarantool.org>, tarantool-patches@dev.tarantool.org, vdavydov@tarantool.org Subject: Re: [Tarantool-patches] [PATCH 8/9] luatest: add new helpers for 'server' object Date: Fri, 12 Nov 2021 00:51:05 +0100 [thread overview] Message-ID: <2d0c8543-7191-0e62-cce0-98e35b07cade@tarantool.org> (raw) In-Reply-To: <03971784-b1d0-1366-f03b-2e10fce807f6@tarantool.org> Thanks for the review! >> diff --git a/test/luatest_helpers/server.lua b/test/luatest_helpers/server.lua >> index b6d6f1400..9959bca6c 100644 >> --- a/test/luatest_helpers/server.lua >> +++ b/test/luatest_helpers/server.lua >> @@ -75,28 +75,45 @@ function Server:build_env() >> return res >> end >> -function Server:wait_for_readiness() >> - local alias = self.alias >> - local id = self.id >> - local pid = self.process.pid >> +local function wait_cond(cond_name, server, func, ...) >> + local alias = server.alias >> + local id = server.id >> + local pid = server.process.pid >> local deadline = clock.time() + WAIT_TIMEOUT >> while true do >> - local ok, is_ready = pcall(function() >> - self:connect_net_box() >> - return self.net_box:eval('return _G.ready') == true >> - end) >> - if ok and is_ready then >> - break >> + if func(...) then >> + return >> end >> if clock.time() > deadline then >> - error(('Starting of server %s-%s (PID %d) was timed out'):format( >> - alias, id, pid)) >> + error(('Waiting for "%s" on server %s-%s (PID %d) timed out') >> + :format(alias, id, pid)) > > 1. Looks like you forgot to use "cond_name" in the error message. ==================== Yes indeed, thanks for noticing: error(('Waiting for "%s" on server %s-%s (PID %d) timed out') - :format(alias, id, pid)) + :format(cond_name, alias, id, pid)) end ==================== >> @@ -116,6 +133,29 @@ function Server:start(opts) >> end >> end >> +function Server:instance_id() >> + -- Cache the value when found it first time. >> + if self.instance_id_value then >> + return self.instance_id_value >> + end >> + local id = self:exec(function() return box.info.id end) >> + -- But do not cache 0 - it is an anon instance, its ID might change. >> + if id ~= 0 then >> + self.instance_id_value = id >> + end >> + return id >> +end > > 2. Let's reset cached instance id in Server:cleanup(). > One might want to call Server:cleanup() and then restart the server > making it receive a new instance id. Thanks, done: ==================== @@ -186,6 +186,8 @@ function Server:cleanup() for _, pattern in ipairs(DEFAULT_CHECKPOINT_PATTERNS) do fio.rmtree(('%s/%s'):format(self.workdir, pattern)) end + self.instance_id_value = nil + self.instance_uuid_value = nil end ====================
next prev parent reply other threads:[~2021-11-11 23:51 UTC|newest] Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-05 23:56 [Tarantool-patches] [PATCH 0/9] ER_READONLY reason Vladislav Shpilevoy via Tarantool-patches 2021-11-05 23:56 ` [Tarantool-patches] [PATCH 1/9] diag: return created error from diag_set() Vladislav Shpilevoy via Tarantool-patches 2021-11-05 23:56 ` [Tarantool-patches] [PATCH 2/9] error: introduce error_payload Vladislav Shpilevoy via Tarantool-patches 2021-11-08 15:14 ` Serge Petrenko via Tarantool-patches 2021-11-11 23:50 ` Vladislav Shpilevoy via Tarantool-patches 2021-11-12 6:29 ` Serge Petrenko via Tarantool-patches 2021-11-05 23:56 ` [Tarantool-patches] [PATCH 3/9] error: move code to struct error from ClientError Vladislav Shpilevoy via Tarantool-patches 2021-11-08 15:15 ` Serge Petrenko via Tarantool-patches 2021-11-11 23:50 ` Vladislav Shpilevoy via Tarantool-patches 2021-11-12 6:31 ` Serge Petrenko via Tarantool-patches 2021-11-05 23:56 ` [Tarantool-patches] [PATCH 4/9] error: use error_payload to store optional members Vladislav Shpilevoy via Tarantool-patches 2021-11-05 23:56 ` [Tarantool-patches] [PATCH 5/9] error: use error_payload in MessagePack codecs Vladislav Shpilevoy via Tarantool-patches 2021-11-05 23:56 ` [Tarantool-patches] [PATCH 6/9] error: use error_payload in Lua Vladislav Shpilevoy via Tarantool-patches 2021-11-05 23:56 ` [Tarantool-patches] [PATCH 7/9] luatest: copy config in cluster:build_server() Vladislav Shpilevoy via Tarantool-patches 2021-11-05 23:56 ` [Tarantool-patches] [PATCH 8/9] luatest: add new helpers for 'server' object Vladislav Shpilevoy via Tarantool-patches 2021-11-08 15:16 ` Serge Petrenko via Tarantool-patches 2021-11-11 23:51 ` Vladislav Shpilevoy via Tarantool-patches [this message] 2021-11-05 23:56 ` [Tarantool-patches] [PATCH 9/9] box: enrich ER_READONLY with new details Vladislav Shpilevoy via Tarantool-patches 2021-11-06 19:30 ` Cyrill Gorcunov via Tarantool-patches 2021-11-07 16:45 ` Vladislav Shpilevoy via Tarantool-patches 2021-11-07 20:19 ` Cyrill Gorcunov via Tarantool-patches 2021-11-08 15:18 ` Serge Petrenko via Tarantool-patches 2021-11-11 23:52 ` Vladislav Shpilevoy via Tarantool-patches 2021-11-08 14:25 ` [Tarantool-patches] [PATCH 0/9] ER_READONLY reason Vladimir Davydov 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=2d0c8543-7191-0e62-cce0-98e35b07cade@tarantool.org \ --to=tarantool-patches@dev.tarantool.org \ --cc=sergepetrenko@tarantool.org \ --cc=v.shpilevoy@tarantool.org \ --cc=vdavydov@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH 8/9] luatest: add new helpers for '\''server'\'' object' \ /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