Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH v3] Add status/messages upstream/downstream checker
@ 2019-04-16 17:32 avtikhon
  2019-04-18 17:02 ` [tarantool-patches] " Alexander Turenko
  0 siblings, 1 reply; 2+ messages in thread
From: avtikhon @ 2019-04-16 17:32 UTC (permalink / raw)
  To: alexander.turenko; +Cc: avtikhon, tarantool-patches

Added the common routine that check the upstream
and downstream status either message or both.
Wait default timeout until the given status and the message
will match the given pattern, if some flags are nil then it
will not be checked. When message is box.NULL expects
box.info.replication[id].message to be nil or box.NULL.

Close #158
---
 test_run.lua | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/test_run.lua b/test_run.lua
index 42d5e56..d0935e3 100644
--- a/test_run.lua
+++ b/test_run.lua
@@ -227,6 +227,42 @@ local function switch(self, node)
     return self:cmd(switch_cmd3:format(node))
 end
 
+local function gen_box_info_replication_cond(id, status, message, field)
+    return function()
+        local info = box.info.replication[id][field]
+        local ok = true
+        if status ~= nil then
+            ok = ok and info.status == status
+        end
+        if message ~= nil then
+            ok = ok and info.message ~= nil and info.message:match(message)
+        elseif type(message) ~= 'nil' then
+            ok = ok and info.message == nil
+        end
+        return not not ok
+    end
+end
+
+-- Wait default timeout until the given status and the message
+-- will match the given pattern, if some flags are nil then it
+-- will not be checked.
+-- when message is box.NULL expects
+-- box.info.replication[id].message to be nil or box.NULL.
+local function wait_upstream(self, id, status, message)
+    return self:wait_cond(gen_box_info_replication_cond(id, status, message,
+                                                        'upstream'))
+end
+
+-- Wait default timeout until the given status and the message
+-- will match the given pattern, if some flags are nil then it
+-- will not be checked.
+-- When message is box.NULL expects
+-- box.info.replication[id].message to be nil or box.NULL.
+local function wait_downstream(self, id, status, message)
+    return self:wait_cond(gen_box_info_replication_cond(id, status, message,
+                                                        'downstream'))
+end
+
 local get_cfg_cmd = 'config %s'
 
 local function get_cfg(self, name)
@@ -360,6 +396,8 @@ local inspector_methods = {
     wait_fullmesh = wait_fullmesh,
     get_cluster_vclock = get_cluster_vclock,
     wait_cluster_vclock = wait_cluster_vclock,
+    wait_downstream = wait_downstream,
+    wait_upstream = wait_upstream,
     --
     grep_log = grep_log,
     wait_cond = wait_cond,
-- 
2.17.1

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-18 17:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-16 17:32 [tarantool-patches] [PATCH v3] Add status/messages upstream/downstream checker avtikhon
2019-04-18 17:02 ` [tarantool-patches] " Alexander Turenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox