[Tarantool-patches] [PATCH] Add wait_vclock_ignore0 compare function

Sergey Kaplun skaplun at tarantool.org
Sun Jul 12 18:04:18 MSK 2020


Function wait_vclock is unsuitable for waiting vclock, when there are
inserts in local spaces. Function wait_vclock_ignore0 waits for
corresponding vclock ignoring zero component.

Needed for #3363
---

Branch: https://github.com/tarantool/test-run/tree/skaplun/wait-vclock-ignore0

 test_run.lua | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/test_run.lua b/test_run.lua
index 9a25246..8a44789 100644
--- a/test_run.lua
+++ b/test_run.lua
@@ -94,6 +94,28 @@ local function wait_vclock(self, node, to_vclock)
     end
 end
 
+local function wait_vclock_ignore0(self, node, to_vclock)
+    while true do
+        local vclock = self:get_vclock(node)
+        local ok = true
+        for server_id, to_lsn in pairs(to_vclock) do
+            if server_id ~= 0 then
+                local lsn = vclock[server_id]
+                if lsn == nil or lsn < to_lsn then
+                    ok = false
+                    break
+                end
+            end
+        end
+        if ok then
+            return
+        end
+        log.info("wait vclock: %s to %s", yaml.encode(vclock),
+                 yaml.encode(to_vclock))
+        fiber.sleep(0.001)
+    end
+end
+
 
 local create_cluster_cmd1 = 'create server %s with script="%s/%s.lua"'
 local create_cluster_cmd1_return_listen_uri =
@@ -440,6 +462,7 @@ local inspector_methods = {
     -- vclock
     get_vclock = get_vclock,
     wait_vclock = wait_vclock,
+    wait_vclock_ignore0 = wait_vclock_ignore0,
     switch = switch,
     -- replication
     create_cluster = create_cluster,
-- 
2.24.1



More information about the Tarantool-patches mailing list