[Buildbot-devel] getPendingBuilds was removed?

Fabrice Coulon coruja074 at gmail.com
Fri Nov 25 09:23:54 UTC 2011


> What does your existing code look like?

The code is part of a system test suite that some other people have
developed for buildbot 0.8.3.

The TestSystemBase class takes care of setting up one buildmaster and
one buildslave on localhost.

The following class test the XMLRPC (the public API to our
buildmaster), one of the test case is "test_xmlrpc_cancel_request",
which uses the old (0.8.3) getPendingBuilds() method:

class TestSystemXMLRPC(TestSystemBase):
    """ Test xmlrpc calls (working with buildbot 0.8.3) """

   # We force start one build then another build using the same buildslave
   # We want to  cancel the pending build and verify that it has been removed
   # from the pending build list.

   def test_xmlrpc_cancel_request(self):
       """ Test canceling a pending build. """
       p = xmlrpc.Proxy('http://localhost:9010/RPC2')
       pend_1_build = self.master.getStatus().getBuilder('pend_1_build')
       pend_build = self.master.getStatus().getBuilder('pend_build')
       md = defer.Deferred()
       e = defer.DeferredList([md])
       class MockSubs(object):
           def buildStarted(self, builderName, build):
               def _cancel_req(_):
                   d_list = []
                   for breq in pend_build.getPendingBuilds():
                       d = p.callRemote('cancelBuildRequest',
'pend_build', breq.brid)
                       d.addCallback(_assert, [breq.brid])
                       e.chainDeferred(d)
                   stop_d = defer.Deferred()
                   stop_d.addCallback(_stop_build)
                   e.chainDeferred(stop_d)
                   reactor.callLater(0.2, stop_d.callback, None)
               pd = p.callRemote('startBuild', 'pend_build', 'tester', [], {})
               pd.addCallback(_cancel_req)
               e.chainDeferred(pd)

           def builderChangedState(self, dont, care):
               pass
           def buildFinished(self, i, dont, care):
               reactor.callLater(0.2, md.callback, None)
       subs = MockSubs()
       pend_1_build.subscribe(subs)
       def _assert(_, brid):
           pending_brids = [br.brid for br in pend_build.getPendingBuilds()]
           self.assertFalse(brid in pending_brids)
       def _stop_build(_):
           for build in pend_build.getCurrentBuilds():
               e.chainDeferred(p.callRemote('stopBuild', 'pend_build',
build.getNumber(),
                        'tester'))
           for build in pend_1_build.getCurrentBuilds():
               e.chainDeferred(p.callRemote('stopBuild',
'pend_1_build', build.getNumber(),
                        'tester'))
       p.callRemote('startBuild', 'pend_1_build', 'tester', [], {})
       return e




More information about the devel mailing list