[svn r37502] unify dist_* options and give dist_rsync_roots more precision:
you now specify relative paths (relative to the conftest.py where a dist_rsync_root setting resides) or absolute paths. --HG-- branch : trunk
This commit is contained in:
parent
216919d612
commit
ad127323e3
|
@ -691,9 +691,8 @@ You must create a conftest.py in any parent directory above your tests.
|
||||||
|
|
||||||
The options that you need to specify in that conftest.py file are:
|
The options that you need to specify in that conftest.py file are:
|
||||||
|
|
||||||
* **`dist_hosts`**: a required list of ssh addresses (which each may
|
* `dist_hosts`: a required list of host specifications
|
||||||
include a path, default path is: ``$HOME/pytestcache-HOSTNAME``)
|
* `dist_rsync_roots` - a list of relative locations to copy to the remote machines.
|
||||||
* `dist_rsyncroots` - a list of packages to copy to the remote machines.
|
|
||||||
* `dist_remotepython` - the remote python executable to run.
|
* `dist_remotepython` - the remote python executable to run.
|
||||||
* `dist_nicelevel` - process priority of remote nodes.
|
* `dist_nicelevel` - process priority of remote nodes.
|
||||||
* `dist_boxing` - will run each single test in a separate process
|
* `dist_boxing` - will run each single test in a separate process
|
||||||
|
@ -703,7 +702,7 @@ The options that you need to specify in that conftest.py file are:
|
||||||
Sample configuration::
|
Sample configuration::
|
||||||
|
|
||||||
dist_hosts = ['localhost', 'user@someserver:/tmp/somedir']
|
dist_hosts = ['localhost', 'user@someserver:/tmp/somedir']
|
||||||
dist_rsyncroots = ['pypy', 'py']
|
dist_rsyncroots = ['../pypy', '../py']
|
||||||
dist_remotepython = 'python2.4'
|
dist_remotepython = 'python2.4'
|
||||||
dist_nicelevel = 10
|
dist_nicelevel = 10
|
||||||
dist_boxing = True
|
dist_boxing = True
|
||||||
|
|
|
@ -118,13 +118,6 @@ class Config(object):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return self.conftest.rget(name, path)
|
return self.conftest.rget(name, path)
|
||||||
|
|
||||||
def getvalue_and_confpath(self, name, path=None):
|
|
||||||
""" same as previous, but returns conftest's path
|
|
||||||
as well
|
|
||||||
"""
|
|
||||||
val, mod = self.conftest.rget_with_confmod(name, path)
|
|
||||||
return val, py.path.local(mod.__file__).dirpath()
|
|
||||||
|
|
||||||
def initsession(self):
|
def initsession(self):
|
||||||
""" return an initialized session object. """
|
""" return an initialized session object. """
|
||||||
cls = self._getsessionclass()
|
cls = self._getsessionclass()
|
||||||
|
|
|
@ -51,10 +51,10 @@ class HostRSync(py.execnet.RSync):
|
||||||
dir, base = os.path.split(path)
|
dir, base = os.path.split(path)
|
||||||
if base == '.svn':
|
if base == '.svn':
|
||||||
return False
|
return False
|
||||||
if self.rsync_roots is None or dir != self.sourcedir:
|
if dir != self.sourcedir:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return base in self.rsync_roots
|
return self.rsync_roots is None or path in self.rsync_roots
|
||||||
|
|
||||||
class DummyGateway(object):
|
class DummyGateway(object):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -133,17 +133,17 @@ class RSession(AbstractSession):
|
||||||
super(RSession, self).fixoptions()
|
super(RSession, self).fixoptions()
|
||||||
config = self.config
|
config = self.config
|
||||||
try:
|
try:
|
||||||
config.getvalue('disthosts')
|
config.getvalue('dist_hosts')
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print "You're trying to run RSession without disthosts specified"
|
print "For running ad-hoc distributed tests you need to specify"
|
||||||
print "you need to specify it in your conftest.py (ie. ~/conftest.py)"
|
print "dist_hosts in a local conftest.py file, for example:"
|
||||||
print "for example:"
|
print "for example:"
|
||||||
print " disthosts = ['localhost'] * 4 # for 3 processors"
|
print
|
||||||
print " - or -"
|
print " dist_hosts = ['localhost'] * 4 # for 3 processors"
|
||||||
print " disthosts = ['you@some.remote.com'] # for remote testing"
|
print " dist_hosts = ['you@remote.com', '...'] # for testing on ssh accounts"
|
||||||
print " # with your remote ssh account"
|
print " # with your remote ssh accounts"
|
||||||
print "http://codespeak.net/py/current/doc/test.html#automated-distributed-testing"
|
print
|
||||||
print " for more info..."
|
print "see also: http://codespeak.net/py/current/doc/test.html#automated-distributed-testing"
|
||||||
raise SystemExit
|
raise SystemExit
|
||||||
|
|
||||||
def main(self, reporter=None):
|
def main(self, reporter=None):
|
||||||
|
@ -195,11 +195,22 @@ class RSession(AbstractSession):
|
||||||
""" Read from conftest file the configuration of distributed testing
|
""" Read from conftest file the configuration of distributed testing
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
rsync_roots = self.config.getvalue("distrsync_roots")
|
conftest = self.config.conftest
|
||||||
except:
|
value, mod = conftest.rget_with_confmod('dist_rsync_roots')
|
||||||
rsync_roots = None # all files and directories in the pkgdir
|
except KeyError:
|
||||||
|
rsync_roots = [self.config.topdir] # our best guess likely
|
||||||
|
else:
|
||||||
|
assert isinstance(value, (list,tuple)), value
|
||||||
|
base = py.path.local(mod.__file__).dirpath()
|
||||||
|
print "base", base
|
||||||
|
rsync_roots = [base.join(path, abs=True)
|
||||||
|
for path in value]
|
||||||
|
for root in rsync_roots:
|
||||||
|
assert root.check(dir=1)
|
||||||
|
#rsync_roots = value
|
||||||
|
print "rsync_roots", rsync_roots
|
||||||
sshhosts = [HostInfo(i) for i in
|
sshhosts = [HostInfo(i) for i in
|
||||||
self.config.getvalue("disthosts")]
|
self.config.getvalue("dist_hosts")]
|
||||||
parse_directories(sshhosts)
|
parse_directories(sshhosts)
|
||||||
remotepython = self.config.getvalue("dist_remotepython")
|
remotepython = self.config.getvalue("dist_remotepython")
|
||||||
return sshhosts, remotepython, rsync_roots
|
return sshhosts, remotepython, rsync_roots
|
||||||
|
|
|
@ -76,7 +76,7 @@ class TestRSessionRemote:
|
||||||
def test_example_distribution_minus_x(self):
|
def test_example_distribution_minus_x(self):
|
||||||
tmpdir = py.test.ensuretemp("example_distribution_minus_x")
|
tmpdir = py.test.ensuretemp("example_distribution_minus_x")
|
||||||
tmpdir.ensure("sub", "conftest.py").write(py.code.Source("""
|
tmpdir.ensure("sub", "conftest.py").write(py.code.Source("""
|
||||||
disthosts = [%r]
|
dist_hosts = [%r]
|
||||||
""" % ('localhost',)))
|
""" % ('localhost',)))
|
||||||
tmpdir.ensure("sub", "__init__.py")
|
tmpdir.ensure("sub", "__init__.py")
|
||||||
tmpdir.ensure("sub", "test_one.py").write(py.code.Source("""
|
tmpdir.ensure("sub", "test_one.py").write(py.code.Source("""
|
||||||
|
@ -106,9 +106,9 @@ class TestRSessionRemote:
|
||||||
subdir = "sub_example_dist"
|
subdir = "sub_example_dist"
|
||||||
tmpdir = py.test.ensuretemp("example_distribution")
|
tmpdir = py.test.ensuretemp("example_distribution")
|
||||||
tmpdir.ensure(subdir, "conftest.py").write(py.code.Source("""
|
tmpdir.ensure(subdir, "conftest.py").write(py.code.Source("""
|
||||||
disthosts = [%r]
|
dist_hosts = [%r]
|
||||||
distrsync_roots = ["%s", "py"]
|
dist_rsync_roots = ["%s", "../py"]
|
||||||
""" % ('localhost', subdir)))
|
""" % ('localhost', tmpdir.join(subdir), )))
|
||||||
tmpdir.ensure(subdir, "__init__.py")
|
tmpdir.ensure(subdir, "__init__.py")
|
||||||
tmpdir.ensure(subdir, "test_one.py").write(py.code.Source("""
|
tmpdir.ensure(subdir, "test_one.py").write(py.code.Source("""
|
||||||
def test_1():
|
def test_1():
|
||||||
|
@ -161,7 +161,8 @@ class TestRSessionRemote:
|
||||||
teardown_events = []
|
teardown_events = []
|
||||||
|
|
||||||
config = py.test.config._reparse([])
|
config = py.test.config._reparse([])
|
||||||
opts = HostOptions(optimise_localhost=False, rsync_roots=['py'])
|
opts = HostOptions(optimise_localhost=False,
|
||||||
|
rsync_roots=[py.path.local(py.__file__).dirpath()])
|
||||||
hm = HostManager(hosts, config, opts)
|
hm = HostManager(hosts, config, opts)
|
||||||
nodes = hm.init_hosts(setup_events.append)
|
nodes = hm.init_hosts(setup_events.append)
|
||||||
hm.teardown_hosts(teardown_events.append,
|
hm.teardown_hosts(teardown_events.append,
|
||||||
|
@ -188,7 +189,8 @@ class TestRSessionRemote:
|
||||||
allevents = []
|
allevents = []
|
||||||
|
|
||||||
config = py.test.config._reparse([])
|
config = py.test.config._reparse([])
|
||||||
opts = HostOptions(optimise_localhost=False, rsync_roots=['py'])
|
opts = HostOptions(optimise_localhost=False,
|
||||||
|
rsync_roots=[py.path.local(py.__file__).dirpath()])
|
||||||
hm = HostManager(hosts, config, opts)
|
hm = HostManager(hosts, config, opts)
|
||||||
nodes = hm.init_hosts(allevents.append)
|
nodes = hm.init_hosts(allevents.append)
|
||||||
|
|
||||||
|
@ -235,7 +237,8 @@ class TestRSessionRemote:
|
||||||
from py.__.test.rsession.master import defaultconftestnames
|
from py.__.test.rsession.master import defaultconftestnames
|
||||||
defaultconftestnames.append("custom")
|
defaultconftestnames.append("custom")
|
||||||
try:
|
try:
|
||||||
opts = HostOptions(optimise_localhost=False, rsync_roots=['py'])
|
opts = HostOptions(optimise_localhost=False,
|
||||||
|
rsync_roots=[py.path.local(py.__file__).dirpath()])
|
||||||
hm = HostManager(hosts, config, opts)
|
hm = HostManager(hosts, config, opts)
|
||||||
nodes = hm.init_hosts(allevents.append)
|
nodes = hm.init_hosts(allevents.append)
|
||||||
|
|
||||||
|
@ -267,7 +270,7 @@ class TestRSessionRemote:
|
||||||
tmpdir = py.test.ensuretemp("nice")
|
tmpdir = py.test.ensuretemp("nice")
|
||||||
tmpdir.ensure("__init__.py")
|
tmpdir.ensure("__init__.py")
|
||||||
tmpdir.ensure("conftest.py").write(py.code.Source("""
|
tmpdir.ensure("conftest.py").write(py.code.Source("""
|
||||||
disthosts = ['localhost']
|
dist_hosts = ['localhost']
|
||||||
dist_nicelevel = 10
|
dist_nicelevel = 10
|
||||||
"""))
|
"""))
|
||||||
tmpdir.ensure("test_one.py").write("""def test_nice():
|
tmpdir.ensure("test_one.py").write("""def test_nice():
|
||||||
|
|
Loading…
Reference in New Issue