[svn r63106] rename host -> gateway in a couple of places

--HG--
branch : trunk
This commit is contained in:
hpk 2009-03-20 02:09:28 +01:00
parent bb3ac13917
commit c44764dc51
9 changed files with 37 additions and 46 deletions

View File

@ -108,9 +108,9 @@ class DSession(Session):
elif eventname == "collectionreport": elif eventname == "collectionreport":
if ev.passed: if ev.passed:
colitems.extend(ev.result) colitems.extend(ev.result)
elif eventname == "hostup": elif eventname == "testnodeready":
self.addhost(ev.host) self.addhost(ev.host)
elif eventname == "hostdown": elif eventname == "testnodedown":
pending = self.removehost(ev.host) pending = self.removehost(ev.host)
if pending: if pending:
crashitem = pending.pop(0) crashitem = pending.pop(0)
@ -132,9 +132,9 @@ class DSession(Session):
# once we are in shutdown mode we dont send # once we are in shutdown mode we dont send
# events other than HostDown upstream # events other than HostDown upstream
eventname, args, kwargs = self.queue.get() eventname, args, kwargs = self.queue.get()
if eventname == "hostdown": if eventname == "testnodedown":
ev, = args ev, = args
self.bus.notify("hostdown", ev) self.bus.notify("testnodedown", ev)
self.removehost(ev.host) self.removehost(ev.host)
if not self.host2pending: if not self.host2pending:
# finished # finished
@ -173,7 +173,7 @@ class DSession(Session):
try: try:
pending = self.host2pending.pop(host) pending = self.host2pending.pop(host)
except KeyError: except KeyError:
# this happens if we didn't receive a hostup event yet # this happens if we didn't receive a testnodeready event yet
return [] return []
for item in pending: for item in pending:
del self.item2host[item] del self.item2host[item]

View File

@ -33,11 +33,11 @@ class MasterNode(object):
if not self._down: if not self._down:
if not err: if not err:
err = "TERMINATED" err = "TERMINATED"
self.notify("hostdown", event.HostDown(self.host, err)) self.notify("testnodedown", event.HostDown(self.host, err))
return return
elif eventcall is None: elif eventcall is None:
self._down = True self._down = True
self.notify("hostdown", event.HostDown(self.host, None)) self.notify("testnodedown", event.HostDown(self.host, None))
return return
except KeyboardInterrupt: except KeyboardInterrupt:
raise raise
@ -95,7 +95,7 @@ class SlaveNode(object):
if basetemp: if basetemp:
self.config.basetemp = py.path.local(basetemp) self.config.basetemp = py.path.local(basetemp)
self.config.pytestplugins.do_configure(self.config) self.config.pytestplugins.do_configure(self.config)
self.sendevent("hostup", makehostup(host)) self.sendevent("testnodeready", maketestnodeready(host))
try: try:
while 1: while 1:
task = channel.receive() task = channel.receive()
@ -120,7 +120,7 @@ class SlaveNode(object):
self.sendevent("itemtestreport", testrep) self.sendevent("itemtestreport", testrep)
def makehostup(host="INPROCESS"): def maketestnodeready(host="INPROCESS"):
import sys import sys
platinfo = {} platinfo = {}
for name in 'platform', 'executable', 'version_info': for name in 'platform', 'executable', 'version_info':

View File

@ -1,5 +1,5 @@
from py.__.test.dsession.dsession import DSession, LoopState from py.__.test.dsession.dsession import DSession, LoopState
from py.__.test.dsession.masterslave import makehostup from py.__.test.dsession.masterslave import maketestnodeready
from py.__.execnet.gwmanage import GatewaySpec from py.__.execnet.gwmanage import GatewaySpec
from py.__.test.runner import basic_collect_report from py.__.test.runner import basic_collect_report
from py.__.test import event from py.__.test import event
@ -146,7 +146,7 @@ class TestDSession:
# setup a HostDown event # setup a HostDown event
ev = event.HostDown(host1, None) ev = event.HostDown(host1, None)
session.queueevent("hostdown", ev) session.queueevent("testnodedown", ev)
loopstate = LoopState([item]) loopstate = LoopState([item])
loopstate.dowork = False loopstate.dowork = False
@ -154,7 +154,7 @@ class TestDSession:
dumpqueue(session.queue) dumpqueue(session.queue)
assert loopstate.exitstatus == outcome.EXIT_NOHOSTS assert loopstate.exitstatus == outcome.EXIT_NOHOSTS
def test_hostdown_causes_reschedule_pending(self, testdir, EventRecorder): def test_testnodedown_causes_reschedule_pending(self, testdir, EventRecorder):
modcol = testdir.getmodulecol(""" modcol = testdir.getmodulecol("""
def test_crash(): def test_crash():
assert 0 assert 0
@ -176,7 +176,7 @@ class TestDSession:
session.senditems([item1, item2]) session.senditems([item1, item2])
host = session.item2host[item1] host = session.item2host[item1]
ev = event.HostDown(host, None) ev = event.HostDown(host, None)
session.queueevent("hostdown", ev) session.queueevent("testnodedown", ev)
evrec = EventRecorder(session.bus) evrec = EventRecorder(session.bus)
loopstate = LoopState([]) loopstate = LoopState([])
session.loop_once(loopstate) session.loop_once(loopstate)
@ -188,13 +188,13 @@ class TestDSession:
assert str(testrep.longrepr).find("crashed") != -1 assert str(testrep.longrepr).find("crashed") != -1
assert str(testrep.longrepr).find(host.address) != -1 assert str(testrep.longrepr).find(host.address) != -1
def test_hostup_adds_to_available(self, testdir): def test_testnodeready_adds_to_available(self, testdir):
item = testdir.getitem("def test_func(): pass") item = testdir.getitem("def test_func(): pass")
# setup a session with two hosts # setup a session with two hosts
session = DSession(item.config) session = DSession(item.config)
host1 = GatewaySpec("localhost") host1 = GatewaySpec("localhost")
hostup = makehostup(host1) testnodeready = maketestnodeready(host1)
session.queueevent("hostup", hostup) session.queueevent("testnodeready", testnodeready)
loopstate = LoopState([item]) loopstate = LoopState([item])
loopstate.dowork = False loopstate.dowork = False
assert len(session.host2pending) == 0 assert len(session.host2pending) == 0
@ -225,7 +225,7 @@ class TestDSession:
session.queueevent("itemtestreport", ev) session.queueevent("itemtestreport", ev)
session.loop_once(loopstate) session.loop_once(loopstate)
assert loopstate.shuttingdown assert loopstate.shuttingdown
session.queueevent("hostdown", event.HostDown(host1, None)) session.queueevent("testnodedown", event.HostDown(host1, None))
session.loop_once(loopstate) session.loop_once(loopstate)
dumpqueue(session.queue) dumpqueue(session.queue)
return session, loopstate.exitstatus return session, loopstate.exitstatus
@ -278,11 +278,11 @@ class TestDSession:
evrec = EventRecorder(session.bus) evrec = EventRecorder(session.bus)
session.queueevent("itemtestreport", run(item)) session.queueevent("itemtestreport", run(item))
session.loop_once(loopstate) session.loop_once(loopstate)
assert not evrec.getfirstnamed("hostdown") assert not evrec.getfirstnamed("testnodedown")
ev = event.HostDown(host) ev = event.HostDown(host)
session.queueevent("hostdown", ev) session.queueevent("testnodedown", ev)
session.loop_once(loopstate) session.loop_once(loopstate)
assert evrec.getfirstnamed('hostdown') == ev assert evrec.getfirstnamed('testnodedown') == ev
def test_filteritems(self, testdir, EventRecorder): def test_filteritems(self, testdir, EventRecorder):
modcol = testdir.getmodulecol(""" modcol = testdir.getmodulecol("""
@ -313,7 +313,7 @@ class TestDSession:
assert event.name == "deselected" assert event.name == "deselected"
assert event.args[0].items == [items[1]] assert event.args[0].items == [items[1]]
def test_hostdown_shutdown_after_completion(self, testdir): def test_testnodedown_shutdown_after_completion(self, testdir):
item = testdir.getitem("def test_func(): pass") item = testdir.getitem("def test_func(): pass")
session = DSession(item.config) session = DSession(item.config)
@ -325,9 +325,9 @@ class TestDSession:
loopstate = LoopState([]) loopstate = LoopState([])
session.loop_once(loopstate) session.loop_once(loopstate)
assert host.node._shutdown is True assert host.node._shutdown is True
assert loopstate.exitstatus is None, "loop did not wait for hostdown" assert loopstate.exitstatus is None, "loop did not wait for testnodedown"
assert loopstate.shuttingdown assert loopstate.shuttingdown
session.queueevent("hostdown", event.HostDown(host, None)) session.queueevent("testnodedown", event.HostDown(host, None))
session.loop_once(loopstate) session.loop_once(loopstate)
assert loopstate.exitstatus == 0 assert loopstate.exitstatus == 0

View File

@ -53,7 +53,7 @@ class TestAsyncFunctional:
ev, = eq.geteventargs("itemtestreport") ev, = eq.geteventargs("itemtestreport")
assert ev.failed assert ev.failed
# see that the host is really down # see that the host is really down
ev, = eq.geteventargs("hostdown") ev, = eq.geteventargs("testnodedown")
assert ev.host.address == "popen" assert ev.host.address == "popen"
ev, = eq.geteventargs("testrunfinish") ev, = eq.geteventargs("testrunfinish")

View File

@ -147,15 +147,6 @@ class TestHostManager:
ev = sorter.getfirstnamed("itemtestreport") ev = sorter.getfirstnamed("itemtestreport")
assert ev.passed assert ev.passed
def test_rsync_samehost_twice(self):
host1 = Host("%s" % (sshhost, ))
host2 = Host("%s" % (sshhost, ))
hm = HostManager(config, hosts=[host1, host2])
events = []
hm.init_rsync(events.append)
print events
assert 0
def test_getconfiggwspecs_numprocesses(): def test_getconfiggwspecs_numprocesses():
config = py.test.config._reparse(['-n3']) config = py.test.config._reparse(['-n3'])

View File

@ -70,7 +70,7 @@ class TestMasterSlaveConnection:
def test_crash_invalid_item(self, mysetup): def test_crash_invalid_item(self, mysetup):
node = mysetup.makenode() node = mysetup.makenode()
node.send(123) # invalid item node.send(123) # invalid item
ev, = mysetup.geteventargs("hostdown") ev, = mysetup.geteventargs("testnodedown")
assert ev.host == mysetup.host assert ev.host == mysetup.host
assert str(ev.error).find("AttributeError") != -1 assert str(ev.error).find("AttributeError") != -1
@ -84,19 +84,19 @@ class TestMasterSlaveConnection:
""") """)
node = mysetup.makenode(item.config) node = mysetup.makenode(item.config)
node.send(item) node.send(item)
ev, = mysetup.geteventargs("hostdown") ev, = mysetup.geteventargs("testnodedown")
assert ev.host == mysetup.host assert ev.host == mysetup.host
assert str(ev.error).find("TERMINATED") != -1 assert str(ev.error).find("TERMINATED") != -1
def test_node_down(self, mysetup): def test_node_down(self, mysetup):
node = mysetup.makenode() node = mysetup.makenode()
node.shutdown() node.shutdown()
ev, = mysetup.geteventargs("hostdown") ev, = mysetup.geteventargs("testnodedown")
assert ev.host == mysetup.host assert ev.host == mysetup.host
assert not ev.error assert not ev.error
node.callback(node.ENDMARK) node.callback(node.ENDMARK)
excinfo = py.test.raises(IOError, excinfo = py.test.raises(IOError,
"mysetup.geteventargs('hostdown', timeout=0.01)") "mysetup.geteventargs('testnodedown', timeout=0.01)")
def test_send_on_closed_channel(self, testdir, mysetup): def test_send_on_closed_channel(self, testdir, mysetup):
item = testdir.getitem("def test_func(): pass") item = testdir.getitem("def test_func(): pass")

View File

@ -200,10 +200,10 @@ class PytestPluginHooks:
within the gateway manager context. within the gateway manager context.
""" """
def pyevent_hostup(self, event): def pyevent_testnodeready(self, event):
""" Host is up. """ """ Host is up. """
def pyevent_hostdown(self, event): def pyevent_testnodedown(self, event):
""" Host is down. """ """ Host is down. """
def pyevent_rescheduleitems(self, event): def pyevent_rescheduleitems(self, event):

View File

@ -103,7 +103,7 @@ class TerminalReporter:
# which garbles our output if we use self.write_line # which garbles our output if we use self.write_line
self.write_line(msg) self.write_line(msg)
def pyevent_hostup(self, event): def pyevent_testnodeready(self, event):
d = event.platinfo.copy() d = event.platinfo.copy()
d['host'] = getattr(event.host, 'address', event.host) d['host'] = getattr(event.host, 'address', event.host)
d['version'] = repr_pythonversion(d['sys.version_info']) d['version'] = repr_pythonversion(d['sys.version_info'])
@ -111,7 +111,7 @@ class TerminalReporter:
"%(sys.executable)s - Python %(version)s" % "%(sys.executable)s - Python %(version)s" %
d) d)
def pyevent_hostdown(self, event): def pyevent_testnodedown(self, event):
host = event.host host = event.host
error = event.error error = event.error
if error: if error:
@ -323,13 +323,13 @@ def repr_pythonversion(v=None):
from py.__.test import event from py.__.test import event
from py.__.test.runner import basic_run_report from py.__.test.runner import basic_run_report
from py.__.test.dsession.masterslave import makehostup from py.__.test.dsession.masterslave import maketestnodeready
class TestTerminal: class TestTerminal:
def test_hostup(self, testdir, linecomp): def test_testnodeready(self, testdir, linecomp):
item = testdir.getitem("def test_func(): pass") item = testdir.getitem("def test_func(): pass")
rep = TerminalReporter(item.config, linecomp.stringio) rep = TerminalReporter(item.config, linecomp.stringio)
rep.pyevent_hostup(makehostup()) rep.pyevent_testnodeready(maketestnodeready())
linecomp.assert_contains_lines([ linecomp.assert_contains_lines([
"*INPROCESS* %s %s - Python %s" %(sys.platform, "*INPROCESS* %s %s - Python %s" %(sys.platform,
sys.executable, repr_pythonversion(sys.version_info)) sys.executable, repr_pythonversion(sys.version_info))

View File

@ -12,7 +12,7 @@ from py.__.test import event, outcome
Item = py.test.collect.Item Item = py.test.collect.Item
Collector = py.test.collect.Collector Collector = py.test.collect.Collector
from runner import basic_collect_report from runner import basic_collect_report
from py.__.test.dsession.masterslave import makehostup from py.__.test.dsession.masterslave import maketestnodeready
class Session(object): class Session(object):
""" """
@ -117,7 +117,7 @@ class Session(object):
colitems = self.getinitialitems(colitems) colitems = self.getinitialitems(colitems)
self.shouldstop = False self.shouldstop = False
self.sessionstarts() self.sessionstarts()
self.bus.notify("hostup", makehostup()) self.bus.notify("testnodeready", maketestnodeready())
exitstatus = outcome.EXIT_OK exitstatus = outcome.EXIT_OK
captured_excinfo = None captured_excinfo = None
try: try: