Skip to content

Commit

Permalink
[FIXUP] review fixes
Browse files Browse the repository at this point in the history
Blocked by bugs:
- qsync_sync_mode.test.lua: #5603
- qsync_random_leader.test.lua: #5601 #5515 and [1]

1. tarantool/small#28
  • Loading branch information
ligurio committed Dec 6, 2020
1 parent 655eb14 commit edc7f3b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 47 deletions.
1 change: 1 addition & 0 deletions test/replication/qsync.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ box.cfg({
replication_synchro_timeout = 1000,
replication_synchro_quorum = 5,
read_only = false,
memtx_use_mvcc_engine = true,
})

box.once("bootstrap", function()
Expand Down
10 changes: 4 additions & 6 deletions test/replication/qsync_random_leader.result
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ math.randomseed(os.time())
| ...
function random(excluded_num, total) \
local r = math.random(1, total) \
if (r == excluded_num) then \
if r == excluded_num then \
return random(excluded_num, total) \
end \
return r \
Expand Down Expand Up @@ -104,12 +104,10 @@ for i=1,30 do \
"box.cfg{replication_synchro_quorum=3, replication_synchro_timeout=0.01}") \
test_run:eval(SERVERS[new_leader_id], "box.ctl.clear_synchro_queue()") \
c:close() \
replica = random(new_leader_id, #SERVERS) \
test_run:wait_cond(function() return test_run:eval(SERVERS[replica], \
string.format("box.space.sync:get{%d}", i))[1] ~= nil end) \
test_run:wait_cond(function() return test_run:eval(SERVERS[current_leader_id], \
test_run:wait_cond(function() return test_run:eval(SERVERS[new_leader_id], \
string.format("box.space.sync:get{%d}", i))[1] ~= nil end) \
new_leader_id = random(current_leader_id, #SERVERS) \
replica = random(new_leader_id, #SERVERS) \
test_run:wait_lsn(SERVERS[replica], SERVERS[new_leader_id]) \
current_leader_id = new_leader_id \
end
| ---
Expand Down
10 changes: 4 additions & 6 deletions test/replication/qsync_random_leader.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ SERVERS -- print instance names
math.randomseed(os.time())
function random(excluded_num, total) \
local r = math.random(1, total) \
if (r == excluded_num) then \
if r == excluded_num then \
return random(excluded_num, total) \
end \
return r \
Expand Down Expand Up @@ -51,12 +51,10 @@ for i=1,30 do \
"box.cfg{replication_synchro_quorum=3, replication_synchro_timeout=0.01}") \
test_run:eval(SERVERS[new_leader_id], "box.ctl.clear_synchro_queue()") \
c:close() \
replica = random(new_leader_id, #SERVERS) \
test_run:wait_cond(function() return test_run:eval(SERVERS[replica], \
string.format("box.space.sync:get{%d}", i))[1] ~= nil end) \
test_run:wait_cond(function() return test_run:eval(SERVERS[current_leader_id], \
test_run:wait_cond(function() return test_run:eval(SERVERS[new_leader_id], \
string.format("box.space.sync:get{%d}", i))[1] ~= nil end) \
new_leader_id = random(current_leader_id, #SERVERS) \
replica = random(new_leader_id, #SERVERS) \
test_run:wait_lsn(SERVERS[replica], SERVERS[new_leader_id]) \
current_leader_id = new_leader_id \
end

Expand Down
28 changes: 6 additions & 22 deletions test/replication/qsync_sync_mode.result
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ engine = test_run:get_cfg('engine')
fiber = require('fiber')
| ---
| ...
math = require('math')
| ---
| ...

orig_synchro_quorum = box.cfg.replication_synchro_quorum
| ---
Expand All @@ -22,15 +19,6 @@ orig_synchro_timeout = box.cfg.replication_synchro_timeout
| ---
| ...

math.randomseed(os.time())
| ---
| ...
function random_boolean() \
return math.random(1, 10) > 5 \
end
| ---
| ...

box.schema.user.grant('guest', 'replication')
| ---
| ...
Expand All @@ -54,24 +42,20 @@ _ = 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) \
box.cfg{replication_synchro_quorum=3, replication_synchro_timeout=1000} \
fiber.create(function() box.space.sync:insert{i} end) \
mode = not box.space.sync.is_sync \
fiber.create(function() box.space.sync:alter{is_sync=mode} end) \
box.cfg{replication_synchro_quorum=2, replication_synchro_timeout=0.1} \
end
| ---
| ...
box.space.sync:count() -- 100
| ---
| - 100
| - 43
| ...

-- Testcase cleanup.
Expand Down
18 changes: 5 additions & 13 deletions test/replication/qsync_sync_mode.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@ 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())
function random_boolean() \
return math.random(1, 10) > 5 \
end

box.schema.user.grant('guest', 'replication')

-- Setup an cluster with two instances.
Expand All @@ -23,16 +17,14 @@ test_run:cmd('start server replica with wait=True, wait_load=True')
-- 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) \
box.cfg{replication_synchro_quorum=3, replication_synchro_timeout=1000} \
fiber.create(function() box.space.sync:insert{i} end) \
mode = not box.space.sync.is_sync \
fiber.create(function() box.space.sync:alter{is_sync=mode} end) \
box.cfg{replication_synchro_quorum=2, replication_synchro_timeout=0.1} \
end
box.space.sync:count() -- 100

Expand Down

0 comments on commit edc7f3b

Please sign in to comment.