[py-svn] r31693 - py/branch/distributed/py/test/rsession

fijal at codespeak.net fijal at codespeak.net
Sat Aug 26 18:58:02 CEST 2006


Author: fijal
Date: Sat Aug 26 18:57:59 2006
New Revision: 31693

Modified:
   py/branch/distributed/py/test/rsession/conftest.py
   py/branch/distributed/py/test/rsession/hostmanage.py
   py/branch/distributed/py/test/rsession/report.py
   py/branch/distributed/py/test/rsession/rsession.py
Log:
Added waittime which tells how long server should wait for nodes to finish, otherwise report them as hanging.


Modified: py/branch/distributed/py/test/rsession/conftest.py
==============================================================================
--- py/branch/distributed/py/test/rsession/conftest.py	(original)
+++ py/branch/distributed/py/test/rsession/conftest.py	Sat Aug 26 18:57:59 2006
@@ -4,5 +4,8 @@
 option = py.test.Config.addoptions("distributed testing options", 
         Option('-D', '',
                action="store", dest="disthosts", default=None,
-               help="comma separated list of testhosts", 
-    ))
+               help="comma separated list of testhosts"),
+        Option('', '--waittime',
+               action="store", dest="waittime", default=10,
+               help="How long (in s) to wait for hanging nodes")
+    )

Modified: py/branch/distributed/py/test/rsession/hostmanage.py
==============================================================================
--- py/branch/distributed/py/test/rsession/hostmanage.py	(original)
+++ py/branch/distributed/py/test/rsession/hostmanage.py	Sat Aug 26 18:57:59 2006
@@ -5,6 +5,8 @@
      setup_slave, MasterNode, dispatch_loop)
 from py.__.test.rsession import report 
 
+from py.__.test.rsession.conftest import option
+
 def init_hosts(reporter, sshhosts, relpath, pkgdir):
     assert pkgdir.join("__init__.py").check(), (
             "%s probably wrong" %(pkgdir,))
@@ -33,7 +35,12 @@
         channel.send(None)
     
     for channel in channels:
-        report.wrapcall(reporter, channel.waitclose)
+        try:
+            report.wrapcall(reporter, channel.waitclose, int(option.waittime))
+        except KeyboardInterrupt, SystemExit:
+            raise
+        except:
+            pass
         channel.gateway.exit()
 
 def bin_rsync(source, sshaddress, destpath):

Modified: py/branch/distributed/py/test/rsession/report.py
==============================================================================
--- py/branch/distributed/py/test/rsession/report.py	(original)
+++ py/branch/distributed/py/test/rsession/report.py	Sat Aug 26 18:57:59 2006
@@ -82,5 +82,9 @@
     def __init__(self):
         self.timeend = time.time()
 
+class Nodes(ReportEvent):
+    def __init__(self, nodes):
+        self.nodes = nodes
+
 # tryiter, main dispatch loop, something else (setup-teardown stuff)
 # 

Modified: py/branch/distributed/py/test/rsession/rsession.py
==============================================================================
--- py/branch/distributed/py/test/rsession/rsession.py	(original)
+++ py/branch/distributed/py/test/rsession/rsession.py	Sat Aug 26 18:57:59 2006
@@ -61,8 +61,18 @@
         self.timeend = item.timeend
         self.skips()
         self.failures()
+        self.hangs()
         self.summary()
     
+    def hangs(self):
+        h = []
+        for node in self.nodes:
+            h += [(i, node.channel.gateway.sshaddress) for i in node.pending]
+        if h:
+            self.out.sep("=", " HANGING NODES ")
+            for i, node in h:
+                self.out.line("%s on %s" % (" ".join(i.listnames()), node))
+    
     def failures(self):
         if self.failed_tests_outcome:
             self.out.sep("=", " FAILURES ")
@@ -164,6 +174,9 @@
         sshhost = event.channel.gateway.sshaddress
         itempath = " ".join(event.item.listnames()[1:])
         print "%10s: %s %s" %(sshhost[:10], status, itempath)
+    
+    def report_Nodes(self, event):
+        self.nodes = event.nodes
 
 class RSession(object):
     """
@@ -197,6 +210,7 @@
         #    list(itemgenerator)])
         dispatch_loop(nodes, itemgenerator, lambda : False)
         teardown_hosts(reporter, [node.channel for node in nodes])
+        reporter(report.Nodes(nodes))
         reporter(report.TestFinished())
         
     def make_colitems(paths, baseon): 



More information about the pytest-commit mailing list