Skip to content

Commit

Permalink
Add arguments to replication test instances.
Browse files Browse the repository at this point in the history
Add start arguments to replication test instances to control
replication_timeout and replication_connect_timeout settings between
restarts.

Prerequisite #3428
  • Loading branch information
sergepetrenko committed Aug 13, 2018
1 parent 785170d commit 4645470
Show file tree
Hide file tree
Showing 38 changed files with 122 additions and 77 deletions.
2 changes: 1 addition & 1 deletion test/replication-py/init_storage.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

server.stop()
replica = TarantoolServer(server.ini)
replica.script = 'replication/replica.lua'
replica.script = 'replication-py/replica.lua'
replica.vardir = server.vardir #os.path.join(server.vardir, 'replica')
replica.rpl_master = master
replica.deploy(wait=False)
Expand Down
1 change: 1 addition & 0 deletions test/replication-py/master.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ os = require('os')
box.cfg({
listen = os.getenv("LISTEN"),
memtx_memory = 107374182,
replication_timeout = 0.1
})

require('console').listen(os.getenv('ADMIN'))
1 change: 1 addition & 0 deletions test/replication-py/replica.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ box.cfg({
listen = os.getenv("LISTEN"),
replication = os.getenv("MASTER"),
memtx_memory = 107374182,
replication_timeout = 0.1
})

box_cfg_done = true
6 changes: 5 additions & 1 deletion test/replication/autobootstrap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ local INSTANCE_ID = string.match(arg[0], "%d")
local USER = 'cluster'
local PASSWORD = 'somepassword'
local SOCKET_DIR = require('fio').cwd()
local TIMEOUT = tonumber(arg[1])
local CON_TIMEOUT = arg[2] and tonumber(arg[2]) or 30.0

local function instance_uri(instance_id)
--return 'localhost:'..(3310 + instance_id)
return SOCKET_DIR..'/autobootstrap'..instance_id..'.sock';
Expand All @@ -21,7 +24,8 @@ box.cfg({
USER..':'..PASSWORD..'@'..instance_uri(2);
USER..':'..PASSWORD..'@'..instance_uri(3);
};
replication_connect_timeout = 0.5,
replication_timeout = TIMEOUT;
replication_connect_timeout = CON_TIMEOUT;
})

box.once("bootstrap", function()
Expand Down
4 changes: 2 additions & 2 deletions test/replication/autobootstrap.result
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SERVERS = { 'autobootstrap1', 'autobootstrap2', 'autobootstrap3' }
--
-- Start servers
--
test_run:create_cluster(SERVERS)
test_run:create_cluster(SERVERS, "replication", {args="0.1"})
---
...
--
Expand Down Expand Up @@ -161,7 +161,7 @@ box.space.test_u:select()
_ = test_run:cmd("switch autobootstrap1")
---
...
_ = test_run:cmd("restart server autobootstrap1 with cleanup=1")
_ = test_run:cmd("restart server autobootstrap1 with cleanup=1, args ='0.1 0.5'")
_ = box.space.test_u:replace({5, 6, 7, 8})
---
...
Expand Down
4 changes: 2 additions & 2 deletions test/replication/autobootstrap.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SERVERS = { 'autobootstrap1', 'autobootstrap2', 'autobootstrap3' }
--
-- Start servers
--
test_run:create_cluster(SERVERS)
test_run:create_cluster(SERVERS, "replication", {args="0.1"})

--
-- Wait for full mesh
Expand Down Expand Up @@ -76,7 +76,7 @@ box.space.test_u:select()
-- Rebootstrap one node and check that others follow.
--
_ = test_run:cmd("switch autobootstrap1")
_ = test_run:cmd("restart server autobootstrap1 with cleanup=1")
_ = test_run:cmd("restart server autobootstrap1 with cleanup=1, args ='0.1 0.5'")

_ = box.space.test_u:replace({5, 6, 7, 8})
box.space.test_u:select()
Expand Down
7 changes: 6 additions & 1 deletion test/replication/autobootstrap_guest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
local INSTANCE_ID = string.match(arg[0], "%d")

local SOCKET_DIR = require('fio').cwd()

local TIMEOUT = tonumber(arg[1])
local CON_TIMEOUT = arg[2] and tonumber(arg[2]) or 30.0

local function instance_uri(instance_id)
--return 'localhost:'..(3310 + instance_id)
return SOCKET_DIR..'/autobootstrap_guest'..instance_id..'.sock';
Expand All @@ -20,7 +24,8 @@ box.cfg({
instance_uri(2);
instance_uri(3);
};
replication_connect_timeout = 0.5,
replication_timeout = TIMEOUT;
replication_connect_timeout = CON_TIMEOUT;
})

box.once("bootstrap", function()
Expand Down
2 changes: 1 addition & 1 deletion test/replication/autobootstrap_guest.result
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ SERVERS = { 'autobootstrap_guest1', 'autobootstrap_guest2', 'autobootstrap_guest
--
-- Start servers
--
test_run:create_cluster(SERVERS)
test_run:create_cluster(SERVERS, "replication", {args="0.1"})
---
...
--
Expand Down
2 changes: 1 addition & 1 deletion test/replication/autobootstrap_guest.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SERVERS = { 'autobootstrap_guest1', 'autobootstrap_guest2', 'autobootstrap_guest
--
-- Start servers
--
test_run:create_cluster(SERVERS)
test_run:create_cluster(SERVERS, "replication", {args="0.1"})

--
-- Wait for full mesh
Expand Down
8 changes: 4 additions & 4 deletions test/replication/before_replace.result
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ SERVERS = { 'autobootstrap1', 'autobootstrap2', 'autobootstrap3' }
---
...
-- Deploy a cluster.
test_run:create_cluster(SERVERS)
test_run:create_cluster(SERVERS, "replication", {args="0.1"})
---
...
test_run:wait_fullmesh(SERVERS)
Expand Down Expand Up @@ -125,7 +125,7 @@ box.space.test:select()
- [9, 90]
- [10, 100]
...
test_run:cmd('restart server autobootstrap1')
test_run:cmd('restart server autobootstrap1 with args="0.1 0.5"')
box.space.test:select()
---
- - [1, 10]
Expand Down Expand Up @@ -156,7 +156,7 @@ box.space.test:select()
- [9, 90]
- [10, 100]
...
test_run:cmd('restart server autobootstrap2')
test_run:cmd('restart server autobootstrap2 with args="0.1 0.5"')
box.space.test:select()
---
- - [1, 10]
Expand Down Expand Up @@ -187,7 +187,7 @@ box.space.test:select()
- [9, 90]
- [10, 100]
...
test_run:cmd('restart server autobootstrap3')
test_run:cmd('restart server autobootstrap3 with args="0.1 0.5"')
box.space.test:select()
---
- - [1, 10]
Expand Down
8 changes: 4 additions & 4 deletions test/replication/before_replace.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test_run = env.new()
SERVERS = { 'autobootstrap1', 'autobootstrap2', 'autobootstrap3' }

-- Deploy a cluster.
test_run:create_cluster(SERVERS)
test_run:create_cluster(SERVERS, "replication", {args="0.1"})
test_run:wait_fullmesh(SERVERS)

-- Setup space:before_replace trigger on all replicas.
Expand Down Expand Up @@ -54,15 +54,15 @@ vclock2 = test_run:wait_cluster_vclock(SERVERS, vclock)
-- and the state persists after restart.
test_run:cmd("switch autobootstrap1")
box.space.test:select()
test_run:cmd('restart server autobootstrap1')
test_run:cmd('restart server autobootstrap1 with args="0.1 0.5"')
box.space.test:select()
test_run:cmd("switch autobootstrap2")
box.space.test:select()
test_run:cmd('restart server autobootstrap2')
test_run:cmd('restart server autobootstrap2 with args="0.1 0.5"')
box.space.test:select()
test_run:cmd("switch autobootstrap3")
box.space.test:select()
test_run:cmd('restart server autobootstrap3')
test_run:cmd('restart server autobootstrap3 with args="0.1 0.5"')
box.space.test:select()


Expand Down
2 changes: 1 addition & 1 deletion test/replication/catch.result
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test_run:cmd("create server replica with rpl_master=default, script='replication
---
- true
...
test_run:cmd("start server replica with args='1'")
test_run:cmd("start server replica with args='0.1'")
---
- true
...
Expand Down
2 changes: 1 addition & 1 deletion test/replication/catch.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ errinj = box.error.injection

box.schema.user.grant('guest', 'replication')
test_run:cmd("create server replica with rpl_master=default, script='replication/replica_timeout.lua'")
test_run:cmd("start server replica with args='1'")
test_run:cmd("start server replica with args='0.1'")
test_run:cmd("switch replica")

test_run:cmd("switch default")
Expand Down
7 changes: 6 additions & 1 deletion test/replication/ddl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ local INSTANCE_ID = string.match(arg[0], "%d")
local USER = 'cluster'
local PASSWORD = 'somepassword'
local SOCKET_DIR = require('fio').cwd()

local TIMEOUT = tonumber(arg[1])
local CON_TIMEOUT = arg[2] and tonumber(arg[2]) or 30.0

local function instance_uri(instance_id)
--return 'localhost:'..(3310 + instance_id)
return SOCKET_DIR..'/autobootstrap'..instance_id..'.sock';
Expand All @@ -22,7 +26,8 @@ box.cfg({
USER..':'..PASSWORD..'@'..instance_uri(3);
USER..':'..PASSWORD..'@'..instance_uri(4);
};
replication_connect_timeout = 0.5,
replication_timeout = TIMEOUT,
replication_connect_timeout = CON_TIMEOUT,
})

box.once("bootstrap", function()
Expand Down
2 changes: 1 addition & 1 deletion test/replication/ddl.result
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SERVERS = { 'ddl1', 'ddl2', 'ddl3', 'ddl4' }
---
...
-- Deploy a cluster.
test_run:create_cluster(SERVERS)
test_run:create_cluster(SERVERS, "replication", {args="0.1"})
---
...
test_run:wait_fullmesh(SERVERS)
Expand Down
2 changes: 1 addition & 1 deletion test/replication/ddl.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ test_run = require('test_run').new()
SERVERS = { 'ddl1', 'ddl2', 'ddl3', 'ddl4' }

-- Deploy a cluster.
test_run:create_cluster(SERVERS)
test_run:create_cluster(SERVERS, "replication", {args="0.1"})
test_run:wait_fullmesh(SERVERS)
test_run:cmd("switch ddl1")
test_run = require('test_run').new()
Expand Down
6 changes: 3 additions & 3 deletions test/replication/errinj.result
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ test_run:cmd("create server replica_timeout with rpl_master=default, script='rep
---
- true
...
test_run:cmd("start server replica_timeout with args='0.01'")
test_run:cmd("start server replica_timeout with args='0.01 0.5'")
---
- true
...
Expand Down Expand Up @@ -474,7 +474,7 @@ errinj.set("ERRINJ_RELAY_REPORT_INTERVAL", 0)
...
-- Check replica's ACKs don't prevent the master from sending
-- heartbeat messages (gh-3160).
test_run:cmd("start server replica_timeout with args='0.009'")
test_run:cmd("start server replica_timeout with args='0.009 0.5'")
---
- true
...
Expand Down Expand Up @@ -522,7 +522,7 @@ for i = 0, 9999 do box.space.test:replace({i, 4, 5, 'test'}) end
-- during the join stage, i.e. a replica with a minuscule
-- timeout successfully bootstraps and breaks connection only
-- after subscribe.
test_run:cmd("start server replica_timeout with args='0.00001'")
test_run:cmd("start server replica_timeout with args='0.00001 0.5'")
---
- true
...
Expand Down
6 changes: 3 additions & 3 deletions test/replication/errinj.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ errinj.set("ERRINJ_RELAY_EXIT_DELAY", 0)
box.cfg{replication_timeout = 0.01}

test_run:cmd("create server replica_timeout with rpl_master=default, script='replication/replica_timeout.lua'")
test_run:cmd("start server replica_timeout with args='0.01'")
test_run:cmd("start server replica_timeout with args='0.01 0.5'")
test_run:cmd("switch replica_timeout")

fiber = require('fiber')
Expand All @@ -199,7 +199,7 @@ errinj.set("ERRINJ_RELAY_REPORT_INTERVAL", 0)
-- Check replica's ACKs don't prevent the master from sending
-- heartbeat messages (gh-3160).

test_run:cmd("start server replica_timeout with args='0.009'")
test_run:cmd("start server replica_timeout with args='0.009 0.5'")
test_run:cmd("switch replica_timeout")

fiber = require('fiber')
Expand All @@ -219,7 +219,7 @@ for i = 0, 9999 do box.space.test:replace({i, 4, 5, 'test'}) end
-- during the join stage, i.e. a replica with a minuscule
-- timeout successfully bootstraps and breaks connection only
-- after subscribe.
test_run:cmd("start server replica_timeout with args='0.00001'")
test_run:cmd("start server replica_timeout with args='0.00001 0.5'")
test_run:cmd("switch replica_timeout")
fiber = require('fiber')
while box.info.replication[1].upstream.message ~= 'timed out' do fiber.sleep(0.0001) end
Expand Down
1 change: 1 addition & 0 deletions test/replication/master.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ box.cfg({
listen = os.getenv("LISTEN"),
memtx_memory = 107374182,
replication_connect_timeout = 0.5,
replication_timeout = 0.1
})

require('console').listen(os.getenv('ADMIN'))
7 changes: 6 additions & 1 deletion test/replication/master_quorum.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
local INSTANCE_ID = string.match(arg[0], "%d")

local SOCKET_DIR = require('fio').cwd()

local TIMEOUT = tonumber(arg[1])
local CON_TIMEOUT = arg[2] and tonumber(arg[2]) or 30.0

local function instance_uri(instance_id)
--return 'localhost:'..(3310 + instance_id)
return SOCKET_DIR..'/master_quorum'..instance_id..'.sock';
Expand All @@ -20,7 +24,8 @@ box.cfg({
instance_uri(2);
};
replication_connect_quorum = 0;
replication_connect_timeout = 0.1;
replication_timeout = TIMEOUT;
replication_connect_timeout = CON_TIMEOUT;
})

test_run = require('test_run').new()
Expand Down
2 changes: 1 addition & 1 deletion test/replication/misc.result
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ SERVERS = { 'autobootstrap1', 'autobootstrap2', 'autobootstrap3' }
---
...
-- Deploy a cluster.
test_run:create_cluster(SERVERS)
test_run:create_cluster(SERVERS, "replication", {args="0.1"})
---
...
test_run:wait_fullmesh(SERVERS)
Expand Down
2 changes: 1 addition & 1 deletion test/replication/misc.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ box.cfg{read_only = false}
SERVERS = { 'autobootstrap1', 'autobootstrap2', 'autobootstrap3' }

-- Deploy a cluster.
test_run:create_cluster(SERVERS)
test_run:create_cluster(SERVERS, "replication", {args="0.1"})
test_run:wait_fullmesh(SERVERS)
test_run:cmd("switch autobootstrap1")
test_run = require('test_run').new()
Expand Down
14 changes: 9 additions & 5 deletions test/replication/on_replace.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ local INSTANCE_ID = string.match(arg[0], "%d")
local USER = 'cluster'
local PASSWORD = 'somepassword'
local SOCKET_DIR = require('fio').cwd()

local TIMEOUT = tonumber(arg[1])
local CON_TIMEOUT = arg[2] and tonumber(arg[2]) or 30.0

local function instance_uri(instance_id)
--return 'localhost:'..(3310 + instance_id)
return SOCKET_DIR..'/on_replace'..instance_id..'.sock';
end

-- start console first
require('console').listen(os.getenv('ADMIN'))
env = require('test_run')
test_run = env.new()
engine = test_run:get_cfg('engine')

box.cfg({
listen = instance_uri(INSTANCE_ID);
Expand All @@ -20,13 +27,10 @@ box.cfg({
USER..':'..PASSWORD..'@'..instance_uri(1);
USER..':'..PASSWORD..'@'..instance_uri(2);
};
replication_connect_timeout = 0.5,
replication_timeout = TIMEOUT,
replication_connect_timeout = CON_TIMEOUT,
})

env = require('test_run')
test_run = env.new()
engine = test_run:get_cfg('engine')

box.once("bootstrap", function()
box.schema.user.create(USER, { password = PASSWORD })
box.schema.user.grant(USER, 'replication')
Expand Down
2 changes: 1 addition & 1 deletion test/replication/on_replace.result
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ box.schema.user.revoke('guest', 'replication')
SERVERS = { 'on_replace1', 'on_replace2' }
---
...
test_run:create_cluster(SERVERS)
test_run:create_cluster(SERVERS, "replication", {args="0.2"})
---
...
test_run:wait_fullmesh(SERVERS)
Expand Down
2 changes: 1 addition & 1 deletion test/replication/on_replace.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ box.schema.user.revoke('guest', 'replication')
-- gh-2682 on_replace on slave server with data change

SERVERS = { 'on_replace1', 'on_replace2' }
test_run:create_cluster(SERVERS)
test_run:create_cluster(SERVERS, "replication", {args="0.2"})
test_run:wait_fullmesh(SERVERS)

test_run:cmd('switch on_replace1')
Expand Down

0 comments on commit 4645470

Please sign in to comment.