[svn r63151] fix various bits, many tests pass modulo dsession host/node handling
--HG-- branch : trunk
This commit is contained in:
		
							parent
							
								
									5740cfebd6
								
							
						
					
					
						commit
						10fb32ad37
					
				| 
						 | 
					@ -86,12 +86,12 @@ class DSession(Session):
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            config.getvalue('hosts')
 | 
					            config.getvalue('hosts')
 | 
				
			||||||
        except KeyError:
 | 
					        except KeyError:
 | 
				
			||||||
            print "Please specify hosts for distribution of tests:"
 | 
					            print "Please specify test environments for distribution of tests:"
 | 
				
			||||||
            print "cmdline: --gateways=host1,host2,..."
 | 
					            print "py.test --tx ssh=user@somehost --tx popen//python=python2.5"
 | 
				
			||||||
            print "conftest.py: pytest_option_hosts=['host1','host2',]"
 | 
					            print "conftest.py: pytest_option_tx=['ssh=user@somehost','popen']"
 | 
				
			||||||
            print "environment: PYTEST_OPTION_HOSTS=host1,host2,host3"
 | 
					            print "environment: PYTEST_OPTION_TX=ssh=@somehost,popen"
 | 
				
			||||||
            print 
 | 
					            print 
 | 
				
			||||||
            print "see also: http://codespeak.net/py/current/doc/test.html#automated-distributed-testing"
 | 
					            #print "see also: http://codespeak.net/py/current/doc/test.html#automated-distributed-testing"
 | 
				
			||||||
            raise SystemExit
 | 
					            raise SystemExit
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def main(self, colitems=None):
 | 
					    def main(self, colitems=None):
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,5 @@
 | 
				
			||||||
from py.__.test.dsession.dsession import DSession
 | 
					from py.__.test.dsession.dsession import DSession
 | 
				
			||||||
from py.__.test.dsession.masterslave import maketestnodeready
 | 
					from py.__.test.dsession.masterslave import maketestnodeready
 | 
				
			||||||
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
 | 
				
			||||||
from py.__.test import outcome
 | 
					from py.__.test import outcome
 | 
				
			||||||
| 
						 | 
					@ -38,7 +37,7 @@ class TestDSession:
 | 
				
			||||||
        item = testdir.getitem("def test_func(): pass")
 | 
					        item = testdir.getitem("def test_func(): pass")
 | 
				
			||||||
        rep = run(item)
 | 
					        rep = run(item)
 | 
				
			||||||
        session = DSession(item.config)
 | 
					        session = DSession(item.config)
 | 
				
			||||||
        host = GatewaySpec("localhost")
 | 
					        host = py.execnet.XSpec("popen")
 | 
				
			||||||
        host.node = MockNode()
 | 
					        host.node = MockNode()
 | 
				
			||||||
        assert not session.host2pending
 | 
					        assert not session.host2pending
 | 
				
			||||||
        session.addhost(host)
 | 
					        session.addhost(host)
 | 
				
			||||||
| 
						 | 
					@ -54,7 +53,7 @@ class TestDSession:
 | 
				
			||||||
        item = testdir.getitem("def test_func(): pass")
 | 
					        item = testdir.getitem("def test_func(): pass")
 | 
				
			||||||
        rep = run(item)
 | 
					        rep = run(item)
 | 
				
			||||||
        session = DSession(item.config)
 | 
					        session = DSession(item.config)
 | 
				
			||||||
        host = GatewaySpec("localhost")
 | 
					        host = py.execnet.XSpec("popen")
 | 
				
			||||||
        host.node = MockNode()
 | 
					        host.node = MockNode()
 | 
				
			||||||
        session.addhost(host)
 | 
					        session.addhost(host)
 | 
				
			||||||
        session.senditems([item])  
 | 
					        session.senditems([item])  
 | 
				
			||||||
| 
						 | 
					@ -79,9 +78,9 @@ class TestDSession:
 | 
				
			||||||
    def test_triggertesting_item(self, testdir):
 | 
					    def test_triggertesting_item(self, testdir):
 | 
				
			||||||
        item = testdir.getitem("def test_func(): pass")
 | 
					        item = testdir.getitem("def test_func(): pass")
 | 
				
			||||||
        session = DSession(item.config)
 | 
					        session = DSession(item.config)
 | 
				
			||||||
        host1 = GatewaySpec("localhost")
 | 
					        host1 = py.execnet.XSpec("popen")
 | 
				
			||||||
        host1.node = MockNode()
 | 
					        host1.node = MockNode()
 | 
				
			||||||
        host2 = GatewaySpec("localhost")
 | 
					        host2 = py.execnet.XSpec("popen")
 | 
				
			||||||
        host2.node = MockNode()
 | 
					        host2.node = MockNode()
 | 
				
			||||||
        session.addhost(host1)
 | 
					        session.addhost(host1)
 | 
				
			||||||
        session.addhost(host2)
 | 
					        session.addhost(host2)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -42,7 +42,7 @@ class TestAsyncFunctional:
 | 
				
			||||||
            def test_fail():
 | 
					            def test_fail():
 | 
				
			||||||
                assert 0
 | 
					                assert 0
 | 
				
			||||||
        """)
 | 
					        """)
 | 
				
			||||||
        config = testdir.parseconfig('-d', p1, '--gateways=popen')
 | 
					        config = testdir.parseconfig('-d', p1, '--tx=popen')
 | 
				
			||||||
        dsession = DSession(config)
 | 
					        dsession = DSession(config)
 | 
				
			||||||
        eq = EventQueue(config.bus)
 | 
					        eq = EventQueue(config.bus)
 | 
				
			||||||
        dsession.main([config.getfsnode(p1)])
 | 
					        dsession.main([config.getfsnode(p1)])
 | 
				
			||||||
| 
						 | 
					@ -54,7 +54,7 @@ class TestAsyncFunctional:
 | 
				
			||||||
        assert ev.failed
 | 
					        assert ev.failed
 | 
				
			||||||
        # see that the host is really down 
 | 
					        # see that the host is really down 
 | 
				
			||||||
        ev, = eq.geteventargs("testnodedown")
 | 
					        ev, = eq.geteventargs("testnodedown")
 | 
				
			||||||
        assert ev.host.address == "popen"
 | 
					        assert ev.host.popen 
 | 
				
			||||||
        ev, = eq.geteventargs("testrunfinish")
 | 
					        ev, = eq.geteventargs("testrunfinish")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def test_distribution_rsyncdirs_example(self, testdir):
 | 
					    def test_distribution_rsyncdirs_example(self, testdir):
 | 
				
			||||||
| 
						 | 
					@ -65,7 +65,7 @@ class TestAsyncFunctional:
 | 
				
			||||||
        p = subdir.join("test_one.py")
 | 
					        p = subdir.join("test_one.py")
 | 
				
			||||||
        p.write("def test_5(): assert not __file__.startswith(%r)" % str(p))
 | 
					        p.write("def test_5(): assert not __file__.startswith(%r)" % str(p))
 | 
				
			||||||
        result = testdir.runpytest("-d", "--rsyncdirs=%(subdir)s" % locals(), 
 | 
					        result = testdir.runpytest("-d", "--rsyncdirs=%(subdir)s" % locals(), 
 | 
				
			||||||
            "--gateways=popen::%(dest)s" % locals(), p)
 | 
					            "--tx=popen//chdir=%(dest)s" % locals(), p)
 | 
				
			||||||
        assert result.ret == 0
 | 
					        assert result.ret == 0
 | 
				
			||||||
        result.stdout.fnmatch_lines([
 | 
					        result.stdout.fnmatch_lines([
 | 
				
			||||||
            "*1* instantiated gateway *popen*",
 | 
					            "*1* instantiated gateway *popen*",
 | 
				
			||||||
| 
						 | 
					@ -88,7 +88,7 @@ class TestAsyncFunctional:
 | 
				
			||||||
                import os
 | 
					                import os
 | 
				
			||||||
                assert os.nice(0) == 10
 | 
					                assert os.nice(0) == 10
 | 
				
			||||||
        """)
 | 
					        """)
 | 
				
			||||||
        evrec = testdir.inline_run('-d', p1, '--gateways=popen')
 | 
					        evrec = testdir.inline_run('-d', p1, '--tx=popen')
 | 
				
			||||||
        ev = evrec.getreport('test_nice')
 | 
					        ev = evrec.getreport('test_nice')
 | 
				
			||||||
        assert ev.passed
 | 
					        assert ev.passed
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,6 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import py
 | 
					import py
 | 
				
			||||||
from py.__.test.dsession.masterslave import MasterNode
 | 
					from py.__.test.dsession.masterslave import MasterNode
 | 
				
			||||||
from py.__.execnet.gwmanage import GatewaySpec
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
class EventQueue:
 | 
					class EventQueue:
 | 
				
			||||||
    def __init__(self, bus, queue=None):
 | 
					    def __init__(self, bus, queue=None):
 | 
				
			||||||
| 
						 | 
					@ -43,8 +42,8 @@ class MySetup:
 | 
				
			||||||
            config = py.test.config._reparse([])
 | 
					            config = py.test.config._reparse([])
 | 
				
			||||||
        self.config = config
 | 
					        self.config = config
 | 
				
			||||||
        self.queue = py.std.Queue.Queue()
 | 
					        self.queue = py.std.Queue.Queue()
 | 
				
			||||||
        self.host = GatewaySpec("popen") 
 | 
					        self.host = py.execnet.XSpec("popen")
 | 
				
			||||||
        self.gateway = self.host.makegateway()
 | 
					        self.gateway = py.execnet.makegateway(self.host)
 | 
				
			||||||
        self.node = MasterNode(self.host, self.gateway, self.config, putevent=self.queue.put)
 | 
					        self.node = MasterNode(self.host, self.gateway, self.config, putevent=self.queue.put)
 | 
				
			||||||
        assert not self.node.channel.isclosed()
 | 
					        assert not self.node.channel.isclosed()
 | 
				
			||||||
        return self.node 
 | 
					        return self.node 
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -265,7 +265,7 @@ class TestPyTest:
 | 
				
			||||||
                    py.test.skip("hello")
 | 
					                    py.test.skip("hello")
 | 
				
			||||||
            """, 
 | 
					            """, 
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        result = testdir.runpytest(p1, '-d', '--gateways=popen,popen')
 | 
					        result = testdir.runpytest(p1, '-d', '--tx popen --tx popen')
 | 
				
			||||||
        result.stdout.fnmatch_lines([
 | 
					        result.stdout.fnmatch_lines([
 | 
				
			||||||
            "HOSTUP: popen*Python*",
 | 
					            "HOSTUP: popen*Python*",
 | 
				
			||||||
            #"HOSTUP: localhost*Python*",
 | 
					            #"HOSTUP: localhost*Python*",
 | 
				
			||||||
| 
						 | 
					@ -288,7 +288,7 @@ class TestPyTest:
 | 
				
			||||||
            """, 
 | 
					            """, 
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        testdir.makeconftest("""
 | 
					        testdir.makeconftest("""
 | 
				
			||||||
            pytest_option_gateways='popen,popen,popen'
 | 
					            pytest_option_tx = 'popen popen popen'.split()
 | 
				
			||||||
        """)
 | 
					        """)
 | 
				
			||||||
        result = testdir.runpytest(p1, '-d')
 | 
					        result = testdir.runpytest(p1, '-d')
 | 
				
			||||||
        result.stdout.fnmatch_lines([
 | 
					        result.stdout.fnmatch_lines([
 | 
				
			||||||
| 
						 | 
					@ -320,7 +320,7 @@ class TestPyTest:
 | 
				
			||||||
                    os.kill(os.getpid(), 15)
 | 
					                    os.kill(os.getpid(), 15)
 | 
				
			||||||
            """
 | 
					            """
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        result = testdir.runpytest(p1, '-d', '--gateways=popen,popen,popen')
 | 
					        result = testdir.runpytest(p1, '-d', '-n 3')
 | 
				
			||||||
        result.stdout.fnmatch_lines([
 | 
					        result.stdout.fnmatch_lines([
 | 
				
			||||||
            "*popen*Python*",
 | 
					            "*popen*Python*",
 | 
				
			||||||
            "*popen*Python*",
 | 
					            "*popen*Python*",
 | 
				
			||||||
| 
						 | 
					@ -434,7 +434,10 @@ class TestInteractive:
 | 
				
			||||||
                print sys.version_info[:2]
 | 
					                print sys.version_info[:2]
 | 
				
			||||||
                assert 0
 | 
					                assert 0
 | 
				
			||||||
        """)
 | 
					        """)
 | 
				
			||||||
        result = testdir.runpytest("--dist-each", "--gateways=popen-python2.5,popen-python2.4")
 | 
					        result = testdir.runpytest("--dist-each", 
 | 
				
			||||||
 | 
					            "--tx=popen//python2.4", 
 | 
				
			||||||
 | 
					            "--tx=popen//python2.5", 
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
        assert result.ret == 1
 | 
					        assert result.ret == 1
 | 
				
			||||||
        result.stdout.fnmatch_lines([
 | 
					        result.stdout.fnmatch_lines([
 | 
				
			||||||
            "*popen-python2.5*FAIL*", 
 | 
					            "*popen-python2.5*FAIL*", 
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue