Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move tarantoolctl to test-run tool submodule and add replication_sync_timeout to it #242

Merged
merged 3 commits into from
Dec 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .tarantoolctl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- Options for test-run tarantoolctl

-- Note: tonumber(nil) is nil.
local workdir = os.getenv('TEST_WORKDIR')
local replication_sync_timeout = tonumber(os.getenv('REPLICATION_SYNC_TIMEOUT'))

default_cfg = {
pid_file = workdir,
wal_dir = workdir,
memtx_dir = workdir,
vinyl_dir = workdir,
log = workdir,
background = false,
replication_sync_timeout = replication_sync_timeout,
}

instance_dir = workdir

-- vim: set ft=lua :
6 changes: 6 additions & 0 deletions lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ def module_init():
os.chdir(path)
setenv()

# Keep the PWD environment variable in sync with a current
# working directory. It does not strictly necessary, just to
# avoid any confusion.
os.environ['PWD'] = os.getcwd()

warn_unix_sockets_at_start(args.vardir)

# always run with clean (non-existent) 'var' directory
Expand All @@ -52,6 +57,7 @@ def module_init():
soext = sys.platform == 'darwin' and 'dylib' or 'so'
os.environ["LUA_PATH"] = SOURCEDIR+"/?.lua;"+SOURCEDIR+"/?/init.lua;;"
os.environ["LUA_CPATH"] = BUILDDIR+"/?."+soext+";;"
os.environ["REPLICATION_SYNC_TIMEOUT"] = str(args.replication_sync_timeout)

TarantoolServer.find_exe(args.builddir)
UnittestServer.find_exe(args.builddir)
Expand Down
14 changes: 14 additions & 0 deletions lib/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,20 @@ def __init__(self):
--valgrind, --long options is passed).
Note: The option works now only with parallel testing.""")

parser.add_argument(
"--replication-sync-timeout",
dest="replication_sync_timeout",
default=100,
type=int,
help="""The number of seconds that a replica will wait when
trying to sync with a master in a cluster, or a quorum of
masters, after connecting or during configuration update.
This could fail indefinitely if replication_sync_lag is smaller
than network latency, or if the replica cannot keep pace with
master updates. If replication_sync_timeout expires, the replica
enters orphan status.
Default: 100 [seconds].""")

parser.add_argument(
"--luacov",
dest="luacov",
Expand Down
19 changes: 18 additions & 1 deletion lib/tarantool_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,15 @@ def copy_files(self):
if (e.errno == errno.ENOENT):
continue
raise
shutil.copy('.tarantoolctl', self.vardir)
# Previously tarantoolctl configuration file located in tarantool
# repository at test/ directory. Currently it is located in root
# path of test-run/ submodule repository. For backward compatibility
# this file should be checked at the old place and only after at
# the current.
tntctl_file = '.tarantoolctl'
if not os.path.exists(tntctl_file):
tntctl_file = os.path.join(self.TEST_RUN_DIR, '.tarantoolctl')
shutil.copy(tntctl_file, self.vardir)
shutil.copy(os.path.join(self.TEST_RUN_DIR, 'test_run.lua'),
self.vardir)
# Need to use get here because of nondefault servers doesn't have ini.
Expand Down Expand Up @@ -848,6 +856,12 @@ def start(self, silent=True, wait=True, wait_load=True, rais=True, args=[],
os.putenv("MASTER", self.rpl_master.iproto.uri)
self.logfile_pos = self.logfile

# This is strange, but tarantooctl leans on the PWD
# environment variable, not a real current working
# directory, when it performs search for the
# .tarantoolctl configuration file.
os.environ['PWD'] = self.vardir

# redirect stdout from tarantoolctl and tarantool
os.putenv("TEST_WORKDIR", self.vardir)
self.process = subprocess.Popen(args,
Expand All @@ -856,6 +870,9 @@ def start(self, silent=True, wait=True, wait_load=True, rais=True, args=[],
stderr=self.log_des)
del(self.log_des)

# Restore the actual PWD value.
os.environ['PWD'] = os.getcwd()

# gh-19 crash detection
self.crash_detector = TestRunGreenlet(self.crash_detect)
self.crash_detector.info = "Crash detector: %s" % self.process
Expand Down