Tarantool development patches archive
 help / color / mirror / Atom feed
From: sergeyb@tarantool.org
To: tarantool-patches@dev.tarantool.org, v.shpilevoy@tarantool.org,
	sergepetrenko@tarantool.org
Subject: [Tarantool-patches] [PATCH 3/3 v2] replication: add test with change space sync mode in a loop
Date: Thu, 12 Nov 2020 12:11:01 +0300	[thread overview]
Message-ID: <508f66c80ca243afd1a0044bda250ae3cb618c32.1605170394.git.sergeyb@tarantool.org> (raw)
In-Reply-To: <cover.1605170394.git.sergeyb@tarantool.org>

From: Sergey Bronnikov <sergeyb@tarantool.org>

Closes #5055
Part of #5144
---
 test/replication/qsync_sync_mode.result   | 114 ++++++++++++++++++++++
 test/replication/qsync_sync_mode.test.lua |  56 +++++++++++
 2 files changed, 170 insertions(+)
 create mode 100644 test/replication/qsync_sync_mode.result
 create mode 100644 test/replication/qsync_sync_mode.test.lua

diff --git a/test/replication/qsync_sync_mode.result b/test/replication/qsync_sync_mode.result
new file mode 100644
index 000000000..66f6a70b2
--- /dev/null
+++ b/test/replication/qsync_sync_mode.result
@@ -0,0 +1,114 @@
+-- test-run result file version 2
+env = require('test_run')
+ | ---
+ | ...
+test_run = env.new()
+ | ---
+ | ...
+engine = test_run:get_cfg('engine')
+ | ---
+ | ...
+fiber = require('fiber')
+ | ---
+ | ...
+math = require('math')
+ | ---
+ | ...
+
+orig_synchro_quorum = box.cfg.replication_synchro_quorum
+ | ---
+ | ...
+orig_synchro_timeout = box.cfg.replication_synchro_timeout
+ | ---
+ | ...
+
+math.randomseed(os.time())
+ | ---
+ | ...
+random_boolean = function()                                                    \
+    if (math.random(1, 10) > 5) then                                           \
+        return true                                                            \
+    else                                                                       \
+        return false                                                           \
+    end                                                                        \
+end
+ | ---
+ | ...
+
+box.schema.user.grant('guest', 'replication')
+ | ---
+ | ...
+
+-- Setup an cluster with two instances.
+test_run:cmd('create server replica with rpl_master=default,\
+                                         script="replication/replica.lua"')
+ | ---
+ | - true
+ | ...
+test_run:cmd('start server replica with wait=True, wait_load=True')
+ | ---
+ | - true
+ | ...
+
+-- Write data to a leader and enable/disable sync mode in a loop.
+-- Testcase setup.
+_ = box.schema.space.create('sync', {is_sync=true, engine=engine})
+ | ---
+ | ...
+_ = box.space.sync:create_index('pk')
+ | ---
+ | ...
+box.cfg{replication_synchro_quorum=2, replication_synchro_timeout=1000}
+ | ---
+ | ...
+
+-- Testcase body.
+for i = 1,100 do                                                               \
+    box.space.sync:alter{is_sync=random_boolean()}                             \
+    box.space.sync:insert{i}                                                   \
+    test_run:switch('replica')                                                 \
+    test_run:wait_cond(function() return box.space.sync:get{i} ~= nil end)     \
+    test_run:switch('default')                                                 \
+    test_run:wait_cond(function() return box.space.sync:get{i} ~= nil end)     \
+end
+ | ---
+ | ...
+box.space.sync:count() -- 100
+ | ---
+ | - 100
+ | ...
+
+-- Testcase cleanup.
+test_run:switch('default')
+ | ---
+ | - true
+ | ...
+box.space.sync:drop()
+ | ---
+ | ...
+
+-- Teardown.
+test_run:cmd('switch default')
+ | ---
+ | - true
+ | ...
+test_run:cmd('stop server replica')
+ | ---
+ | - true
+ | ...
+test_run:cmd('delete server replica')
+ | ---
+ | - true
+ | ...
+test_run:cleanup_cluster()
+ | ---
+ | ...
+box.schema.user.revoke('guest', 'replication')
+ | ---
+ | ...
+box.cfg{                                                                       \
+    replication_synchro_quorum = orig_synchro_quorum,                          \
+    replication_synchro_timeout = orig_synchro_timeout,                        \
+}
+ | ---
+ | ...
diff --git a/test/replication/qsync_sync_mode.test.lua b/test/replication/qsync_sync_mode.test.lua
new file mode 100644
index 000000000..ea5725169
--- /dev/null
+++ b/test/replication/qsync_sync_mode.test.lua
@@ -0,0 +1,56 @@
+env = require('test_run')
+test_run = env.new()
+engine = test_run:get_cfg('engine')
+fiber = require('fiber')
+math = require('math')
+
+orig_synchro_quorum = box.cfg.replication_synchro_quorum
+orig_synchro_timeout = box.cfg.replication_synchro_timeout
+
+math.randomseed(os.time())
+random_boolean = function()                                                    \
+    if (math.random(1, 10) > 5) then                                           \
+        return true                                                            \
+    else                                                                       \
+        return false                                                           \
+    end                                                                        \
+end
+
+box.schema.user.grant('guest', 'replication')
+
+-- Setup an cluster with two instances.
+test_run:cmd('create server replica with rpl_master=default,\
+                                         script="replication/replica.lua"')
+test_run:cmd('start server replica with wait=True, wait_load=True')
+
+-- Write data to a leader and enable/disable sync mode in a loop.
+-- Testcase setup.
+_ = box.schema.space.create('sync', {is_sync=true, engine=engine})
+_ = box.space.sync:create_index('pk')
+box.cfg{replication_synchro_quorum=2, replication_synchro_timeout=1000}
+
+-- Testcase body.
+for i = 1,100 do                                                               \
+    box.space.sync:alter{is_sync=random_boolean()}                             \
+    box.space.sync:insert{i}                                                   \
+    test_run:switch('replica')                                                 \
+    test_run:wait_cond(function() return box.space.sync:get{i} ~= nil end)     \
+    test_run:switch('default')                                                 \
+    test_run:wait_cond(function() return box.space.sync:get{i} ~= nil end)     \
+end
+box.space.sync:count() -- 100
+
+-- Testcase cleanup.
+test_run:switch('default')
+box.space.sync:drop()
+
+-- Teardown.
+test_run:cmd('switch default')
+test_run:cmd('stop server replica')
+test_run:cmd('delete server replica')
+test_run:cleanup_cluster()
+box.schema.user.revoke('guest', 'replication')
+box.cfg{                                                                       \
+    replication_synchro_quorum = orig_synchro_quorum,                          \
+    replication_synchro_timeout = orig_synchro_timeout,                        \
+}
-- 
2.25.1

  parent reply	other threads:[~2020-11-12  9:11 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-12  9:10 [Tarantool-patches] [PATCH 0/3 v2] Additional qsync tests sergeyb
2020-11-12  9:10 ` [Tarantool-patches] [PATCH 1/3 v2] replication: test clear_synchro_queue() function sergeyb
2020-11-13 13:12   ` Serge Petrenko
2020-11-16 11:11     ` Sergey Bronnikov
2020-11-16 14:44       ` Serge Petrenko
2020-11-12  9:10 ` [Tarantool-patches] [PATCH 2/3 v2] replication: add test with random leaders promotion and demotion sergeyb
2020-11-13 15:10   ` Serge Petrenko
2020-11-16  9:10     ` Sergey Bronnikov
2020-11-16 14:00       ` Sergey Bronnikov
2020-11-16 14:48         ` Serge Petrenko
2020-11-16 14:53           ` Serge Petrenko
2020-11-16 16:04             ` Sergey Bronnikov
2020-11-12  9:11 ` sergeyb [this message]
2020-11-13 14:05   ` [Tarantool-patches] [PATCH 3/3 v2] replication: add test with change space sync mode in a loop Serge Petrenko

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=508f66c80ca243afd1a0044bda250ae3cb618c32.1605170394.git.sergeyb@tarantool.org \
    --to=sergeyb@tarantool.org \
    --cc=sergepetrenko@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH 3/3 v2] replication: add test with change space sync mode in a loop' \
    /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