diff --git a/py/test/dsession/dsession.py b/py/test/dsession/dsession.py index 730f02f79..225233637 100644 --- a/py/test/dsession/dsession.py +++ b/py/test/dsession/dsession.py @@ -9,6 +9,7 @@ from py.__.test import event from py.__.test.runner import basic_run_report, basic_collect_report from py.__.test.session import Session from py.__.test import outcome +from py.__.test.dsession.nodemanage import NodeManager import Queue @@ -97,9 +98,9 @@ class DSession(Session): def main(self, colitems=None): colitems = self.getinitialitems(colitems) self.sessionstarts() - self.setup_nodes() + self.setup() exitstatus = self.loop(colitems) - self.teardown_nodes() + self.teardown() self.sessionfinishes() return exitstatus @@ -235,15 +236,14 @@ class DSession(Session): rep = event.ItemTestReport(item, when="???", excinfo=longrepr) self.bus.notify("itemtestreport", rep) - def setup_nodes(self): + def setup(self): """ setup any neccessary resources ahead of the test run. """ - from py.__.test.dsession.hostmanage import HostManager - self.hm = HostManager(self.config) - self.hm.setup_hosts(putevent=self.queue.put) + self.nodemanager = NodeManager(self.config) + self.nodemanager.setup_nodes(putevent=self.queue.put) - def teardown_nodes(self): + def teardown(self): """ teardown any resources after a test run. """ - self.hm.teardown_hosts() + self.nodemanager.teardown_nodes() # debugging function def dump_picklestate(item): diff --git a/py/test/dsession/hostmanage.py b/py/test/dsession/nodemanage.py similarity index 90% rename from py/test/dsession/hostmanage.py rename to py/test/dsession/nodemanage.py index bf184b8f7..6ac202e73 100644 --- a/py/test/dsession/hostmanage.py +++ b/py/test/dsession/nodemanage.py @@ -40,13 +40,13 @@ def getconfigroots(config): roots.append(pydir) return roots -class HostManager(object): - def __init__(self, config, hosts=None): +class NodeManager(object): + def __init__(self, config, specs=None): self.config = config - if hosts is None: - hosts = getxspecs(self.config) + if specs is None: + specs = getxspecs(self.config) self.roots = getconfigroots(config) - self.gwmanager = GatewayManager(hosts) + self.gwmanager = GatewayManager(specs) self.nodes = [] def makegateways(self): @@ -60,9 +60,9 @@ class HostManager(object): self.gwmanager.makegateways() finally: old.chdir() - self.trace_hoststatus() + self.trace_nodestatus() - def trace_hoststatus(self): + def trace_nodestatus(self): if self.config.option.debug: for ch, result in self.gwmanager.multi_exec(""" import sys, os @@ -97,9 +97,9 @@ class HostManager(object): self.config.bus.notify("rsyncfinished", event.RsyncFinished()) def trace(self, msg): - self.config.bus.notify("trace", "testhostmanage", msg) + self.config.bus.notify("trace", "nodemanage", msg) - def setup_hosts(self, putevent): + def setup_nodes(self, putevent): self.rsync_roots() nice = self.config.getvalue("dist_nicelevel") if nice != 0: @@ -109,7 +109,7 @@ class HostManager(object): os.nice(%r) """ % nice).waitclose() - self.trace_hoststatus() + self.trace_nodestatus() multigw = self.gwmanager.getgateways(inplacelocal=False, remote=True) multigw.remote_exec(""" import os, sys @@ -120,6 +120,6 @@ class HostManager(object): node = MasterNode(gateway, self.config, putevent) self.nodes.append(node) - def teardown_hosts(self): + def teardown_nodes(self): # XXX teardown nodes? self.gwmanager.exit() diff --git a/py/test/dsession/testing/test_masterslave.py b/py/test/dsession/testing/test_masterslave.py index 0d8c52cff..50954cc84 100644 --- a/py/test/dsession/testing/test_masterslave.py +++ b/py/test/dsession/testing/test_masterslave.py @@ -49,9 +49,10 @@ class MySetup: return self.node def finalize(self): - if hasattr(self, 'host'): - print "exiting:", self.gateway - self.gateway.exit() + if hasattr(self, 'node'): + gw = self.node.gateway + print "exiting:", gw + gw.exit() def pytest_pyfuncarg_mysetup(pyfuncitem): mysetup = MySetup(pyfuncitem) diff --git a/py/test/dsession/testing/test_hostmanage.py b/py/test/dsession/testing/test_nodemanage.py similarity index 78% rename from py/test/dsession/testing/test_hostmanage.py rename to py/test/dsession/testing/test_nodemanage.py index 3f292ede7..89f7a00a4 100644 --- a/py/test/dsession/testing/test_hostmanage.py +++ b/py/test/dsession/testing/test_nodemanage.py @@ -3,7 +3,7 @@ """ import py -from py.__.test.dsession.hostmanage import HostManager, getxspecs, getconfigroots +from py.__.test.dsession.nodemanage import NodeManager, getxspecs, getconfigroots from py.__.test import event @@ -13,15 +13,15 @@ def pytest_pyfuncarg_dest(pyfuncitem): dest = py.test.ensuretemp(pyfuncitem.getmodpath()).mkdir("dest") return dest -class TestHostManager: +class TestNodeManager: @py.test.mark.xfail("consider / forbid implicit rsyncdirs?") - def test_hostmanager_rsync_roots_no_roots(self, source, dest): + def test_rsync_roots_no_roots(self, source, dest): source.ensure("dir1", "file1").write("hello") config = py.test.config._reparse([source]) - hm = HostManager(config, hosts=["popen::%s" % dest]) - assert hm.config.topdir == source == config.topdir - hm.rsync_roots() - p, = hm.gwmanager.multi_exec("import os ; channel.send(os.getcwd())").receive_each() + nodemanager = NodeManager(config, ["popen//chdir=%s" % dest]) + assert nodemanager.config.topdir == source == config.topdir + nodemanager.rsync_roots() + p, = nodemanager.gwmanager.multi_exec("import os ; channel.send(os.getcwd())").receive_each() p = py.path.local(p) print "remote curdir", p assert p == dest.join(config.topdir.basename) @@ -34,13 +34,13 @@ class TestHostManager: dir2.ensure("hello") for rsyncroot in (dir1, source): dest.remove() - hm = HostManager(testdir.parseconfig( + nodemanager = NodeManager(testdir.parseconfig( "--tx", "popen//chdir=%s" % dest, "--rsyncdirs", rsyncroot, source, )) - assert hm.config.topdir == source - hm.rsync_roots() + assert nodemanager.config.topdir == source + nodemanager.rsync_roots() if rsyncroot == source: dest = dest.join("source") assert dest.join("dir1").check() @@ -56,9 +56,8 @@ class TestHostManager: rsyncdirs = ['dir1/dir2'] """)) session = py.test.config._reparse([source]).initsession() - hm = HostManager(session.config, - hosts=["popen//chdir=%s" % dest]) - hm.rsync_roots() + nodemanager = NodeManager(session.config, ["popen//chdir=%s" % dest]) + nodemanager.rsync_roots() assert dest.join("dir2").check() assert not dest.join("dir1").check() assert not dest.join("bogus").check() @@ -73,41 +72,41 @@ class TestHostManager: rsyncignore = ['dir1/dir2', 'dir5/dir6'] """)) session = py.test.config._reparse([source]).initsession() - hm = HostManager(session.config, - hosts=["popen//chdir=%s" % dest]) - hm.rsync_roots() + nodemanager = NodeManager(session.config, + ["popen//chdir=%s" % dest]) + nodemanager.rsync_roots() assert dest.join("dir1").check() assert not dest.join("dir1", "dir2").check() assert dest.join("dir5","file").check() assert not dest.join("dir6").check() def test_optimise_popen(self, source, dest): - hosts = ["popen"] * 3 + specs = ["popen"] * 3 source.join("conftest.py").write("rsyncdirs = ['a']") source.ensure('a', dir=1) config = py.test.config._reparse([source]) - hm = HostManager(config, hosts=hosts) - hm.rsync_roots() - for gwspec in hm.gwmanager.specs: + nodemanager = NodeManager(config, specs) + nodemanager.rsync_roots() + for gwspec in nodemanager.gwmanager.specs: assert gwspec._samefilesystem() assert not gwspec.chdir - def test_setup_hosts_DEBUG(self, source, EventRecorder): - hosts = ["popen"] * 2 + def test_setup_DEBUG(self, source, EventRecorder): + specs = ["popen"] * 2 source.join("conftest.py").write("rsyncdirs = ['a']") source.ensure('a', dir=1) config = py.test.config._reparse([source, '--debug']) assert config.option.debug - hm = HostManager(config, hosts=hosts) + nodemanager = NodeManager(config, specs) evrec = EventRecorder(config.bus, debug=True) - hm.setup_hosts(putevent=[].append) - for host in hm.gwmanager.specs: + nodemanager.setup_nodes(putevent=[].append) + for spec in nodemanager.gwmanager.specs: l = evrec.getnamed("trace") print evrec.events assert l - hm.teardown_hosts() + nodemanager.teardown_nodes() - def test_ssh_setup_hosts(self, specssh, testdir): + def test_ssh_setup_nodes(self, specssh, testdir): testdir.makepyfile(__init__="", test_x=""" def test_one(): pass