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

#234 use master/worker terminology #268

Merged
merged 8 commits into from
Feb 6, 2018
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dist/
include/
lib/
bin/
env/
xdist/_version.py*
pytest_xdist.egg-info
issue/
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

If a test crashes the interpreter, pytest-xdist will automatically restart
that slave and report the failure as usual. You can use the
``--max-slave-restart`` option to limit the number of slaves that can
be restarted, or disable restarting altogether using ``--max-slave-restart=0``.
that worker and report the failure as usual. You can use the
``--max-worker-restart`` option to limit the number of workers that can
be restarted, or disable restarting altogether using ``--max-worker-restart=0``.


Running tests in a Python subprocess
Expand Down
1 change: 1 addition & 0 deletions changelog/234.trivial
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Change terminology used by ``pytest-xdist`` to *master* and *worker* in arguments and messages (for example ``--max-worker-reset``).
78 changes: 39 additions & 39 deletions testing/acceptance_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,23 +196,23 @@ def test_data_exchange(self, testdir):
testdir.makeconftest("""
# This hook only called on master.
def pytest_configure_node(node):
node.slaveinput['a'] = 42
node.slaveinput['b'] = 7
node.workerinput['a'] = 42
node.workerinput['b'] = 7

def pytest_configure(config):
# this attribute is only set on slaves
if hasattr(config, 'slaveinput'):
a = config.slaveinput['a']
b = config.slaveinput['b']
# this attribute is only set on workers
if hasattr(config, 'workerinput'):
a = config.workerinput['a']
b = config.workerinput['b']
r = a + b
config.slaveoutput['r'] = r
config.workeroutput['r'] = r

# This hook only called on master.
def pytest_testnodedown(node, error):
node.config.calc_result = node.slaveoutput['r']
node.config.calc_result = node.workeroutput['r']

def pytest_terminal_summary(terminalreporter):
if not hasattr(terminalreporter.config, 'slaveinput'):
if not hasattr(terminalreporter.config, 'workerinput'):
calc_result = terminalreporter.config.calc_result
terminalreporter._tw.sep('-',
'calculated result is %s' % calc_result)
Expand All @@ -232,12 +232,12 @@ def test_hello():
""")
testdir.makeconftest("""
def pytest_sessionfinish(session):
# on the slave
if hasattr(session.config, 'slaveoutput'):
session.config.slaveoutput['s2'] = 42
# on the worker
if hasattr(session.config, 'workeroutput'):
session.config.workeroutput['s2'] = 42
# on the master
def pytest_testnodedown(node, error):
assert node.slaveoutput['s2'] == 42
assert node.workeroutput['s2'] == 42
print ("s2call-finished")
""")
args = ["-n1", "--debug"]
Expand Down Expand Up @@ -411,7 +411,7 @@ def teardown_function(function):
def test_terminate_on_hangingnode(testdir):
p = testdir.makeconftest("""
def pytest_sessionfinish(session):
if session.nodeid == "my": # running on slave
if session.nodeid == "my": # running on worker
import time
time.sleep(3)
""")
Expand All @@ -429,15 +429,15 @@ def test_session_hooks(testdir):
def pytest_sessionstart(session):
sys.pytestsessionhooks = session
def pytest_sessionfinish(session):
if hasattr(session.config, 'slaveinput'):
name = "slave"
if hasattr(session.config, 'workerinput'):
name = "worker"
else:
name = "master"
f = open(name, "w")
f.write("xy")
f.close()
# let's fail on the slave
if name == "slave":
# let's fail on the worker
if name == "worker":
raise ValueError(42)
""")
p = testdir.makepyfile("""
Expand All @@ -453,14 +453,14 @@ def test_hello():
assert not result.ret
d = result.parseoutcomes()
assert d['passed'] == 1
assert testdir.tmpdir.join("slave").check()
assert testdir.tmpdir.join("worker").check()
assert testdir.tmpdir.join("master").check()


def test_session_testscollected(testdir):
"""
Make sure master node is updating the session object with the number
of tests collected from the slaves.
of tests collected from the workers.
"""
testdir.makepyfile(test_foo="""
import pytest
Expand Down Expand Up @@ -667,8 +667,8 @@ def test_b(): pass
""")
res = testdir.runpytest(f, '-n1')
res.stdout.fnmatch_lines([
"*Replacing crashed slave*",
"*Slave*crashed while running*",
"*Replacing crashed worker*",
"*Worker*crashed while running*",
"*1 failed*1 passed*",
])

Expand All @@ -682,8 +682,8 @@ def test_d(): pass
""")
res = testdir.runpytest(f, '-n2')
res.stdout.fnmatch_lines([
"*Replacing crashed slave*",
"*Slave*crashed while running*",
"*Replacing crashed worker*",
"*Worker*crashed while running*",
"*1 failed*3 passed*",
])

Expand All @@ -695,8 +695,8 @@ def test_b(): pass
""")
res = testdir.runpytest(f, '--dist=each', '--tx=popen')
res.stdout.fnmatch_lines([
"*Replacing crashed slave*",
"*Slave*crashed while running*",
"*Replacing crashed worker*",
"*Worker*crashed while running*",
"*1 failed*1 passed*",
])

Expand All @@ -709,34 +709,34 @@ def test_b(): pass
""")
res = testdir.runpytest(f, '--dist=each', '--tx=2*popen')
res.stdout.fnmatch_lines([
"*Replacing crashed slave*",
"*Slave*crashed while running*",
"*Replacing crashed worker*",
"*Worker*crashed while running*",
"*2 failed*2 passed*",
])

def test_max_slave_restart(self, testdir):
def test_max_worker_restart(self, testdir):
f = testdir.makepyfile("""
import os
def test_a(): pass
def test_b(): os._exit(1)
def test_c(): os._exit(1)
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([
"*Replacing crashed slave*",
"*Maximum crashed slaves reached: 1*",
"*Slave*crashed while running*",
"*Slave*crashed while running*",
"*Replacing crashed worker*",
"*Maximum crashed workers reached: 1*",
"*Worker*crashed while running*",
"*Worker*crashed while running*",
"*2 failed*2 passed*",
])

def test_max_slave_restart_die(self, testdir):
def test_max_worker_restart_die(self, testdir):
f = testdir.makepyfile("""
import os
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([
"*Unexpectedly no active workers*",
"*INTERNALERROR*"
Expand All @@ -749,10 +749,10 @@ def test_a(): pass
def test_b(): os._exit(1)
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([
"*Slave restarting disabled*",
"*Slave*crashed while running*",
"*Worker restarting disabled*",
"*Worker*crashed while running*",
"*1 failed*2 passed*",
])

Expand Down
2 changes: 1 addition & 1 deletion testing/test_dsession.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def test_add_remove_node(self, testdir):
def test_different_tests_collected(self, testdir):
"""
Test that LoadScheduling is reporting collection errors when
different test ids are collected by slaves.
different test ids are collected by workers.
"""

class CollectHook(object):
Expand Down
10 changes: 5 additions & 5 deletions testing/test_newhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def test_runtest_logreport(self, testdir):
def pytest_runtest_logreport(report):
if hasattr(report, 'node'):
if report.when == "call":
slaveid = report.node.slaveinput['slaveid']
if slaveid != report.worker_id:
workerid = report.node.workerinput['workerid']
if workerid != report.worker_id:
print("HOOK: Worker id mismatch: %s %s"
% (slaveid, report.worker_id))
% (workerid, report.worker_id))
else:
print("HOOK: %s %s"
% (report.nodeid, report.worker_id))
Expand All @@ -41,9 +41,9 @@ def test_node_collection_finished(self, testdir):
"""
testdir.makeconftest("""
def pytest_xdist_node_collection_finished(node, ids):
slaveid = node.slaveinput['slaveid']
workerid = node.workerinput['workerid']
stripped_ids = [x.split('::')[1] for x in ids]
print("HOOK: %s %s" % (slaveid, ', '.join(stripped_ids)))
print("HOOK: %s %s" % (workerid, ', '.join(stripped_ids)))
""")
res = testdir.runpytest('-n2', '-s')
res.stdout.fnmatch_lines_random([
Expand Down
2 changes: 1 addition & 1 deletion testing/test_plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import py
import execnet
from xdist.slavemanage import NodeManager
from xdist.workermanage import NodeManager


def test_dist_incompatibility_messages(testdir):
Expand Down
Loading