Exemplo n.º 1
0
    def run(self, _inTests=False):
        # we can't do spawnProcess until we're inside reactor.run(), so get
        # funky
        output("using '%s' connect method" % self.connect)
        self.exitcode = 0
        d = fireEventually(None)
        if bool(self.config.get("get-builder-names")):
            d.addCallback(lambda res: self.getAvailableBuilderNames())
        else:
            d.addCallback(lambda res: self.createJob())
            d.addCallback(lambda res: self.announce("job created"))
            deliver = self.deliverJob
            if bool(self.config.get("dryrun")):
                deliver = self.fakeDeliverJob
            d.addCallback(lambda res: deliver())
            d.addCallback(lambda res: self.announce("job has been delivered"))
            d.addCallback(lambda res: self.getStatus())
        d.addErrback(self.trapSystemExit)
        d.addErrback(log.err)
        d.addCallback(self.cleanup)
        if _inTests:
            return d
        d.addCallback(lambda res: reactor.stop())

        reactor.run()
        sys.exit(self.exitcode)
Exemplo n.º 2
0
    def run(self, _inTests=False):
        # we can't do spawnProcess until we're inside reactor.run(), so get
        # funky
        output("using '%s' connect method" % self.connect)
        self.exitcode = 0
        d = fireEventually(None)
        if bool(self.config.get("get-builder-names")):
            d.addCallback(lambda res: self.getAvailableBuilderNames())
        else:
            d.addCallback(lambda res: self.createJob())
            d.addCallback(lambda res: self.announce("job created"))
            deliver = self.deliverJob
            if bool(self.config.get("dryrun")):
                deliver = self.fakeDeliverJob
            d.addCallback(lambda res: deliver())
            d.addCallback(lambda res: self.announce("job has been delivered"))
            d.addCallback(lambda res: self.getStatus())
        d.addErrback(self.trapSystemExit)
        d.addErrback(log.err)
        d.addCallback(self.cleanup)
        if _inTests:
            return d
        d.addCallback(lambda res: reactor.stop())

        reactor.run()
        sys.exit(self.exitcode)
Exemplo n.º 3
0
    def run_impl(self):
        output(f"using '{self.connect}' connect method")
        self.exitcode = 0

        # we can't do spawnProcess until we're inside reactor.run(), so force asynchronous execution
        yield fireEventually(None)

        try:
            if bool(self.config.get("get-builder-names")):
                yield self.getAvailableBuilderNames()
            else:
                yield self.createJob()
                yield self.announce("job created")
                if bool(self.config.get("dryrun")):
                    yield self.fakeDeliverJob()
                else:
                    yield self.deliverJob()
                yield self.announce("job has been delivered")
                yield self.getStatus()

            if not bool(self.config.get("dryrun")):
                yield self.cleanup()
        except SystemExit as e:
            self.exitcode = e.code
        except Exception as e:
            log.err(e)
            raise
Exemplo n.º 4
0
    def _subscribe_test3(self, res):
        db = self.master.db
        (brids, bss, success_events, finished_events) = res
        d = fireEventually()

        def _check1(ign):
            self.failUnlessEqual(len(success_events), 0)
            self.failUnlessEqual(len(finished_events), 0)
            db.retire_buildrequests([brids["bn1"]], FAILURE)
            return flushEventualQueue()

        d.addCallback(_check1)

        def _check2(ign):
            self.failUnlessEqual(len(success_events), 1)
            self.failUnlessEqual(len(finished_events), 0)
            self.failUnlessEqual(success_events[0].isFinished(), False)
            self.failUnlessEqual(success_events[0].getResults(), None)
            db.retire_buildrequests([brids["bn2"]], SUCCESS)
            return flushEventualQueue()

        d.addCallback(_check2)

        def _check3(ign):
            self.failUnlessEqual(len(success_events), 1)
            self.failUnlessEqual(len(finished_events), 1)
            self.failUnlessIdentical(bss.__class__,
                                     success_events[0].__class__)
            self.failUnlessEqual(success_events[0].isFinished(), True)
            self.failUnlessEqual(success_events[0].getResults(), FAILURE)
            self.failUnlessEqual(finished_events[0].getResults(), FAILURE)
            return flushEventualQueue()

        d.addCallback(_check3)
        return d
Exemplo n.º 5
0
 def _subscribe_test3(self, res):
     db = self.master.db
     (brids, bss, success_events, finished_events) = res
     d = fireEventually()
     def _check1(ign):
         self.failUnlessEqual(len(success_events), 0)
         self.failUnlessEqual(len(finished_events), 0)
         db.retire_buildrequests([brids["bn1"]], FAILURE)
         return flushEventualQueue()
     d.addCallback(_check1)
     def _check2(ign):
         self.failUnlessEqual(len(success_events), 1)
         self.failUnlessEqual(len(finished_events), 0)
         self.failUnlessEqual(success_events[0].isFinished(), False)
         self.failUnlessEqual(success_events[0].getResults(), None)
         db.retire_buildrequests([brids["bn2"]], SUCCESS)
         return flushEventualQueue()
     d.addCallback(_check2)
     def _check3(ign):
         self.failUnlessEqual(len(success_events), 1)
         self.failUnlessEqual(len(finished_events), 1)
         self.failUnlessIdentical(bss.__class__,
                                  success_events[0].__class__)
         self.failUnlessEqual(success_events[0].isFinished(), True)
         self.failUnlessEqual(success_events[0].getResults(), FAILURE)
         self.failUnlessEqual(finished_events[0].getResults(), FAILURE)
         return flushEventualQueue()
     d.addCallback(_check3)
     return d
Exemplo n.º 6
0
 def callRemote(self, message, *args, **kw):
     method = getattr(self.impl, "remote_{}".format(message), None)
     if method is None:
         raise AttributeError("No such method: remote_{}".format(message))
     try:
         state = method(*args, **kw)
     except TypeError:
         log.msg("{} didn't accept {} and {}".format(method, args, kw))
         raise
     # break callback recursion for large transfers by using fireEventually
     return fireEventually(state)
Exemplo n.º 7
0
 def callRemote(self, message, *args, **kw):
     method = getattr(self.impl, "remote_%s" % message, None)
     if method is None:
         raise AttributeError("No such method: remote_%s" % (message,))
     try:
         state = method(*args, **kw)
     except TypeError:
         log.msg("%s didn't accept %s and %s" % (method, args, kw))
         raise
     # break callback recursion for large transfers by using fireEventually
     return fireEventually(state)
Exemplo n.º 8
0
 def callRemote(self, message, *args, **kw):
     method = getattr(self.impl, f"remote_{message}", None)
     if method is None:
         raise AttributeError(f"No such method: remote_{message}")
     try:
         state = method(*args, **kw)
     except TypeError:
         log.msg(f"{method} didn't accept {args} and {kw}")
         raise
     # break callback recursion for large transfers by using fireEventually
     return fireEventually(state)
Exemplo n.º 9
0
 def _check1(ign):
     b = self.status.getBuilder("full")
     self.failUnlessEqual(b.getPendingBuilds(), [])
     b.subscribe(o)
     submit_build("rev1")
     pending = b.getPendingBuilds()
     self.failUnlessEqual(len(pending), 1)
     brs = pending[0]
     self.failUnless(interfaces.IBuildRequestStatus.providedBy(brs))
     ss1 = brs.getSourceStamp()
     self.failUnlessEqual(ss1.revision, "rev1")
     self.failUnlessEqual(brs.getBuilderName(), "full")
     return fireEventually()
Exemplo n.º 10
0
    def _do_shutdown(self, res):
        bs = self.master.botmaster.builders["quick"].slaves[0]
        # Check that the slave is accepting builds once it's connected
        self.assertEquals(bs.slave.canStartBuild(), True)

        # Monkeypatch the slave's shutdown routine since the real shutdown
        # interrupts the test harness
        self.did_shutdown = False

        def _shutdown():
            self.did_shutdown = True

        bs.slave.shutdown = _shutdown

        # Start a graceful shutdown
        bs.slave.slave_status.setGraceful(True)
        # Check that the slave isn't accepting builds any more
        self.assertEquals(bs.slave.canStartBuild(), False)

        # Wait a little bit and then check that we (pretended to) shut down
        d = fireEventually()
        d.addCallback(self._check_shutdown)
        return d
 def maybeStartBuildsOnBuilder(bldr):
     self.assertIdentical(self.builders[bldr.name], bldr)
     self.maybeStartBuildsOnBuilder_calls.append(bldr.name)
     return fireEventually()
 def maybeStartBuildsOnBuilder(bldr):
     self.assertIdentical(self.builders[bldr.name], bldr)
     self.maybeStartBuildsOnBuilder_calls.append(bldr.name)
     return fireEventually()
Exemplo n.º 13
0
 def test_fireEventually_call(self):
     d = eventual.fireEventually(13)
     d.addCallback(self.cb)
     return self.assertResults([(13,)])