[svn r63104] * introduce rsync events

* only rsync once if a gateway is specified multiply

--HG--
branch : trunk
This commit is contained in:
hpk
2009-03-20 01:34:59 +01:00
parent 877a7a32d8
commit 22b4ff7f06
6 changed files with 55 additions and 37 deletions

View File

@@ -147,9 +147,7 @@ class TestHostManager:
ev = sorter.getfirstnamed("itemtestreport")
assert ev.passed
@py.test.mark.xfail("implement double-rsync test")
def test_ssh_rsync_samehost_twice(self):
sshhost = getsshhost(withpython=True)
def test_rsync_samehost_twice(self):
host1 = Host("%s" % (sshhost, ))
host2 = Host("%s" % (sshhost, ))
hm = HostManager(config, hosts=[host1, host2])

View File

@@ -161,6 +161,12 @@ class PytestPluginHooks:
def pyevent_gateway_exit(self, gateway):
""" called when gateway is being exited. """
def pyevent_gwmanage_rsyncstart(self, source, gateways):
""" called before rsyncing a directory to remote gateways takes place. """
def pyevent_gwmanage_rsyncfinish(self, source, gateways):
""" called after rsyncing a directory to remote gateways takes place. """
def pyevent_trace(self, category, msg):
""" called for tracing events. """

View File

@@ -87,9 +87,13 @@ class TerminalReporter:
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):
if self.config.option.verbose:
self.write_line("HostGatewayReady: %s" %(event.host,))
def pyevent_gwmanage_rsyncstart(self, source, gateways):
targets = ", ".join([gw.id for gw in gateways])
self.write_line("rsyncstart: %s -> %s" %(source, targets))
def pyevent_gwmanage_rsyncfinish(self, source, gateways):
targets = ", ".join([gw.id for gw in gateways])
self.write_line("rsyncfinish: %s -> %s" %(source, targets))
def pyevent_plugin_registered(self, plugin):
if self.config.option.traceconfig:
@@ -323,7 +327,6 @@ from py.__.test.dsession.masterslave import makehostup
class TestTerminal:
def test_hostup(self, testdir, linecomp):
from py.__.execnet.gwmanage import GatewaySpec
item = testdir.getitem("def test_func(): pass")
rep = TerminalReporter(item.config, linecomp.stringio)
rep.pyevent_hostup(makehostup())
@@ -416,21 +419,31 @@ class TestTerminal:
"InternalException: >*raise ValueError*"
])
def test_hostready_crash(self, testdir, linecomp):
from py.__.execnet.gwmanage import GatewaySpec
def test_gwmanage_events(self, testdir, linecomp):
modcol = testdir.getmodulecol("""
def test_one():
pass
""", configargs=("-v",))
host1 = GatewaySpec("localhost")
rep = TerminalReporter(modcol.config, file=linecomp.stringio)
rep.pyevent_hostgatewayready(event.HostGatewayReady(host1, None))
class gw1:
id = "X1"
spec = py.execnet.GatewaySpec("popen")
class gw2:
id = "X2"
spec = py.execnet.GatewaySpec("popen")
rep.pyevent_gwmanage_newgateway(gateway=gw1)
linecomp.assert_contains_lines([
"*HostGatewayReady*"
"X1 instantiated gateway from spec*",
])
rep.pyevent_hostdown(event.HostDown(host1, "myerror"))
rep.pyevent_gwmanage_rsyncstart(source="hello", gateways=[gw1, gw2])
linecomp.assert_contains_lines([
"*HostDown*myerror*",
"rsyncstart: hello -> X1, X2"
])
rep.pyevent_gwmanage_rsyncfinish(source="hello", gateways=[gw1, gw2])
linecomp.assert_contains_lines([
"rsyncfinish: hello -> X1, X2"
])
def test_writeline(self, testdir, linecomp):

View File

@@ -44,7 +44,7 @@ class TestImmutablePickling:
assert config1.topdir == testdir.tmpdir
testdir.chdir()
p2config = pickletransport.p1_to_p2(config1)
assert p2config.topdir == config1.topdir
assert p2config.topdir.realpath() == config1.topdir.realpath()
config_back = pickletransport.p2_to_p1(p2config)
assert config_back is config1
@@ -160,10 +160,10 @@ class TestConfigPickling:
newcol3 = unpickler.load()
assert newcol2.config is newcol.config
assert newcol2.parent == newcol
assert newcol2.config.topdir == topdir
assert newcol.fspath == topdir
assert newcol2.config.topdir.realpath() == topdir.realpath()
assert newcol.fspath.realpath() == topdir.realpath()
assert newcol2.fspath.basename == dir1.basename
assert newcol2.fspath.relto(topdir)
assert newcol2.fspath.relto(newcol2.config.topdir)
finally:
old.chdir()