[py-svn] r57068 - in py/branch/event/py/test2: . rep rep/testing rsession rsession/testing
hpk at codespeak.net
hpk at codespeak.net
Thu Aug 7 18:29:39 CEST 2008
Author: hpk
Date: Thu Aug 7 18:29:36 2008
New Revision: 57068
Modified:
py/branch/event/py/test2/rep/terminal.py
py/branch/event/py/test2/rep/testing/test_terminal.py
py/branch/event/py/test2/repevent.py
py/branch/event/py/test2/rsession/hostmanage.py
py/branch/event/py/test2/rsession/masterslave.py
py/branch/event/py/test2/rsession/testing/test_masterslave.py
Log:
unify HostDown and HostCrashed events
Modified: py/branch/event/py/test2/rep/terminal.py
==============================================================================
--- py/branch/event/py/test2/rep/terminal.py (original)
+++ py/branch/event/py/test2/rep/terminal.py Thu Aug 7 18:29:36 2008
@@ -37,14 +37,13 @@
def rep_HostReady(self, ev):
self.write_line("HostReady: %s" %(ev.host,))
- def rep_HostCrashed(self, ev):
+ def rep_HostDown(self, ev):
host = ev.host
error = ev.error
- if not error:
- error = "TERMINATED unexpectedly"
- self.write_line("HostCrashed %s: pending=%r" %(host.hostid, ev.pending))
- for line in str(error).split("\n"):
- self.write_line("HostCrashed %s: %s" %(host.hostid, line))
+ if error or ev.pending:
+ self.write_line("HostDown %s: pending=%r" %(host.hostid, ev.pending))
+ for line in str(error).split("\n"):
+ self.write_line("Error: %s" %(line))
def rep_ItemTestReport(self, ev):
super(TerminalReporter, self).rep_ItemTestReport(ev)
Modified: py/branch/event/py/test2/rep/testing/test_terminal.py
==============================================================================
--- py/branch/event/py/test2/rep/testing/test_terminal.py (original)
+++ py/branch/event/py/test2/rep/testing/test_terminal.py Thu Aug 7 18:29:36 2008
@@ -81,9 +81,9 @@
rep.processevent(repevent.HostReady(host1, None))
s = popvalue(stringio)
assert s.find("HostReady") != -1
- rep.processevent(repevent.HostCrashed(host1, [], "myerror"))
+ rep.processevent(repevent.HostDown(host1, [], "myerror"))
s = popvalue(stringio)
- assert s.find("HostCrashed") != -1
+ assert s.find("HostDown") != -1
assert s.find("myerror") != -1
def test_writeline(self):
Modified: py/branch/event/py/test2/repevent.py
==============================================================================
--- py/branch/event/py/test2/repevent.py (original)
+++ py/branch/event/py/test2/repevent.py Thu Aug 7 18:29:36 2008
@@ -34,7 +34,9 @@
self.timeend = time.time()
class InternalException(BaseEvent):
- def __init__(self, excinfo):
+ def __init__(self, excinfo=None):
+ if excinfo is None:
+ excinfo = py.code.ExceptionInfo()
self.excinfo = excinfo
# ----------------------------------------------------------------------
@@ -79,11 +81,27 @@
# Distributed Testing Events
# ----------------------------------------------------------------------
+class HostReady(BaseEvent):
+ def __init__(self, host, roots):
+ self.host = host
+ self.roots = roots
+
+class HostDown(BaseEvent):
+ def __init__(self, host, pending, error):
+ self.host = host
+ self.pending = pending
+ self.error = error
+
class SendItem(BaseEvent):
def __init__(self, host, item):
self.item = item
self.host = host
+
+#
+# events related to rsyncing
+#
+
class HostRSyncing(BaseEvent):
def __init__(self, host, root, remotepath, synced):
self.host = host
@@ -95,22 +113,6 @@
def __init__(self):
self.time = timestamp()
-class HostReady(BaseEvent):
- def __init__(self, host, roots):
- self.host = host
- self.roots = roots
-
-class HostDown(BaseEvent):
- def __init__(self, host, pending):
- self.host = host
- self.pending = pending
-
-class HostCrashed(BaseEvent):
- def __init__(self, host, pending, error):
- self.host = host
- self.pending = pending
- self.error = error
-
class HostRSyncRootReady(BaseEvent):
def __init__(self, host, root):
self.host = host
Modified: py/branch/event/py/test2/rsession/hostmanage.py
==============================================================================
--- py/branch/event/py/test2/rsession/hostmanage.py (original)
+++ py/branch/event/py/test2/rsession/hostmanage.py Thu Aug 7 18:29:36 2008
@@ -178,13 +178,9 @@
if isinstance(ev, repevent.HostDown):
assert not ev.pending
self.hosts.remove(ev.host)
- pending_going_down.remove(ev.host)
- elif isinstance(ev, repevent.HostCrashed):
if ev.host in pending_going_down:
pending_going_down.remove(ev.host)
- self.hosts.remove(ev.host)
#XXX remaining.extend(ev.pending)
- pass
#else:
# print "ignoring event", ev
#print "items remaining", numitems
Modified: py/branch/event/py/test2/rsession/masterslave.py
==============================================================================
--- py/branch/event/py/test2/rsession/masterslave.py (original)
+++ py/branch/event/py/test2/rsession/masterslave.py Thu Aug 7 18:29:36 2008
@@ -27,13 +27,14 @@
try:
if ev == self.ENDMARK:
err = self.channel._getremoteerror()
- if not self._down or err:
- ev = repevent.HostCrashed(self.host, self.pending, err)
- self.notify(ev)
+ if not self._down:
+ if not err:
+ err = "TERMINATED"
+ self.notify(repevent.HostDown(self.host, self.pending, err))
return
if ev is None:
- self.notify(repevent.HostDown(self.host, self.pending))
self._down = True
+ self.notify(repevent.HostDown(self.host, self.pending, None))
return
if isinstance(ev, repevent.ItemTestReport):
item = self.pending.pop()
@@ -47,11 +48,7 @@
self.notify(ev)
def send(self, item):
- try:
- self.channel.send(item)
- except IOError, ex:
- ev = repevent.HostCrashed(self.host, self.pending, ex)
- self.notify(ev)
+ self.channel.send(item)
if item is not None:
self.pending.insert(0, item)
self.notify(repevent.SendItem(self.host, item))
Modified: py/branch/event/py/test2/rsession/testing/test_masterslave.py
==============================================================================
--- py/branch/event/py/test2/rsession/testing/test_masterslave.py (original)
+++ py/branch/event/py/test2/rsession/testing/test_masterslave.py Thu Aug 7 18:29:36 2008
@@ -82,7 +82,7 @@
def test_crash_invalid_item(self):
self.node.send(123) # invalid item
- ev = self.getevent(repevent.HostCrashed)
+ ev = self.getevent(repevent.HostDown)
assert ev.host == self.host
assert ev.pending == [123]
assert str(ev.error).find("AttributeError") != -1
@@ -90,19 +90,27 @@
def test_crash_killed(self):
item = self.getfunc("kill15")
self.node.send(item) # invalid item
- ev = self.getevent(repevent.HostCrashed)
+ ev = self.getevent(repevent.HostDown)
assert ev.host == self.host
assert ev.pending == [item]
- assert not ev.error # currently this means crashed
+ assert str(ev.error).find("TERMINATED") != -1
def test_node_down(self):
self.node.send(None)
event = self.getevent(repevent.HostDown)
assert event.host == self.host
assert event.pending == []
+ assert not event.error
self.node.callback(self.node.ENDMARK)
- py.test.raises(IOError,
- "self.getevent(repevent.HostCrashed, timeout=0.01)")
+ excinfo = py.test.raises(IOError,
+ "self.getevent(repevent.HostDown, timeout=0.01)")
+
+ def test_send_on_closed_channel(self):
+ item = self.getfunc("passed")
+ self.node.channel.close()
+ py.test2.raises(IOError, "self.node.send(item)")
+ #ev = self.getevent(repevent.InternalException)
+ #assert ev.excinfo.errisinstance(IOError)
def test_send_one(self):
item = self.getfunc("passed")
More information about the pytest-commit
mailing list