Beispiel #1
0
    def setUpTestReactor(self, use_asyncio=False):

        self.patch(threadpool, 'ThreadPool', NonThreadPool)
        self.reactor = TestReactor()
        _setReactor(self.reactor)

        def deferToThread(f, *args, **kwargs):
            return threads.deferToThreadPool(self.reactor,
                                             self.reactor.getThreadPool(), f,
                                             *args, **kwargs)

        self.patch(threads, 'deferToThread', deferToThread)

        # During shutdown sequence we must first stop the reactor and only then
        # set unset the reactor used for eventually() because any callbacks
        # that are run during reactor.stop() may use eventually() themselves.
        self.addCleanup(_setReactor, None)
        self.addCleanup(self.reactor.stop)

        if use_asyncio:
            self.asyncio_loop = TwistedLoop(self.reactor)
            asyncio.set_event_loop(self.asyncio_loop)
            self.asyncio_loop.start()

            def stop():
                self.asyncio_loop.stop()
                self.asyncio_loop.close()
                asyncio.set_event_loop(None)

            self.addCleanup(stop)
Beispiel #2
0
 def setUp(self):
     self.patch(threadpool, 'ThreadPool', NonThreadPool)
     self.reactor = TestReactor()
     _setReactor(self.reactor)
     self.patch(workerhyper, 'Hyper', hyper.Client)
     self.build = Properties(
         image="busybox:latest", builder="docker_worker")
     self.worker = None
Beispiel #3
0
 def setUpTestReactor(self):
     self.patch(threadpool, 'ThreadPool', NonThreadPool)
     self.reactor = TestReactor()
     _setReactor(self.reactor)
     # During shutdown sequence we must first stop the reactor and only then
     # set unset the reactor used for eventually() because any callbacks
     # that are run during reactor.stop() may use eventually() themselves.
     self.addCleanup(_setReactor, None)
     self.addCleanup(self.reactor.stop)
    def setUp(self):
        self.setUpDirs('workdir')
        self.addCleanup(self.tearDownDirs)

        self.reactor = TestReactor()
        self.addCleanup(self.reactor.stop)
        self.spawned_process = mock.Mock()
        self.reactor.spawnProcess = mock.Mock(
            return_value=self.spawned_process)
Beispiel #5
0
    def setUp(self):
        def deferToThread(f, *args, **kwargs):
            return threads.deferToThreadPool(self.reactor, self.reactor.getThreadPool(),
                                             f, *args, **kwargs)
        self.patch(threadpool, 'ThreadPool', NonThreadPool)
        self.patch(threads, 'deferToThread', deferToThread)
        self.reactor = TestReactor()

        _setReactor(self.reactor)
        self.build = Properties(
            image='busybox:latest', builder='docker_worker', distro='wheezy')
        self.patch(dockerworker, 'client', docker)
    def setUp(self):
        self.patch(threadpool, 'ThreadPool', NonThreadPool)
        self.reactor = TestReactor()

        # to ease debugging we display the error logs in the test log
        origAddCompleteLog = BuildStep.addCompleteLog

        def addCompleteLog(self, name, _log):
            if name.endswith("err.text"):
                log.msg("got error log!", name, _log)
            return origAddCompleteLog(self, name, _log)
        self.patch(BuildStep, "addCompleteLog", addCompleteLog)

        if 'BBTRACE' in os.environ:
            enable_trace(self, ["twisted", "worker_transition.py", "util/tu", "util/path",
                                "log.py", "/mq/", "/db/", "buildbot/data/", "fake/reactor.py"])
Beispiel #7
0
    def setUp(self):
        self.patch(threadpool, 'ThreadPool', NonThreadPool)
        self.reactor = TestReactor()
        self.addCleanup(self.reactor.stop)
        _setReactor(self.reactor)
        self.addCleanup(_setReactor, None)

        # to ease debugging we display the error logs in the test log
        origAddCompleteLog = BuildStep.addCompleteLog

        def addCompleteLog(self, name, _log):
            if name.endswith("err.text"):
                log.msg("got error log!", name, _log)
            return origAddCompleteLog(self, name, _log)

        self.patch(BuildStep, "addCompleteLog", addCompleteLog)
Beispiel #8
0
    def setUpTestReactor(self):
        self.patch(threadpool, 'ThreadPool', NonThreadPool)
        self.reactor = TestReactor()
        _setReactor(self.reactor)

        def deferToThread(f, *args, **kwargs):
            return threads.deferToThreadPool(self.reactor,
                                             self.reactor.getThreadPool(), f,
                                             *args, **kwargs)

        self.patch(threads, 'deferToThread', deferToThread)

        # During shutdown sequence we must first stop the reactor and only then
        # set unset the reactor used for eventually() because any callbacks
        # that are run during reactor.stop() may use eventually() themselves.
        self.addCleanup(_setReactor, None)
        self.addCleanup(self.reactor.stop)
Beispiel #9
0
 def setUp(self):
     self.patch(threadpool, 'ThreadPool', NonThreadPool)
     self.reactor = TestReactor()
     self.addCleanup(self.reactor.stop)
Beispiel #10
0
 def setUp(self):
     self.patch(threadpool, 'ThreadPool', NonThreadPool)
     self.reactor = TestReactor()
 def setUp(self):
     self.reactor = TestReactor()
     _setReactor(self.reactor)
     self.build = Properties(
         image="busybox:latest", builder="docker_worker")
     self.worker = None