diff --git a/py/test/rsession/hostmanage.py b/py/test/rsession/hostmanage.py index d1a4783d6..1fbd72b87 100644 --- a/py/test/rsession/hostmanage.py +++ b/py/test/rsession/hostmanage.py @@ -122,23 +122,31 @@ class HostManager(object): host.initgateway(python=dist_remotepython) host.gw.host = host + def _send_rsync(self, root, reporter, ignores, make_callback=False): + rsync = HostRSync(ignores=ignores) + destrelpath = root.relto(self.config.topdir) + for host in self.hosts: + reporter(repevent.HostRSyncing(host)) + if make_callback: + def donecallback(): + reporter(repevent.HostReady(host)) + else: + donecallback = None + rsync.add_target_host(host, destrelpath, + finishedcallback=donecallback) + rsync.send(root) + + def init_rsync(self, reporter): - # send each rsync root + # send each rsync root roots = self.config.getvalue_pathlist("dist_rsync_roots") ignores = self.config.getvalue_pathlist("dist_rsync_ignore") if roots is None: roots = [self.config.topdir] self.prepare_gateways() - rsync = HostRSync(ignores=ignores) - for root in roots: - destrelpath = root.relto(self.config.topdir) - for host in self.hosts: - reporter(repevent.HostRSyncing(host)) - def donecallback(): - reporter(repevent.HostReady(host)) - rsync.add_target_host(host, destrelpath, - finishedcallback=donecallback) - rsync.send(root) + for root in roots[:-1]: + self._send_rsync(root, reporter, ignores) + self._send_rsync(roots[-1], reporter, ignores, True) def setup_hosts(self, reporter): self.init_rsync(reporter) diff --git a/py/test/rsession/testing/test_hostmanage.py b/py/test/rsession/testing/test_hostmanage.py index b3759fb84..808e5551a 100644 --- a/py/test/rsession/testing/test_hostmanage.py +++ b/py/test/rsession/testing/test_hostmanage.py @@ -4,7 +4,8 @@ import py from py.__.test.rsession.hostmanage import HostRSync -from py.__.test.rsession.hostmanage import HostInfo, HostManager +from py.__.test.rsession.hostmanage import HostInfo, HostManager +from py.__.test.rsession import repevent class DirSetup: def setup_method(self, method): @@ -177,3 +178,15 @@ class TestHostManager(DirSetup): assert self.dest.join("dir5","file").check() assert not self.dest.join("dir6").check() + def test_hostmanager_rsync_reported_once(self): + dir2 = self.source.ensure("dir1", "dir2", dir=1) + dir5 = self.source.ensure("dir5", "dir6", "bogus") + dirf = self.source.ensure("dir3", "file") + config = py.test.config._reparse([self.source]) + hm = HostManager(config, + hosts=[HostInfo("localhost:" + str(self.dest)) + for i in range(3)]) + events = [] + hm.init_rsync(reporter=events.append) + readies = [i for i in events if isinstance(i, repevent.HostReady)] + assert len(readies) == 3