[svn r63091] report some more info on dist-setup
shift comments --HG-- branch : trunk
This commit is contained in:
parent
6f2cca80ae
commit
a94359c791
|
@ -26,6 +26,7 @@ NO_ENDMARKER_WANTED = object()
|
||||||
class GatewaySpec(object):
|
class GatewaySpec(object):
|
||||||
python = None
|
python = None
|
||||||
def __init__(self, spec, defaultjoinpath="pyexecnetcache"):
|
def __init__(self, spec, defaultjoinpath="pyexecnetcache"):
|
||||||
|
self._spec = spec
|
||||||
if spec == "popen" or spec.startswith("popen:"):
|
if spec == "popen" or spec.startswith("popen:"):
|
||||||
parts = spec.split(":", 2)
|
parts = spec.split(":", 2)
|
||||||
self.type = self.address = parts.pop(0)
|
self.type = self.address = parts.pop(0)
|
||||||
|
@ -66,7 +67,7 @@ class GatewaySpec(object):
|
||||||
return bool(self.type == "popen" and not self.joinpath)
|
return bool(self.type == "popen" and not self.joinpath)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "<GatewaySpec %s:%s>" % (self.address, self.joinpath)
|
return "<GatewaySpec %s>" % self._spec
|
||||||
__repr__ = __str__
|
__repr__ = __str__
|
||||||
|
|
||||||
def makegateway(self, waitclose=True):
|
def makegateway(self, waitclose=True):
|
||||||
|
@ -102,13 +103,18 @@ class GatewayManager:
|
||||||
self.gateways = []
|
self.gateways = []
|
||||||
|
|
||||||
def trace(self, msg):
|
def trace(self, msg):
|
||||||
py._com.pyplugins.notify("trace", "gatewaymanage", msg)
|
self.notify("trace", "gatewaymanage", msg)
|
||||||
|
|
||||||
|
def notify(self, eventname, *args, **kwargs):
|
||||||
|
py._com.pyplugins.notify(eventname, *args, **kwargs)
|
||||||
|
|
||||||
def makegateways(self):
|
def makegateways(self):
|
||||||
assert not self.gateways
|
assert not self.gateways
|
||||||
for spec in self.specs:
|
for spec in self.specs:
|
||||||
self.trace("makegateway %s" %(spec))
|
gw = spec.makegateway()
|
||||||
self.gateways.append(spec.makegateway())
|
self.gateways.append(gw)
|
||||||
|
gw.id = "[%s]" % len(self.gateways)
|
||||||
|
self.notify("gwmanage_newgateway", gw)
|
||||||
|
|
||||||
def getgateways(self, remote=True, inplacelocal=True):
|
def getgateways(self, remote=True, inplacelocal=True):
|
||||||
if not self.gateways and self.specs:
|
if not self.gateways and self.specs:
|
||||||
|
|
|
@ -565,9 +565,9 @@ class SocketGatewaySetup:
|
||||||
## cls.gw.exit()
|
## cls.gw.exit()
|
||||||
## cls.proxygw.exit()
|
## cls.proxygw.exit()
|
||||||
|
|
||||||
def getsshhost():
|
def getsshhost(withpython=False):
|
||||||
sshhost = py.test.config.getvalueorskip("sshhost")
|
sshhost = py.test.config.getvalueorskip("sshhost")
|
||||||
if sshhost.find(":") != -1:
|
if not withpython and sshhost.find(":") != -1:
|
||||||
sshhost = sshhost.split(":")[0]
|
sshhost = sshhost.split(":")[0]
|
||||||
ssh = py.path.local.sysfind("ssh")
|
ssh = py.path.local.sysfind("ssh")
|
||||||
if not ssh:
|
if not ssh:
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
"""
|
"""
|
||||||
tests for
|
tests for
|
||||||
- gateway specifications
|
|
||||||
- multi channels and multi gateways
|
|
||||||
- gateway management
|
- gateway management
|
||||||
- manage rsyncing of hosts
|
- manage rsyncing of hosts
|
||||||
|
|
||||||
|
@ -10,10 +8,18 @@
|
||||||
import py
|
import py
|
||||||
from py.__.execnet.gwmanage import GatewayManager, HostRSync
|
from py.__.execnet.gwmanage import GatewayManager, HostRSync
|
||||||
|
|
||||||
|
pytest_plugins = "pytest_pytester"
|
||||||
|
|
||||||
class TestGatewayManagerPopen:
|
class TestGatewayManagerPopen:
|
||||||
def test_hostmanager_popen_makegateway(self):
|
def test_hostmanager_popen_makegateway(self, eventrecorder):
|
||||||
hm = GatewayManager(["popen"] * 2)
|
hm = GatewayManager(["popen"] * 2)
|
||||||
hm.makegateways()
|
hm.makegateways()
|
||||||
|
event = eventrecorder.popevent("gwmanage_newgateway")
|
||||||
|
gw = event.args[0]
|
||||||
|
assert gw.id == "[1]"
|
||||||
|
event = eventrecorder.popevent("gwmanage_newgateway")
|
||||||
|
gw = event.args[0]
|
||||||
|
assert gw.id == "[2]"
|
||||||
assert len(hm.gateways) == 2
|
assert len(hm.gateways) == 2
|
||||||
hm.exit()
|
hm.exit()
|
||||||
assert not len(hm.gateways)
|
assert not len(hm.gateways)
|
||||||
|
|
|
@ -50,6 +50,11 @@ class HostManager(object):
|
||||||
self.gwmanager = GatewayManager(hosts)
|
self.gwmanager = GatewayManager(hosts)
|
||||||
|
|
||||||
def makegateways(self):
|
def makegateways(self):
|
||||||
|
# we change to the topdir sot that
|
||||||
|
# PopenGateways will have their cwd
|
||||||
|
# such that unpickling configs will
|
||||||
|
# pick it up as the right topdir
|
||||||
|
# (for other gateways this chdir is irrelevant)
|
||||||
old = self.config.topdir.chdir()
|
old = self.config.topdir.chdir()
|
||||||
try:
|
try:
|
||||||
self.gwmanager.makegateways()
|
self.gwmanager.makegateways()
|
||||||
|
@ -74,11 +79,6 @@ class HostManager(object):
|
||||||
have the same set of roots in their
|
have the same set of roots in their
|
||||||
current directory.
|
current directory.
|
||||||
"""
|
"""
|
||||||
# we change to the topdir sot that
|
|
||||||
# PopenGateways will have their cwd
|
|
||||||
# such that unpickling configs will
|
|
||||||
# pick it up as the right topdir
|
|
||||||
# (for other gateways this chdir is irrelevant)
|
|
||||||
self.makegateways()
|
self.makegateways()
|
||||||
options = {
|
options = {
|
||||||
'ignores': self.config_getignores(),
|
'ignores': self.config_getignores(),
|
||||||
|
|
|
@ -65,9 +65,12 @@ class TestAsyncFunctional:
|
||||||
p = subdir.join("test_one.py")
|
p = subdir.join("test_one.py")
|
||||||
p.write("def test_5(): assert not __file__.startswith(%r)" % str(p))
|
p.write("def test_5(): assert not __file__.startswith(%r)" % str(p))
|
||||||
result = testdir.runpytest("-d", "--rsyncdirs=%(subdir)s" % locals(),
|
result = testdir.runpytest("-d", "--rsyncdirs=%(subdir)s" % locals(),
|
||||||
"--gateways=popen::%(dest)s" % locals(), p)
|
"--gateways=popen::%(dest)s" % locals(), p)
|
||||||
assert result.ret == 0
|
assert result.ret == 0
|
||||||
result.stdout.fnmatch_lines([
|
result.stdout.fnmatch_lines([
|
||||||
|
"*1* instantiated gateway *popen*",
|
||||||
|
#"RSyncStart: [G1]",
|
||||||
|
#"RSyncFinished: [G1]",
|
||||||
"*1 passed*"
|
"*1 passed*"
|
||||||
])
|
])
|
||||||
assert dest.join(subdir.basename).check(dir=1)
|
assert dest.join(subdir.basename).check(dir=1)
|
||||||
|
|
|
@ -136,7 +136,7 @@ class TestHostManager:
|
||||||
hm.teardown_hosts()
|
hm.teardown_hosts()
|
||||||
|
|
||||||
def test_hostmanage_ssh_setup_hosts(self, testdir):
|
def test_hostmanage_ssh_setup_hosts(self, testdir):
|
||||||
sshhost = getsshhost()
|
sshhost = getsshhost(withpython=True)
|
||||||
testdir.makepyfile(__init__="", test_x="""
|
testdir.makepyfile(__init__="", test_x="""
|
||||||
def test_one():
|
def test_one():
|
||||||
pass
|
pass
|
||||||
|
@ -149,7 +149,7 @@ class TestHostManager:
|
||||||
|
|
||||||
@py.test.mark.xfail("implement double-rsync test")
|
@py.test.mark.xfail("implement double-rsync test")
|
||||||
def test_ssh_rsync_samehost_twice(self):
|
def test_ssh_rsync_samehost_twice(self):
|
||||||
sshhost = getsshhost()
|
sshhost = getsshhost(withpython=True)
|
||||||
host1 = Host("%s" % (sshhost, ))
|
host1 = Host("%s" % (sshhost, ))
|
||||||
host2 = Host("%s" % (sshhost, ))
|
host2 = Host("%s" % (sshhost, ))
|
||||||
hm = HostManager(config, hosts=[host1, host2])
|
hm = HostManager(config, hosts=[host1, host2])
|
||||||
|
|
|
@ -186,7 +186,13 @@ class PytestPluginHooks:
|
||||||
""" whole test run starts. """
|
""" whole test run starts. """
|
||||||
|
|
||||||
def pyevent_testrunfinish(self, event):
|
def pyevent_testrunfinish(self, event):
|
||||||
""" whole test run starts. """
|
""" whole test run finishes. """
|
||||||
|
|
||||||
|
def pyevent_gwmanage_newgateway(self, gateway):
|
||||||
|
""" execnet gateway manager has instantiated a gateway.
|
||||||
|
The gateway will have an 'id' attribute that is unique
|
||||||
|
within the gateway manager context.
|
||||||
|
"""
|
||||||
|
|
||||||
def pyevent_hostup(self, event):
|
def pyevent_hostup(self, event):
|
||||||
""" Host is up. """
|
""" Host is up. """
|
||||||
|
|
|
@ -84,6 +84,9 @@ class TerminalReporter:
|
||||||
for line in str(event.repr).split("\n"):
|
for line in str(event.repr).split("\n"):
|
||||||
self.write_line("InternalException: " + line)
|
self.write_line("InternalException: " + line)
|
||||||
|
|
||||||
|
def pyevent_gwmanage_newgateway(self, gateway):
|
||||||
|
self.write_line("%s instantiated gateway from spec %r" %(gateway.id, gateway.spec._spec))
|
||||||
|
|
||||||
def pyevent_hostgatewayready(self, event):
|
def pyevent_hostgatewayready(self, event):
|
||||||
if self.config.option.verbose:
|
if self.config.option.verbose:
|
||||||
self.write_line("HostGatewayReady: %s" %(event.host,))
|
self.write_line("HostGatewayReady: %s" %(event.host,))
|
||||||
|
|
Loading…
Reference in New Issue