From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 62D8245C309 for ; Thu, 3 Dec 2020 17:05:27 +0300 (MSK) Received: by mail-lj1-f171.google.com with SMTP id y16so2664790ljk.1 for ; Thu, 03 Dec 2020 06:05:27 -0800 (PST) From: Cyrill Gorcunov Date: Thu, 3 Dec 2020 17:04:46 +0300 Message-Id: <20201203140446.66312-4-gorcunov@gmail.com> In-Reply-To: <20201203140446.66312-1-gorcunov@gmail.com> References: <20201203140446.66312-1-gorcunov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v3 3/3] test: add replication/gh-5446-sqync-eval-quorum.test.lua List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: tml Cc: Mons Anderson , Vladislav Shpilevoy Part-of #5446 Signed-off-by: Cyrill Gorcunov --- .../gh-5446-sqync-eval-quorum.result | 156 ++++++++++++++++++ .../gh-5446-sqync-eval-quorum.test.lua | 62 +++++++ test/replication/replica-quorum-1.lua | 1 + test/replication/replica-quorum-2.lua | 1 + test/replication/replica-quorum-3.lua | 1 + test/replication/replica-quorum-4.lua | 1 + 6 files changed, 222 insertions(+) create mode 100644 test/replication/gh-5446-sqync-eval-quorum.result create mode 100644 test/replication/gh-5446-sqync-eval-quorum.test.lua create mode 120000 test/replication/replica-quorum-1.lua create mode 120000 test/replication/replica-quorum-2.lua create mode 120000 test/replication/replica-quorum-3.lua create mode 120000 test/replication/replica-quorum-4.lua diff --git a/test/replication/gh-5446-sqync-eval-quorum.result b/test/replication/gh-5446-sqync-eval-quorum.result new file mode 100644 index 000000000..14050aa4b --- /dev/null +++ b/test/replication/gh-5446-sqync-eval-quorum.result @@ -0,0 +1,156 @@ +-- test-run result file version 2 +test_run = require('test_run').new() + | --- + | ... +engine = test_run:get_cfg('engine') + | --- + | ... + +box.schema.user.grant('guest', 'replication') + | --- + | ... + +box.cfg { replication_synchro_quorum = "N/2+1", replication_synchro_timeout = 1000 } + | --- + | ... + +test_run:cmd('create server replica1 with rpl_master=default,\ + script="replication/replica-quorum-1.lua"') + | --- + | - true + | ... +test_run:cmd('start server replica1 with wait=True, wait_load=True') + | --- + | - true + | ... + +test_run:cmd('create server replica2 with rpl_master=default,\ + script="replication/replica-quorum-2.lua"') + | --- + | - true + | ... +test_run:cmd('start server replica2 with wait=True, wait_load=True') + | --- + | - true + | ... + +test_run:cmd('create server replica3 with rpl_master=default,\ + script="replication/replica-quorum-3.lua"') + | --- + | - true + | ... +test_run:cmd('start server replica3 with wait=True, wait_load=True') + | --- + | - true + | ... + +test_run:cmd('create server replica4 with rpl_master=default,\ + script="replication/replica-quorum-4.lua"') + | --- + | - true + | ... +test_run:cmd('start server replica4 with wait=True, wait_load=True') + | --- + | - true + | ... + +_ = box.schema.space.create('sync', {is_sync = true, engine = engine}) + | --- + | ... +s = box.space.sync + | --- + | ... + +s:format({{name = 'id', type = 'unsigned'}, {name = 'band_name', type = 'string'}}) + | --- + | ... + +_ = s:create_index('primary', {parts = {'id'}}) + | --- + | ... +s:insert({1, '1'}) + | --- + | - [1, '1'] + | ... +s:insert({2, '2'}) + | --- + | - [2, '2'] + | ... +s:insert({3, '3'}) + | --- + | - [3, '3'] + | ... + +-- Wait the data to be propagated, there is no much +-- need for this since we're testing the quorum number +-- update only but just in case. +test_run:wait_lsn('replica1', 'default') + | --- + | ... +test_run:wait_lsn('replica2', 'default') + | --- + | ... +test_run:wait_lsn('replica3', 'default') + | --- + | ... +test_run:wait_lsn('replica4', 'default') + | --- + | ... + +-- Make sure we were configured in a proper way +match = 'set \'replication_synchro_quorum\' configuration option to \"N\\/2%+1' + | --- + | ... +test_run:grep_log("default", match) ~= nil + | --- + | - true + | ... + +-- There are 4 replicas -> replication_synchro_quorum = 4/2 + 1 = 3 +match = 'update replication_synchro_quorum = 3' + | --- + | ... +test_run:grep_log("default", match) ~= nil + | --- + | - true + | ... + +test_run:cmd('stop server replica1') + | --- + | - true + | ... +test_run:cmd('delete server replica1') + | --- + | - true + | ... + +test_run:cmd('stop server replica2') + | --- + | - true + | ... +test_run:cmd('delete server replica2') + | --- + | - true + | ... + +test_run:cmd('stop server replica3') + | --- + | - true + | ... +test_run:cmd('delete server replica3') + | --- + | - true + | ... + +test_run:cmd('stop server replica4') + | --- + | - true + | ... +test_run:cmd('delete server replica4') + | --- + | - true + | ... + +box.schema.user.revoke('guest', 'replication') + | --- + | ... diff --git a/test/replication/gh-5446-sqync-eval-quorum.test.lua b/test/replication/gh-5446-sqync-eval-quorum.test.lua new file mode 100644 index 000000000..8a188e5b2 --- /dev/null +++ b/test/replication/gh-5446-sqync-eval-quorum.test.lua @@ -0,0 +1,62 @@ +test_run = require('test_run').new() +engine = test_run:get_cfg('engine') + +box.schema.user.grant('guest', 'replication') + +box.cfg { replication_synchro_quorum = "N/2+1", replication_synchro_timeout = 1000 } + +test_run:cmd('create server replica1 with rpl_master=default,\ + script="replication/replica-quorum-1.lua"') +test_run:cmd('start server replica1 with wait=True, wait_load=True') + +test_run:cmd('create server replica2 with rpl_master=default,\ + script="replication/replica-quorum-2.lua"') +test_run:cmd('start server replica2 with wait=True, wait_load=True') + +test_run:cmd('create server replica3 with rpl_master=default,\ + script="replication/replica-quorum-3.lua"') +test_run:cmd('start server replica3 with wait=True, wait_load=True') + +test_run:cmd('create server replica4 with rpl_master=default,\ + script="replication/replica-quorum-4.lua"') +test_run:cmd('start server replica4 with wait=True, wait_load=True') + +_ = box.schema.space.create('sync', {is_sync = true, engine = engine}) +s = box.space.sync + +s:format({{name = 'id', type = 'unsigned'}, {name = 'band_name', type = 'string'}}) + +_ = s:create_index('primary', {parts = {'id'}}) +s:insert({1, '1'}) +s:insert({2, '2'}) +s:insert({3, '3'}) + +-- Wait the data to be propagated, there is no much +-- need for this since we're testing the quorum number +-- update only but just in case. +test_run:wait_lsn('replica1', 'default') +test_run:wait_lsn('replica2', 'default') +test_run:wait_lsn('replica3', 'default') +test_run:wait_lsn('replica4', 'default') + +-- Make sure we were configured in a proper way +match = 'set \'replication_synchro_quorum\' configuration option to \"N\\/2%+1' +test_run:grep_log("default", match) ~= nil + +-- There are 4 replicas -> replication_synchro_quorum = 4/2 + 1 = 3 +match = 'update replication_synchro_quorum = 3' +test_run:grep_log("default", match) ~= nil + +test_run:cmd('stop server replica1') +test_run:cmd('delete server replica1') + +test_run:cmd('stop server replica2') +test_run:cmd('delete server replica2') + +test_run:cmd('stop server replica3') +test_run:cmd('delete server replica3') + +test_run:cmd('stop server replica4') +test_run:cmd('delete server replica4') + +box.schema.user.revoke('guest', 'replication') diff --git a/test/replication/replica-quorum-1.lua b/test/replication/replica-quorum-1.lua new file mode 120000 index 000000000..da69ac81c --- /dev/null +++ b/test/replication/replica-quorum-1.lua @@ -0,0 +1 @@ +replica.lua \ No newline at end of file diff --git a/test/replication/replica-quorum-2.lua b/test/replication/replica-quorum-2.lua new file mode 120000 index 000000000..da69ac81c --- /dev/null +++ b/test/replication/replica-quorum-2.lua @@ -0,0 +1 @@ +replica.lua \ No newline at end of file diff --git a/test/replication/replica-quorum-3.lua b/test/replication/replica-quorum-3.lua new file mode 120000 index 000000000..da69ac81c --- /dev/null +++ b/test/replication/replica-quorum-3.lua @@ -0,0 +1 @@ +replica.lua \ No newline at end of file diff --git a/test/replication/replica-quorum-4.lua b/test/replication/replica-quorum-4.lua new file mode 120000 index 000000000..da69ac81c --- /dev/null +++ b/test/replication/replica-quorum-4.lua @@ -0,0 +1 @@ +replica.lua \ No newline at end of file -- 2.26.2