Class luatest.replica_set
Class to manage groups of Tarantool instances with the same data set.
Add the server object to the replica set.
The added server object should be built via the ReplicaSet:build_server
function.
Parameters:
- server: (tab) Server object to be added to the replica set.
Build a server object and add it to the replica set.
Parameters:
- config: (tab) Configuration for the new server. (optional)
Returns:
table
See also:
- luatest.server.Server:new
Build a server object for the replica set.
Parameters:
- config: (tab) Configuration for the new server. (optional)
Returns:
table
See also:
- luatest.server.Server:new
Delete the server object from the replica set by the given server alias.
Parameters:
- alias: (string) Server alias.
Stop all servers in the replica set and save their artifacts if the test fails.
This function should be used only at the end of the test (after_test
,
after_each
, after_all
hooks) to terminate all server processes in
the replica set. Besides process termination, it saves the contents of
each server working directory to the <vardir>/artifacts
directory
for further analysis if the test fails.
Get the server object from the replica set by the given server alias.
Parameters:
- alias: (string) Server alias.
Returns:
table|nil
Build a replica set object.
Parameters:
- object: Table with the entries listed below. (optional)
- servers: (tab) List of server configurations to build serverobjects from and add them to the new replica set. See an example below. (optional)
Returns:
table
See also:
- luatest.server.Server:new
local ReplicaSet = require('luatest.replica_set')
local Server = require('luatest.server')
local box_cfg = {
replication_timeout = 0.1,
replication_connect_timeout = 10,
replication_sync_lag = 0.01,
replication_connect_quorum = 3,
replication = {
Server.build_listen_uri('replica1'),
Server.build_listen_uri('replica2'),
Server.build_listen_uri('replica3'),
},
}
local replica_set = ReplicaSet:new({
servers = {
{alias = 'replica1', box_cfg = box_cfg},
{alias = 'replica2', box_cfg = box_cfg},
{alias = 'replica3', box_cfg = box_cfg},
}
})
replica_set:start()
replica_set:wait_for_fullmesh()
Start all servers in the replica set. Optionally waits until all servers are ready.
Parameters:
- opts: Table with the entries listed below. (optional)
- wait_until_ready: (bool) Wait until all servers are ready.Defaults to
true
. (optional)
- wait_until_ready: (bool) Wait until all servers are ready.Defaults to
Wait until every node is connected to every other node in the replica set.
Parameters:
- opts: Table with the entries listed below. (optional)
- timeout: (number) Timeout in seconds to wait for full mesh.Defaults to 60. (optional)
- delay: (number) Delay in seconds between attempts to check full mesh.Defaults to 0.1. (optional)