Skip to content

Commit bddcef7

Browse files
committed
Allow to use unix socket for non-default servers
It allows to mitigate the error 'Address already in use' while binding admin (console) port. Check [1] for more information (see comment itself, the issue is about the another problem). Unified boolean suite.ini options parsing. [1]: #115 (comment)
1 parent 3f8c83c commit bddcef7

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

lib/preprocessor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ def server_create(self, ctype, sname, opts):
211211
if 'rpl_master' in opts:
212212
temp.rpl_master = self.servers[opts['rpl_master']]
213213
temp.vardir = self.suite_ini['vardir']
214+
temp.use_unix_sockets = self.suite_ini['use_unix_sockets']
214215
temp.inspector_port = int(self.suite_ini.get(
215216
'inspector_port', temp.DEFAULT_INSPECTOR
216217
))

lib/tarantool_server.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,9 @@ def install(self, silent=True):
514514
self.copy_files()
515515

516516
if self.use_unix_sockets:
517-
self._admin = os.path.join(self.vardir, "socket-admin")
517+
path = os.path.join(self.vardir, self.name + ".socket-admin")
518+
warn_unix_socket(path)
519+
self._admin = path
518520
else:
519521
self._admin = find_port()
520522

lib/test_suite.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,19 @@ def get_multirun_params(self, test_path):
6161
result = self.multi_run.get('*', None)
6262
return result
6363

64+
def parse_bool_opt(self, name, default):
65+
val = self.ini.get(name)
66+
if val is None:
67+
self.ini[name] = default
68+
elif isinstance(val, bool):
69+
pass
70+
elif isinstance(val, str) and val.lower() in ('true', 'false'):
71+
# If value is not boolean it come from ini file, need to convert
72+
# string 'True' or 'False' into boolean representation.
73+
self.ini[name] = val.lower() == 'true'
74+
else:
75+
raise ConfigurationError(name, val, "'True' or 'False'")
76+
6477
def __init__(self, suite_path, args):
6578
"""Initialize a test suite: check that it exists and contains
6679
a syntactically correct configuration file. Then create
@@ -97,8 +110,9 @@ def __init__(self, suite_path, args):
97110
dict.fromkeys(self.ini[i].split())
98111
if i in self.ini else dict())
99112

100-
self.ini.update(
101-
dict(show_reproduce_content=self.show_reproduce_content()))
113+
self.parse_bool_opt('use_unix_sockets', False)
114+
self.parse_bool_opt('is_parallel', False)
115+
self.parse_bool_opt('show_reproduce_content', False)
102116

103117
def find_tests(self):
104118
if self.ini['core'] == 'tarantool':
@@ -201,23 +215,7 @@ def run_test(self, test, server, inspector):
201215
return short_status
202216

203217
def is_parallel(self):
204-
val = self.ini.get('is_parallel', 'false')
205-
if isinstance(val, bool):
206-
return val
207-
# If value is not boolean it come from ini file, need to
208-
# convert string 'True' or 'False' into boolean representation
209-
if val.lower() not in ['true', 'false']:
210-
raise ConfigurationError('is_parallel', val, "'True' or 'False'")
211-
return val.lower() == 'true'
218+
return self.ini['is_parallel']
212219

213220
def show_reproduce_content(self):
214-
val = self.ini.get('show_reproduce_content', 'true')
215-
if isinstance(val, bool):
216-
return val
217-
# If value is not boolean it come from ini file, need to
218-
# convert string 'True' or 'False' into boolean representation
219-
if val.lower() not in ['true', 'false']:
220-
raise ConfigurationError('show_reproduce_content',
221-
val,
222-
"'True' or 'False'")
223-
return val.lower() == 'true'
221+
return self.ini['show_reproduce_content']

0 commit comments

Comments
 (0)