use master/worker terminology

This commit is contained in:
feuillemorte
2018-01-16 21:46:43 +03:00
parent 3098f27731
commit f1e6dc4344
6 changed files with 30 additions and 30 deletions

View File

@@ -77,9 +77,9 @@ a lot of IO this can lead to considerable speed ups. This option can
also be set to ``auto`` for automatic detection of the number of CPUs. also be set to ``auto`` for automatic detection of the number of CPUs.
If a test crashes the interpreter, pytest-xdist will automatically restart If a test crashes the interpreter, pytest-xdist will automatically restart
that slave and report the failure as usual. You can use the that worker and report the failure as usual. You can use the
``--max-slave-restart`` option to limit the number of slaves that can ``--max-worker-restart`` option to limit the number of workers that can
be restarted, or disable restarting altogether using ``--max-slave-restart=0``. be restarted, or disable restarting altogether using ``--max-worker-restart=0``.
Running tests in a Python subprocess Running tests in a Python subprocess

View File

@@ -667,8 +667,8 @@ class TestNodeFailure:
""") """)
res = testdir.runpytest(f, '-n1') res = testdir.runpytest(f, '-n1')
res.stdout.fnmatch_lines([ res.stdout.fnmatch_lines([
"*Replacing crashed slave*", "*Replacing crashed worker*",
"*Slave*crashed while running*", "*Worker*crashed while running*",
"*1 failed*1 passed*", "*1 failed*1 passed*",
]) ])
@@ -682,8 +682,8 @@ class TestNodeFailure:
""") """)
res = testdir.runpytest(f, '-n2') res = testdir.runpytest(f, '-n2')
res.stdout.fnmatch_lines([ res.stdout.fnmatch_lines([
"*Replacing crashed slave*", "*Replacing crashed worker*",
"*Slave*crashed while running*", "*Worker*crashed while running*",
"*1 failed*3 passed*", "*1 failed*3 passed*",
]) ])
@@ -695,8 +695,8 @@ class TestNodeFailure:
""") """)
res = testdir.runpytest(f, '--dist=each', '--tx=popen') res = testdir.runpytest(f, '--dist=each', '--tx=popen')
res.stdout.fnmatch_lines([ res.stdout.fnmatch_lines([
"*Replacing crashed slave*", "*Replacing crashed worker*",
"*Slave*crashed while running*", "*Worker*crashed while running*",
"*1 failed*1 passed*", "*1 failed*1 passed*",
]) ])
@@ -709,8 +709,8 @@ class TestNodeFailure:
""") """)
res = testdir.runpytest(f, '--dist=each', '--tx=2*popen') res = testdir.runpytest(f, '--dist=each', '--tx=2*popen')
res.stdout.fnmatch_lines([ res.stdout.fnmatch_lines([
"*Replacing crashed slave*", "*Replacing crashed worker*",
"*Slave*crashed while running*", "*Worker*crashed while running*",
"*2 failed*2 passed*", "*2 failed*2 passed*",
]) ])
@@ -722,12 +722,12 @@ class TestNodeFailure:
def test_c(): os._exit(1) def test_c(): os._exit(1)
def test_d(): pass def test_d(): pass
""") """)
res = testdir.runpytest(f, '-n4', '--max-slave-restart=1') res = testdir.runpytest(f, '-n4', '--max-worker-restart=1')
res.stdout.fnmatch_lines([ res.stdout.fnmatch_lines([
"*Replacing crashed slave*", "*Replacing crashed worker*",
"*Maximum crashed slaves reached: 1*", "*Maximum crashed workers reached: 1*",
"*Slave*crashed while running*", "*Worker*crashed while running*",
"*Slave*crashed while running*", "*Worker*crashed while running*",
"*2 failed*2 passed*", "*2 failed*2 passed*",
]) ])
@@ -736,7 +736,7 @@ class TestNodeFailure:
import os import os
os._exit(1) os._exit(1)
""") """)
res = testdir.runpytest(f, '-n4', '--max-slave-restart=0') res = testdir.runpytest(f, '-n4', '--max-worker-restart=0')
res.stdout.fnmatch_lines([ res.stdout.fnmatch_lines([
"*Unexpectedly no active workers*", "*Unexpectedly no active workers*",
"*INTERNALERROR*" "*INTERNALERROR*"
@@ -749,10 +749,10 @@ class TestNodeFailure:
def test_b(): os._exit(1) def test_b(): os._exit(1)
def test_c(): pass def test_c(): pass
""") """)
res = testdir.runpytest(f, '-n4', '--max-slave-restart=0') res = testdir.runpytest(f, '-n4', '--max-worker-restart=0')
res.stdout.fnmatch_lines([ res.stdout.fnmatch_lines([
"*Slave restarting disabled*", "*Worker restarting disabled*",
"*Slave*crashed while running*", "*Worker*crashed while running*",
"*1 failed*2 passed*", "*1 failed*2 passed*",
]) ])

View File

@@ -371,5 +371,5 @@ def test_remote_env_vars(testdir):
assert os.environ['PYTEST_XDIST_WORKER'] in ('gw0', 'gw1') assert os.environ['PYTEST_XDIST_WORKER'] in ('gw0', 'gw1')
assert os.environ['PYTEST_XDIST_WORKER_COUNT'] == '2' assert os.environ['PYTEST_XDIST_WORKER_COUNT'] == '2'
''') ''')
result = testdir.runpytest('-n2', '--max-slave-restart=0') result = testdir.runpytest('-n2', '--max-worker-restart=0')
assert result.ret == 0 assert result.ret == 0

View File

@@ -46,7 +46,7 @@ class DSession:
self._failed_collection_errors = {} self._failed_collection_errors = {}
self._active_nodes = set() self._active_nodes = set()
self._failed_nodes_count = 0 self._failed_nodes_count = 0
self._max_slave_restart = self.config.getoption('max_slave_restart') self._max_slave_restart = self.config.getoption('max_worker_restart')
if self._max_slave_restart is not None: if self._max_slave_restart is not None:
self._max_slave_restart = int(self._max_slave_restart) self._max_slave_restart = int(self._max_slave_restart)
try: try:
@@ -193,13 +193,13 @@ class DSession:
self._failed_nodes_count > self._max_slave_restart) self._failed_nodes_count > self._max_slave_restart)
if maximum_reached: if maximum_reached:
if self._max_slave_restart == 0: if self._max_slave_restart == 0:
msg = 'Slave restarting disabled' msg = 'Worker restarting disabled'
else: else:
msg = "Maximum crashed slaves reached: %d" % \ msg = "Maximum crashed workers reached: %d" % \
self._max_slave_restart self._max_slave_restart
self.report_line(msg) self.report_line(msg)
else: else:
self.report_line("Replacing crashed slave %s" % node.gateway.id) self.report_line("Replacing crashed worker %s" % node.gateway.id)
self._clone_node(node) self._clone_node(node)
self._active_nodes.remove(node) self._active_nodes.remove(node)
@@ -305,7 +305,7 @@ class DSession:
# XXX count no of failures and retry N times # XXX count no of failures and retry N times
runner = self.config.pluginmanager.getplugin("runner") runner = self.config.pluginmanager.getplugin("runner")
fspath = nodeid.split("::")[0] fspath = nodeid.split("::")[0]
msg = "Slave %r crashed while running %r" % (slave.gateway.id, nodeid) msg = "Worker %r crashed while running %r" % (slave.gateway.id, nodeid)
rep = runner.TestReport(nodeid, (fspath, None, fspath), rep = runner.TestReport(nodeid, (fspath, None, fspath),
(), "failed", msg, "???") (), "failed", msg, "???")
rep.node = slave rep.node = slave

View File

@@ -69,7 +69,7 @@ class RemoteControl(object):
out = py.io.TerminalWriter() out = py.io.TerminalWriter()
if hasattr(self, 'gateway'): if hasattr(self, 'gateway'):
raise ValueError("already have gateway %r" % self.gateway) raise ValueError("already have gateway %r" % self.gateway)
self.trace("setting up slave session") self.trace("setting up worker session")
self.gateway = self.initgateway() self.gateway = self.initgateway()
self.channel = channel = self.gateway.remote_exec( self.channel = channel = self.gateway.remote_exec(
init_slave_session, init_slave_session,
@@ -194,7 +194,7 @@ class SlaveFailSession:
self.collection_failed = True self.collection_failed = True
def main(self): def main(self):
self.DEBUG("SLAVE: received configuration, waiting for command trails") self.DEBUG("WORKER: received configuration, waiting for command trails")
try: try:
command = self.channel.receive() command = self.channel.receive()
except KeyboardInterrupt: except KeyboardInterrupt:

View File

@@ -26,8 +26,8 @@ def pytest_addoption(parser):
help="shortcut for '--dist=load --tx=NUM*popen', " help="shortcut for '--dist=load --tx=NUM*popen', "
"you can use 'auto' here for auto detection CPUs number on " "you can use 'auto' here for auto detection CPUs number on "
"host system") "host system")
group.addoption('--max-slave-restart', action="store", default=None, group.addoption('--max-worker-restart', action="store", default=None,
help="maximum number of slaves that can be restarted " help="maximum number of workers that can be restarted "
"when crashed (set to zero to disable this feature)") "when crashed (set to zero to disable this feature)")
group.addoption( group.addoption(
'--dist', metavar="distmode", '--dist', metavar="distmode",