server.stop() server.script = script server.deploy() print '-------------------------------------------------------------' print 'Start a new replica and check box.info on the start' print '-------------------------------------------------------------' # master server master = server master_id = master.get_param('server')['id'] master.admin("box.schema.user.grant('guest', 'replication')") replica = TarantoolServer(server.ini) replica.script = 'replication-py/replica.lua' replica.vardir = server.vardir replica.rpl_master = master replica.deploy() replica.wait_lsn(master_id, master.get_lsn(master_id)) replica_id = replica.get_param('server')['id'] replica_uuid = replica.get_param('server')['uuid'] sys.stdout.push_filter(replica_uuid, '<replica uuid>') replica.admin('box.info.server.id == %d' % replica_id) replica.admin('not box.info.server.ro') replica.admin('box.info.server.lsn == 0') replica.admin('box.info.vclock[%d] == 0' % replica_id) print '-------------------------------------------------------------' print 'Modify data to change LSN and check box.info' print '-------------------------------------------------------------'
from __future__ import print_function import os import sys import re import yaml from lib.tarantool_server import TarantoolServer server = TarantoolServer(server.ini) server.script = "long_run-py/lua/finalizers.lua" server.vardir = os.path.join(server.vardir, "finalizers") server.crash_expected = True try: server.deploy() except: print("Expected error:", sys.exc_info()[0]) else: print("Error! exception did not occur")
try: s = con.space('test') print(s.select()) except NetworkError: print('NetworkError !') except Exception as e: print(e) # Start instances master = server cluster = [master] for i in range(INSTANCE_N): server = TarantoolServer(server.ini) server.script = 'cluster-py/instance%d.lua' % (i+1) server.vardir = os.path.join(server.vardir, 'instance', str(i)) server.deploy() server.admin("box.schema.user.grant('guest', 'read,write,execute', 'universe')") server.admin("_ = box.schema.space.create('test')") server.admin("_ = box.space.test:create_index('primary')") server.admin("box.space.test:insert{%d, %s}" % (1, i), silent = True) cluster.append(server) # Make a list of servers sources = [] for server in cluster[1:]: sources.append(yaml.safe_load(server.admin('box.cfg.listen', silent=True))[0]) addrs = [] for addr in sources: addrs.append({'host': None, 'port': addr})
master.admin( "space = box.schema.space.create('test', { id = 99999, engine = \"sophia\" })" ) master.admin("index = space:create_index('primary', { type = 'tree'})") master.admin('for k = 1, 123 do space:insert{k, k*k} end') master.admin('box.snapshot()') lsn = master.get_lsn(master_id) print '-------------------------------------------------------------' print 'replica JOIN' print '-------------------------------------------------------------' # replica server replica = TarantoolServer(server.ini) replica.script = 'replication/replica.lua' replica.vardir = server.vardir #os.path.join(server.vardir,'replica') replica.rpl_master = master replica.deploy() replica.wait_lsn(master_id, lsn) replica.admin('box.space.test:select()') replica.stop() replica.cleanup(True) # remove space master.admin("space:drop()") master.admin('box.snapshot()') master.admin("ffi = require('ffi')") master.admin("ffi.cdef(\"int sophia_schedule(void);\")") master.admin("ffi.C.sophia_schedule() >= 0")
import os from glob import iglob as glob from lib.tarantool_server import TarantoolServer # master server master = server master_id = master.get_param('server')['id'] master.admin("box.schema.user.grant('guest', 'replication')") replica = TarantoolServer(server.ini) replica.script = 'replication/replica.lua' replica.vardir = server.vardir #os.path.join(server.vardir, 'replica') replica.rpl_master = master replica.deploy() replica.wait_lsn(master_id, master.get_lsn(master_id)) replica_id = replica.get_param('server')['id'] replica.admin('box.info.server.id') replica.admin('box.info.server.ro') replica.admin('box.info.server.lsn') replica.stop() print '-------------------------------------------------------------' print 'replica is read-only until receive self server_id in _cluster' print '-------------------------------------------------------------' # Remove xlog retrived by SUBSCRIBE filename = str(0).zfill(20) + ".xlog" wal = os.path.join(os.path.join(replica.vardir, replica.name), filename) os.remove(wal)
master = server master.admin("fiber = require('fiber')") master.admin("box.schema.user.grant('guest', 'replication')") master.admin("box.schema.user.grant('guest', 'execute', 'universe')") print '----------------------------------------------------------------------' print 'Bootstrap replicas' print '----------------------------------------------------------------------' # Start replicas master.id = master.get_param('id') cluster = [master] for i in range(REPLICA_N - 1): server = TarantoolServer(server.ini) server.script = 'replication-py/replica.lua' server.vardir = os.path.join(server.vardir, 'replica', str(master.id + i)) server.rpl_master = master server.deploy() # Wait replica to fully bootstrap. # Otherwise can get ACCESS_DENIED error. cluster.append(server) # Make a list of servers sources = [] for server in cluster: sources.append( yaml.safe_load(server.admin('box.cfg.listen', silent=True))[0]) server.id = server.get_param('id') print 'done'
from lib.tarantool_server import TarantoolServer from time import sleep import yaml def check_replication(nodes, select_args=''): for node in nodes: node.admin('box.space.test:select{%s}' % select_args) master = server master.admin("box.schema.user.grant('guest', 'replication')") replica = TarantoolServer(server.ini) replica.script = 'replication-py/replica.lua' replica.vardir = server.vardir replica.rpl_master = master replica.deploy() def parallel_run(cmd1, cmd2, compare): print 'parallel send: %s' % cmd1 print 'parallel send: %s' % cmd2 master.admin.socket.sendall('%s\n' % cmd1) replica.admin.socket.sendall('%s\n' % cmd2) master.admin.socket.recv(2048) replica.admin.socket.recv(2048) # wait for status changing in tarantool master_status = yaml.load(
server.stop() server.script = script server.deploy() print '-------------------------------------------------------------' print 'Start a new replica and check box.info on the start' print '-------------------------------------------------------------' # master server master = server master_id = master.get_param('server')['id'] master.admin("box.schema.user.grant('guest', 'replication')") replica = TarantoolServer(server.ini) replica.script = 'replication/replica.lua' replica.vardir = server.vardir replica.rpl_master = master replica.deploy() replica.wait_lsn(master_id, master.get_lsn(master_id)) replica_id = replica.get_param('server')['id'] replica_uuid = replica.get_param('server')['uuid'] sys.stdout.push_filter(replica_uuid, '<replica uuid>') replica.admin('box.info.server.id == %d' % replica_id) replica.admin('not box.info.server.ro') replica.admin('box.info.server.lsn == 0') replica.admin('box.info.vclock[%d] == 0' % replica_id) print '-------------------------------------------------------------' print 'Modify data to change LSN and check box.info' print '-------------------------------------------------------------'
server.script = script server.deploy() print '-------------------------------------------------------------' print 'gh-527: update vclock on delete from box.space._cluster' print '-------------------------------------------------------------' # master server master = server master_id = master.get_param('server')['id'] master.admin("box.schema.user.grant('guest', 'replication')") replica = TarantoolServer(server.ini) replica.script = 'replication/replica.lua' replica.vardir = server.vardir replica.rpl_master = master replica.deploy() replica.wait_lsn(master_id, master.get_lsn(master_id)) replica_id = replica.get_param('server')['id'] replica_uuid = replica.get_param('server')['uuid'] sys.stdout.push_filter(replica_uuid, '<replica uuid>') replica.admin('box.space._schema:insert{"test", 48}') replica.admin('box.info.server.id') replica.admin('box.info.server.ro') replica.admin('box.info.server.lsn') # 1 replica.admin('box.info.vclock[%d]' % replica_id) master.admin('box.space._cluster:delete{%d}' % replica_id) replica.wait_lsn(master_id, master.get_lsn(master_id))
import os import sys import re import yaml from lib.tarantool_server import TarantoolServer server = TarantoolServer(server.ini) server.script = 'long_run/lua/finalizers.lua' server.vardir = os.path.join(server.vardir, 'finalizers') try: server.deploy() except: print "Expected error:", sys.exc_info()[0] else: print "Error! exception did not occur"
master.admin("fiber = require('fiber')") master.admin("box.schema.user.grant('guest', 'replication')") master.admin("box.schema.user.grant('guest', 'execute', 'universe')") print '----------------------------------------------------------------------' print 'Bootstrap replicas' print '----------------------------------------------------------------------' # Start replicas master.id = master.get_param('server')['id'] master_lsn = master.get_lsn(master.id) cluster = [ master ] for i in range(REPLICA_N - 1): server = TarantoolServer(server.ini) server.script = 'replication/replica.lua' server.vardir = os.path.join(server.vardir, 'replica', str(master.id + i)) server.rpl_master = master server.deploy() # Wait replica to fully bootstrap. # Otherwise can get ACCESS_DENIED error. server.wait_lsn(master.id, master_lsn) cluster.append(server) # Make a list of servers sources = [] for server in cluster: sources.append(yaml.load(server.admin('box.cfg.listen', silent = True))[0]) server.id = server.get_param('server')['id'] print 'done'
import os import re import time from lib.tarantool_server import TarantoolServer # master server master = server master.admin("box.schema.user.grant('guest', 'read,write,execute', 'universe')") # replica server replica = TarantoolServer() replica.script = "replication/replica.lua" replica.rpl_master = master replica.vardir = os.path.join(master.vardir, 'replica') replica.deploy() replica.get_param('node') cycles = 0 status = replica.admin.execute_no_reconnect("box.info.status", True) while (re.search(r'replica/.*/(connecting|connected)\n', status) == None and cycles < 500): time.sleep(0.01) status = replica.admin.execute_no_reconnect("box.info.status", True) cycles += 1 print(re.search(r'replica/.*/(connecting|connected)\n', status) != None) master.stop() cycles = 0 while (re.search(r'replica/.*/(connecting|failed)\n', status) == None and cycles < 500):
import os import re import time from lib.tarantool_server import TarantoolServer # master server master = server master.admin( "box.schema.user.grant('guest', 'read,write,execute', 'universe')") # replica server replica = TarantoolServer() replica.script = "replication/replica.lua" replica.rpl_master = master replica.vardir = os.path.join(master.vardir, 'replica') replica.deploy() replica.get_param('node') cycles = 0 status = replica.admin.execute_no_reconnect("box.info.status", True) while (re.search(r'replica/.*/(connecting|connected)\n', status) == None and cycles < 500): time.sleep(0.01) status = replica.admin.execute_no_reconnect("box.info.status", True) cycles += 1 print(re.search(r'replica/.*/(connecting|connected)\n', status) != None) master.stop() cycles = 0