[svn r38035] be more precise when reporting about hosts
(enumerate them) --HG-- branch : trunk
This commit is contained in:
		
							parent
							
								
									1d4a46d46a
								
							
						
					
					
						commit
						563ed75651
					
				| 
						 | 
					@ -25,7 +25,7 @@ class HostInfo(object):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def _getuniqueid(self, hostname):
 | 
					    def _getuniqueid(self, hostname):
 | 
				
			||||||
        l = self._hostname2list.setdefault(hostname, [])
 | 
					        l = self._hostname2list.setdefault(hostname, [])
 | 
				
			||||||
        hostid = hostname + "_" * len(l)
 | 
					        hostid = hostname + "[%d]" % len(l)
 | 
				
			||||||
        l.append(hostid)
 | 
					        l.append(hostid)
 | 
				
			||||||
        return hostid
 | 
					        return hostid
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -57,13 +57,15 @@ class AbstractReporter(object):
 | 
				
			||||||
                                        address)
 | 
					                                        address)
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def report_HostRSyncing(self, item):
 | 
					    def report_HostRSyncing(self, item):
 | 
				
			||||||
        print "%10s: RSYNC ==> %s" % (item.host.hostname[:10],
 | 
					        hostrepr = self._hostrepr(item.host)
 | 
				
			||||||
 | 
					        print "%15s: RSYNC ==> %s" % (hostrepr, 
 | 
				
			||||||
                                      item.host.relpath)
 | 
					                                      item.host.relpath)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def report_HostGatewayReady(self, item):
 | 
					    def report_HostGatewayReady(self, item):
 | 
				
			||||||
        self.to_rsync[item.host] = len(item.roots)
 | 
					        self.to_rsync[item.host] = len(item.roots)
 | 
				
			||||||
        self.out.write("%10s: gateway initialised (remote topdir: %s)\n"\
 | 
					        hostrepr = self._hostrepr(item.host)
 | 
				
			||||||
                       % (item.host.hostname, item.host.gw_remotepath))
 | 
					        self.out.write("%15s: gateway initialised (remote topdir: %s)\n"\
 | 
				
			||||||
 | 
					                       % (hostrepr, item.host.gw_remotepath))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def report_HostRSyncRootReady(self, item):
 | 
					    def report_HostRSyncRootReady(self, item):
 | 
				
			||||||
        self.to_rsync[item.host] -= 1
 | 
					        self.to_rsync[item.host] -= 1
 | 
				
			||||||
| 
						 | 
					@ -72,15 +74,16 @@ class AbstractReporter(object):
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def _host_ready(self, item):
 | 
					    def _host_ready(self, item):
 | 
				
			||||||
        self.hosts_to_rsync -= 1
 | 
					        self.hosts_to_rsync -= 1
 | 
				
			||||||
 | 
					        hostrepr = self._hostrepr(item.host)
 | 
				
			||||||
        if self.hosts_to_rsync:
 | 
					        if self.hosts_to_rsync:
 | 
				
			||||||
            print "%10s: READY (still %d to go)" % (item.host.hostname[:10],
 | 
					            print "%15s: READY (still %d to go)" % (hostrepr, 
 | 
				
			||||||
                                                self.hosts_to_rsync)
 | 
					                                                    self.hosts_to_rsync)
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            print "%10s: READY" % item.host.hostname[:10]
 | 
					            print "%15s: READY" % hostrepr 
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def report_TestStarted(self, item):
 | 
					    def report_TestStarted(self, item):
 | 
				
			||||||
        hostnames = [host.hostname for host in item.hosts]
 | 
					        hostreprs = [self._hostrepr(host) for host in item.hosts]
 | 
				
			||||||
        txt = " Test started, hosts: %s " % ", ".join(hostnames)
 | 
					        txt = " Test started, hosts: %s " % ", ".join(hostreprs)
 | 
				
			||||||
        self.hosts_to_rsync = len(item.hosts)
 | 
					        self.hosts_to_rsync = len(item.hosts)
 | 
				
			||||||
        self.out.sep("=", txt)
 | 
					        self.out.sep("=", txt)
 | 
				
			||||||
        self.timestart = item.timestart
 | 
					        self.timestart = item.timestart
 | 
				
			||||||
| 
						 | 
					@ -163,6 +166,9 @@ class AbstractReporter(object):
 | 
				
			||||||
        signal = outcome.signal
 | 
					        signal = outcome.signal
 | 
				
			||||||
        self.out.line("Received signal: %d" % outcome.signal)
 | 
					        self.out.line("Received signal: %d" % outcome.signal)
 | 
				
			||||||
        self.repr_out_err(outcome)
 | 
					        self.repr_out_err(outcome)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def _hostrepr(self, host):
 | 
				
			||||||
 | 
					        return host.hostid
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def skips(self):
 | 
					    def skips(self):
 | 
				
			||||||
        texts = {}
 | 
					        texts = {}
 | 
				
			||||||
| 
						 | 
					@ -223,17 +229,18 @@ class AbstractReporter(object):
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    def report_ReceivedItemOutcome(self, event):
 | 
					    def report_ReceivedItemOutcome(self, event):
 | 
				
			||||||
        host = event.host
 | 
					        host = event.host
 | 
				
			||||||
 | 
					        hostrepr = self._hostrepr(host)
 | 
				
			||||||
        if event.outcome.passed:
 | 
					        if event.outcome.passed:
 | 
				
			||||||
            self.passed[host] += 1
 | 
					            self.passed[host] += 1
 | 
				
			||||||
            sys.stdout.write("%10s: PASSED  " % host.hostname[:10])
 | 
					            sys.stdout.write("%15s: PASSED  " % hostrepr)
 | 
				
			||||||
        elif event.outcome.skipped:
 | 
					        elif event.outcome.skipped:
 | 
				
			||||||
            self.skipped_tests_outcome.append(event)
 | 
					            self.skipped_tests_outcome.append(event)
 | 
				
			||||||
            self.skipped[host] += 1
 | 
					            self.skipped[host] += 1
 | 
				
			||||||
            sys.stdout.write("%10s: SKIPPED " % host.hostname[:10])
 | 
					            sys.stdout.write("%15s: SKIPPED " % hostrepr) 
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            self.failed[host] += 1
 | 
					            self.failed[host] += 1
 | 
				
			||||||
            self.failed_tests_outcome.append(event)
 | 
					            self.failed_tests_outcome.append(event)
 | 
				
			||||||
            sys.stdout.write("%10s: " % host.hostname[:10])
 | 
					            sys.stdout.write("%15s: " % hostrepr) 
 | 
				
			||||||
            ansi_print("FAILED", esc=(31,1), newline=False, file=sys.stdout)
 | 
					            ansi_print("FAILED", esc=(31,1), newline=False, file=sys.stdout)
 | 
				
			||||||
            sys.stdout.write("  ")
 | 
					            sys.stdout.write("  ")
 | 
				
			||||||
        # we should have printed 20 characters to this point
 | 
					        # we should have printed 20 characters to this point
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -157,12 +157,15 @@ class AbstractTestReporter(BasicRsessionTest):
 | 
				
			||||||
                r.report(repevent.HostRSyncRootReady(host, root))
 | 
					                r.report(repevent.HostRSyncRootReady(host, root))
 | 
				
			||||||
        out, err = cap.reset()
 | 
					        out, err = cap.reset()
 | 
				
			||||||
        assert not err
 | 
					        assert not err
 | 
				
			||||||
        expected1 = "Test started, hosts: host1, host2, host3"
 | 
					        expected1 = "Test started, hosts: host1[0], host2[0], host3[0]"
 | 
				
			||||||
        expected2 = """host1: READY (still 2 to go)
 | 
					 | 
				
			||||||
     host2: READY (still 1 to go)
 | 
					 | 
				
			||||||
     host3: READY"""
 | 
					 | 
				
			||||||
        assert out.find(expected1) != -1
 | 
					        assert out.find(expected1) != -1
 | 
				
			||||||
        assert out.find(expected2) != -1
 | 
					        for expected in py.code.Source("""
 | 
				
			||||||
 | 
					            host1[0]: READY (still 2 to go)
 | 
				
			||||||
 | 
					            host2[0]: READY (still 1 to go)
 | 
				
			||||||
 | 
					            host3[0]: READY
 | 
				
			||||||
 | 
					        """).lines:
 | 
				
			||||||
 | 
					            expected = expected.strip()
 | 
				
			||||||
 | 
					            assert out.find(expected) != -1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class TestLocalReporter(AbstractTestReporter):
 | 
					class TestLocalReporter(AbstractTestReporter):
 | 
				
			||||||
    reporter = LocalReporter
 | 
					    reporter = LocalReporter
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue