[py-svn] r35143 - in py/dist/py/test/rsession: . testing webdata

fijal at codespeak.net fijal at codespeak.net
Thu Nov 30 00:20:12 CET 2006


Author: fijal
Date: Thu Nov 30 00:20:04 2006
New Revision: 35143

Modified:
   py/dist/py/test/rsession/hostmanage.py
   py/dist/py/test/rsession/report.py
   py/dist/py/test/rsession/testing/test_webjs.py
   py/dist/py/test/rsession/web.py
   py/dist/py/test/rsession/webdata/index.html
   py/dist/py/test/rsession/webdata/source.js
   py/dist/py/test/rsession/webjs.py
Log:
* Some improvements in tests host keys
* Now we can see what tests are running on each node.


Modified: py/dist/py/test/rsession/hostmanage.py
==============================================================================
--- py/dist/py/test/rsession/hostmanage.py	(original)
+++ py/dist/py/test/rsession/hostmanage.py	Thu Nov 30 00:20:04 2006
@@ -49,16 +49,16 @@
                         gw = py.execnet.SshGateway(host)
                     else:
                         gw = py.execnet.SshGateway(host, remotepython=remote_python)
+                gw.hostid = host + str(num)
             else:
                 gw = None
-                
             hosts.append((num, host, gw, remoterootpath))
         else:
             if remote_python is None:
                 gw = py.execnet.PopenGateway()
             else:
                 gw = py.execnet.PopenGateway(remotepython=remote_python)
-            gw.sshaddress = 'localhost'
+            gw.hostid = 'localhost' + str(num)
             hosts.append((num, host, gw, str(pkgdir.dirpath())))
     return hosts
 
@@ -85,7 +85,8 @@
             continue
         rsynced[(host, remoterootpath)] = True
         def done(host=host):
-            reporter(report.HostReady(host))
+            key = host + str(num)
+            reporter(report.HostReady(host, key))
         reporter(report.HostRSyncing(host, remoterootpath))
         if do_sync:
             rsync.add_target(gw, remoterootpath, done)

Modified: py/dist/py/test/rsession/report.py
==============================================================================
--- py/dist/py/test/rsession/report.py	(original)
+++ py/dist/py/test/rsession/report.py	Thu Nov 30 00:20:04 2006
@@ -75,8 +75,9 @@
         self.remoterootpath = remoterootpath
 
 class HostReady(ReportEvent):
-    def __init__(self, hostname):
+    def __init__(self, hostname, hostid):
         self.hostname = hostname
+        self.hostid = hostid
 
 class TestStarted(ReportEvent):
     def __init__(self, hosts):

Modified: py/dist/py/test/rsession/testing/test_webjs.py
==============================================================================
--- py/dist/py/test/rsession/testing/test_webjs.py	(original)
+++ py/dist/py/test/rsession/testing/test_webjs.py	Thu Nov 30 00:20:04 2006
@@ -85,4 +85,3 @@
     # XXX: This assert obviously is true in output code, why it does not work?
     assert tds[0].innerHTML == 'foo.py[1/10]'
     assert tds[1].innerHTML == '.'
-

Modified: py/dist/py/test/rsession/web.py
==============================================================================
--- py/dist/py/test/rsession/web.py	(original)
+++ py/dist/py/test/rsession/web.py	Thu Nov 30 00:20:04 2006
@@ -20,7 +20,8 @@
 from py.__.test.rsession.webdata import json
 
 DATADIR = py.path.local(__file__).dirpath("webdata")
-FUNCTION_LIST = ["main", "show_skip", "show_traceback", "show_info", "hide_info"]
+FUNCTION_LIST = ["main", "show_skip", "show_traceback", "show_info", "hide_info",
+    "show_host", "hide_host"]
 
 def escape(s):
     return s
@@ -206,16 +207,18 @@
                     event.item, outcome.excinfo, outcome.excinfo.traceback)
                 self.stdout[fullitemname] = outcome.stdout
                 self.stderr[fullitemname] = outcome.stderr
+            if event.channel:
+                args['hostkey'] = event.channel.gateway.hostid
+            else:
+                args['hostkey'] = ''
         elif isinstance(event, report.ItemStart):
             args = add_item(event)
+        elif isinstance(event, report.SendItem):
+            args = add_item(event)
+            args['hostkey'] = event.channel.gateway.hostid
         elif isinstance(event, report.HostReady):
-            host = event.hostname
-            num = 0
-            while self.ready_hosts[host]:
-                host = event.hostname + "_" + str(num)
-                num += 1
-            self.ready_hosts[host] = True
-            args = {'hostname' : event.hostname, 'hostkey' : host}
+            self.ready_hosts[event.hostid] = True
+            args = {'hostname' : event.hostname, 'hostkey' : event.hostid}
         elif isinstance(event, report.FailedTryiter):
             args = add_item(event)
         elif isinstance(event, report.SkippedTryiter):
@@ -258,12 +261,8 @@
     def report_TestStarted(self, event):
         self.hosts = {}
         self.ready_hosts = {}
-        for host in event.hosts:
-            host_str = host
-            num = 0
-            while host_str in self.hosts:
-                host_str = host + "_" + str(num)
-                num += 1
+        for num, host in enumerate(event.hosts):
+            host_str = host + str(num)
             self.hosts[host_str] = host
             self.ready_hosts[host_str] = False
         self.start_event.set()

Modified: py/dist/py/test/rsession/webdata/index.html
==============================================================================
--- py/dist/py/test/rsession/webdata/index.html	(original)
+++ py/dist/py/test/rsession/webdata/index.html	Thu Nov 30 00:20:04 2006
@@ -27,6 +27,10 @@
 <table id="hosts">
   <tr id="hostrow"></tr>
 </table>
+<table>
+<tbody id="jobs" style="visibility:hidden; background-color:#FFA">
+</tbody>
+</table>
 <table id="main_table">
 </table>
 <fieldset id="messagebox_fieldset">

Modified: py/dist/py/test/rsession/webdata/source.js
==============================================================================
Binary files. No diff available.

Modified: py/dist/py/test/rsession/webjs.py
==============================================================================
--- py/dist/py/test/rsession/webjs.py	(original)
+++ py/dist/py/test/rsession/webjs.py	Thu Nov 30 00:20:04 2006
@@ -31,6 +31,7 @@
 class Globals(object):
     def __init__(self):
         self.pending = []
+        self.host = ""
 
 glob = Globals()
 
@@ -88,9 +89,18 @@
             counters[msg['fullitemname']] = 0
             
             main_t.appendChild(tr)
+    elif msg['type'] == 'SendItem':
+        host_elem = dom.get_document().getElementById(msg['hostkey'])
+        glob.host_pending[msg['hostkey']].insert(0, msg['fullitemname'])
+        count = len(glob.host_pending[msg['hostkey']])
+        host_elem.childNodes[0].nodeValue = glob.host_dict[msg['hostkey']] + '[' +\
+            str(count) + ']'
+        
     elif msg['type'] == 'HostReady':
-        dom.get_document().getElementById(msg['hostkey']).style.background = \
+        host_elem = dom.get_document().getElementById(msg['hostkey'])
+        host_elem.style.background = \
             "#00ff00"
+        host_elem.childNodes[0].nodeValue = glob.host_dict[msg['hostkey']] + '[0]'
     elif msg['type'] == 'ReceivedItemOutcome':
         try:
             module_part = get_elem(msg['fullmodulename'])
@@ -134,6 +144,14 @@
             counter_part.childNodes[0].nodeValue = "%s[%d/%d]" % (
                     short_item_names[name], counters[name], max_items[name])
             module_part.childNodes[-1].appendChild(td)
+            
+            if msg['hostkey']:
+                host_elem = dom.get_document().getElementById(msg['hostkey'])
+                glob.host_pending[msg['hostkey']].pop()
+                count = len(glob.host_pending[msg['hostkey']])
+                host_elem.childNodes[0].nodeValue = glob.host_dict[msg['hostkey']] + '[' +\
+                    str(count) + ']'
+        
         except:
             dom.get_document().getElementById("testmain").innerHTML += \
                                                     "some error"
@@ -189,6 +207,32 @@
 def skip_come_back(msg):
     skips[msg['item_name']] = msg['reason']
 
+def reshow_host():
+    if glob.host == "":
+        return
+    show_host(glob.host)
+    
+def show_host(host_name="aa"):
+    elem = dom.get_document().getElementById("jobs")
+    while len(elem.childNodes):
+        elem.removeChild(elem.childNodes[0])
+    for item in glob.host_pending[host_name]:
+        tr = create_elem("tr")
+        td = create_elem("td")
+        td.appendChild(create_text_elem(item))
+        tr.appendChild(td)
+        elem.appendChild(tr)
+    elem.style.visibility = "visible"
+    glob.host = host_name
+    dom.setTimeout(reshow_host, 100)
+    
+def hide_host():
+    elem = dom.get_document().getElementById("jobs")
+    while len(elem.childNodes):
+        elem.removeChild(elem.childNodes[0])
+    elem.style.visibility = "hidden"
+    glob.host = ""
+    
 def host_init(host_dict):
     elem = dom.get_document().getElementById("hostrow")
     for host in host_dict.keys():
@@ -198,6 +242,12 @@
         td.appendChild(txt)
         td.id = host
         elem.appendChild(td)
+        td.setAttribute("onmouseover", "show_host('%s')" % host)
+        td.setAttribute("onmouseout", "hide_host()")
+    glob.host_dict = host_dict
+    glob.host_pending = {}
+    for key in host_dict.keys():
+        glob.host_pending[key] = []
 
 def sessid_comeback(id):
     glob.sessid = id



More information about the pytest-commit mailing list