Example #1
0
    def test_worker_graceful_shutdown(self):
        """Test that running the build worker's gracefulShutdown method results
        in a call to the master's shutdown method"""
        d = defer.Deferred()

        fakepersp = Mock()
        called = []

        def fakeCallRemote(*args):
            called.append(args)
            d1 = defer.succeed(None)
            return d1

        fakepersp.callRemote = fakeCallRemote

        # set up to call shutdown when we are attached, and chain the results onto
        # the deferred for the whole test
        def call_shutdown(mind):
            self.worker.bf.perspective = fakepersp
            shutdown_d = self.worker.gracefulShutdown()
            shutdown_d.addCallbacks(d.callback, d.errback)

        persp = MasterPerspective()
        port = self.start_master(persp, on_attachment=call_shutdown)

        self.worker = bot.Worker("127.0.0.1",
                                 port,
                                 "testy",
                                 "westy",
                                 self.basedir,
                                 keepalive=0,
                                 usePTY=False,
                                 umask=0o22)

        self.worker.startService()

        def check(ign):
            self.assertEquals(called, [('shutdown', )])

        d.addCallback(check)

        return d
Example #2
0
    def test_worker_print(self):
        d = defer.Deferred()

        # set up to call print when we are attached, and chain the results onto
        # the deferred for the whole test
        def call_print(mind):
            print_d = mind.callRemote("print", "Hi, worker.")
            print_d.addCallbacks(d.callback, d.errback)

        # start up the master and worker
        persp = MasterPerspective()
        port = self.start_master(persp, on_attachment=call_print)
        self.worker = bot.Worker("127.0.0.1",
                                 port,
                                 "testy",
                                 "westy",
                                 self.basedir,
                                 keepalive=0,
                                 umask=0o22)
        self.worker.startService()

        # and wait for the result of the print
        return d
Example #3
0
 def test_constructor_full(self):
     # invocation with all args
     bot.Worker('mstr', 9010, 'me', 'pwd', '/s', 10,
                umask=0o123, maxdelay=10, keepaliveTimeout=10,
                unicode_encoding='utf8', allow_shutdown=True)
Example #4
0
 def test_constructor_083_tac(self):
     # invocation as made from default 083 tac files
     bot.Worker('mstr', 9010, 'me', 'pwd', '/s', 10,
                umask=0o123, maxdelay=10)
Example #5
0
 def test_constructor_minimal(self):
     # only required arguments
     bot.Worker('mstr', 9010, 'me', 'pwd', '/s', 10)
Example #6
0
 def test_constructor_091_tac(self):
     # invocation as made from default 0.9.1 tac files
     bot.Worker(None, None, 'me', 'pwd', '/s', 10,
                connection_string="tcp:host=localhost:port=9010",
                umask=0o123, protocol='pb', maxdelay=10)
Example #7
0
 def test_constructor_083_tac(self):
     """invocation as made from default 0.8.3 tac files"""
     bot.Worker('mstr', 9010, 'me', 'pwd', '/s', 10,
                umask=0o123, protocol='pb', maxdelay=10)