Exemplo n.º 1
0
 def test_inv_nextBuild(self):
     self.assertRaisesConfigError(
         "nextBuild must be a callable",
         lambda: config.BuilderConfig(nextBuild="foo",
                                      name="a",
                                      slavenames=['a'],
                                      factory=self.factory))
Exemplo n.º 2
0
 def test_tags_must_be_list_of_str(self):
     self.assertRaisesConfigError(
         "tags list contains something that is not a string",
         lambda: config.BuilderConfig(tags=['abc', 13],
                                      name='a',
                                      slavenames=['a'],
                                      factory=self.factory))
Exemplo n.º 3
0
 def test_getConfigDict(self):
     ns = lambda: 'ns'
     nb = lambda: 'nb'
     cfg = config.BuilderConfig(name='b',
                                slavename='s1',
                                slavenames='s2',
                                builddir='bd',
                                slavebuilddir='sbd',
                                factory=self.factory,
                                category='c',
                                nextSlave=ns,
                                nextBuild=nb,
                                locks=['l'],
                                env=dict(x=10),
                                properties=dict(y=20),
                                mergeRequests='mr')
     self.assertEqual(
         cfg.getConfigDict(), {
             'builddir': 'bd',
             'category': 'c',
             'env': {
                 'x': 10
             },
             'factory': self.factory,
             'locks': ['l'],
             'mergeRequests': 'mr',
             'name': 'b',
             'nextBuild': nb,
             'nextSlave': ns,
             'properties': {
                 'y': 20
             },
             'slavebuilddir': 'sbd',
             'slavenames': ['s2', 's1'],
         })
Exemplo n.º 4
0
    def test_reconfigServiceBuilders_add_remove(self):
        bc = config.BuilderConfig(name='bldr', factory=mock.Mock(),
                            slavename='f')
        self.new_config.builders = [ bc ]

        wfd = defer.waitForDeferred(
                self.botmaster.reconfigServiceBuilders(self.new_config))
        yield wfd
        wfd.getResult()

        bldr = self.botmaster.builders['bldr']
        self.assertIdentical(bldr.parent, self.botmaster)
        self.assertIdentical(bldr.master, self.master)
        self.assertEqual(self.botmaster.builderNames, [ 'bldr' ])

        self.new_config.builders = [ ]

        wfd = defer.waitForDeferred(
                self.botmaster.reconfigServiceBuilders(self.new_config))
        yield wfd
        wfd.getResult()

        self.assertIdentical(bldr.parent, None)
        self.assertIdentical(bldr.master, None)
        self.assertEqual(self.botmaster.builders, {})
        self.assertEqual(self.botmaster.builderNames, [])
Exemplo n.º 5
0
    def addSlave(self, **kwargs):
        """
        Create a master-side slave instance and add it to the BotMaster

        @param **kwargs: arguments to pass to the L{BuildSlave} constructor.
        """
        self.buildslave = buildslave.BuildSlave("testslave", "pw", **kwargs)

        # patch in our FakeBuilder for the regular Builder class
        self.patch(botmaster, 'Builder', FakeBuilder)

        # reconfig the master to get it set up
        new_config = self.master.config
        new_config.slavePortnum = "tcp:0:interface=127.0.0.1"
        new_config.slaves = [self.buildslave]
        new_config.builders = [
            config.BuilderConfig(name='bldr',
                                 slavename='testslave',
                                 factory=mock.Mock())
        ]

        yield self.botmaster.reconfigService(new_config)

        # as part of the reconfig, the slave registered with the pbmanager, so
        # get the port it was assigned
        self.port = self.buildslave.registration.getPort()
Exemplo n.º 6
0
    def test_customBuildUrls(self):
        customBuildUrls={
            'Open My Tests Tool':
                "http://tool.com/Build/View?katanaUrl={buildbotUrl}"
                "&builderName={builderName}&buildNumber={buildNumber}&buildUrl={buildUrl}",
            'name': 'url2'
        }

        cfg = config.BuilderConfig(
                name='builder',
                slavename='s1',
                project="project",
                factory=self.factory,
                customBuildUrls=customBuildUrls
        )

        expectedLinks = {
            'Open My Tests Tool': "http://tool.com/Build/View?katanaUrl=test&builderName=builder&buildNumber=1"
                                  "&buildUrl=http://buildbot.com/build/1",
            'name': 'url2'
        }

        for link in cfg.getCustomBuildUrls(buildbotUrl="test", buildNumber=1, buildUrl="http://buildbot.com/build/1"):
            self.assertTrue('name' in link and 'url' in link)
            self.assertTrue(link['name'] in customBuildUrls)
            self.assertEquals(expectedLinks[link['name']], link['url'])
Exemplo n.º 7
0
 def test_load_builders(self):
     bldr = config.BuilderConfig(name='x',
                                 factory=mock.Mock(),
                                 slavename='x')
     self.cfg.load_builders(self.filename, dict(builders=[bldr]),
                            self.errors)
     self.assertResults(builders=[bldr])
Exemplo n.º 8
0
    def addMasterSideWorker(
            self,
            connection_string=r"tcp:{port}:interface=127.0.0.1".format(
                port=DEFAULT_PORT),
            name="testworker",
            password="******",
            update_port=True,
            **kwargs):
        """
        Create a master-side worker instance and add it to the BotMaster

        @param **kwargs: arguments to pass to the L{Worker} constructor.
        """
        self.buildworker = worker.Worker(name, password, **kwargs)

        # reconfig the master to get it set up
        new_config = self.master.config
        new_config.protocols = {"pb": {"port": connection_string}}
        new_config.workers = [self.buildworker]
        new_config.builders = [
            config.BuilderConfig(name='bldr',
                                 workername='testworker',
                                 factory=factory.BuildFactory())
        ]

        yield self.botmaster.reconfigServiceWithBuildbotConfig(new_config)
        yield self.workers.reconfigServiceWithBuildbotConfig(new_config)

        if update_port:
            # as part of the reconfig, the worker registered with the
            # pbmanager, so get the port it was assigned
            self.port = self.buildworker.registration.getPBPort()
Exemplo n.º 9
0
    def test_reconfig(self):
        yield self.makeBuilder(description="Old", tags=["OldTag"])
        config_args = dict(name='bldr',
                           workername="wrk",
                           builddir="bdir",
                           workerbuilddir="wbdir",
                           factory=self.factory,
                           description='Noe',
                           tags=['OldTag'])
        new_builder_config = config.BuilderConfig(**config_args)
        new_builder_config.description = "New"
        new_builder_config.tags = ["NewTag"]

        mastercfg = config.MasterConfig()
        mastercfg.builders = [new_builder_config]
        yield self.bldr.reconfigServiceWithBuildbotConfig(mastercfg)

        # check that the reconfig grabbed a builderid
        self.assertIsNotNone(self.bldr._builderid)

        builder_dict = yield self.master.data.get(
            ('builders', self.bldr._builderid))
        self.assertEqual(builder_dict['description'], 'New')
        self.assertEqual(builder_dict['tags'], ['NewTag'])

        self.assertIdentical(self.bldr.config, new_builder_config)
Exemplo n.º 10
0
    def do_test_nextWorker(self, nextWorker, exp_choice=None):
        builder_config = config.BuilderConfig(name='bldrconf',
                                              workernames=['wk1', 'wk2'],
                                              builddir='bdir',
                                              factory=factory.BuildFactory(),
                                              nextWorker=nextWorker)
        self.bldr = yield self.createBuilder('B',
                                             builderid=78,
                                             builder_config=builder_config)
        for i in range(4):
            self.addWorkers({'test-worker%d' % i: 1})

        rows = [
            fakedb.SourceStamp(id=21),
            fakedb.Builder(id=78, name='B'),
            fakedb.Buildset(id=12, reason='because'),
            fakedb.BuildsetSourceStamp(sourcestampid=21, buildsetid=12),
            fakedb.BuildRequest(id=12, buildsetid=12, builderid=78),
        ]

        if exp_choice is None:
            exp_claims = []
            exp_builds = []
        else:
            exp_claims = [12]
            exp_builds = [('test-worker%d' % exp_choice, [12])]

        yield self.do_test_maybeStartBuildsOnBuilder(rows=rows,
                                                     exp_claims=exp_claims,
                                                     exp_builds=exp_builds)
Exemplo n.º 11
0
    def makeBuilder(self, name="bldr", patch_random=False, noReconfig=False,
                    **config_kwargs):
        """Set up C{self.bldr}"""
        # only include the necessary required config, plus user-requested
        config_args = dict(name=name, workername="slv", builddir="bdir",
                           workerbuilddir="sbdir", factory=self.factory)
        config_args.update(config_kwargs)
        self.builder_config = config.BuilderConfig(**config_args)
        self.bldr = builder.Builder(
            self.builder_config.name, _addServices=False)
        self.bldr.master = self.master
        self.bldr.botmaster = self.master.botmaster

        # patch into the _startBuildsFor method
        self.builds_started = []

        def _startBuildFor(workerforbuilder, buildrequests):
            self.builds_started.append((workerforbuilder, buildrequests))
            return defer.succeed(True)
        self.bldr._startBuildFor = _startBuildFor

        if patch_random:
            # patch 'random.choice' to always take the worker that sorts
            # last, based on its name
            self.patch(random, "choice",
                       lambda lst: sorted(lst, key=lambda m: m.name)[-1])

        self.bldr.startService()

        mastercfg = config.MasterConfig()
        mastercfg.builders = [self.builder_config]
        if not noReconfig:
            defer.returnValue((yield self.bldr.reconfigServiceWithBuildbotConfig(mastercfg)))
Exemplo n.º 12
0
    def makeBuilder(self, name="bldr", patch_random=False, **config_kwargs):
        """Set up C{self.bldr}"""
        self.factory = factory.BuildFactory()
        self.master = fakemaster.make_master()
        # only include the necessary required config, plus user-requested
        config_args = dict(name=name, slavename="slv", builddir="bdir",
                           slavebuilddir="sbdir", factory=self.factory)
        config_args.update(config_kwargs)
        self.builder_config = config.BuilderConfig(**config_args)
        self.bldr = builder.Builder(self.builder_config.name, _addServices=False)
        self.master.db = self.db = fakedb.FakeDBConnector(self)
        self.bldr.master = self.master
        self.bldr.botmaster = self.master.botmaster

        # patch into the _startBuildsFor method
        self.builds_started = []

        def _startBuildFor(slavebuilder, buildrequests):
            self.builds_started.append((slavebuilder, buildrequests))
            return defer.succeed(True)
        self.bldr._startBuildFor = _startBuildFor

        if patch_random:
            # patch 'random.choice' to always take the slave that sorts
            # last, based on its name
            self.patch(random, "choice",
                       lambda lst: sorted(lst, key=lambda m: m.name)[-1])

        self.bldr.startService()

        mastercfg = config.MasterConfig()
        mastercfg.builders = [self.builder_config]
        return self.bldr.reconfigService(mastercfg)
Exemplo n.º 13
0
 def test_args(self):
     cfg = config.BuilderConfig(name='b',
                                slavename='s1',
                                slavenames='s2',
                                builddir='bd',
                                slavebuilddir='sbd',
                                factory=self.factory,
                                category='c',
                                nextSlave=lambda: 'ns',
                                nextBuild=lambda: 'nb',
                                locks=['l'],
                                env=dict(x=10),
                                properties=dict(y=20),
                                mergeRequests='mr',
                                description='buzz')
     self.assertIdentical(cfg.factory, self.factory)
     self.assertAttributes(cfg,
                           name='b',
                           slavenames=['s2', 's1'],
                           builddir='bd',
                           slavebuilddir='sbd',
                           category='c',
                           locks=['l'],
                           env={'x': 10},
                           properties={'y': 20},
                           mergeRequests='mr',
                           description='buzz')
Exemplo n.º 14
0
 def test_tags_no_categories_too(self):
     self.assertRaisesConfigError(
         "category is being replaced by tags; you should only specify tags",
         lambda: config.BuilderConfig(tags=['abc'],
                                      category='def',
                                      name='a',
                                      slavenames=['a'],
                                      factory=self.factory))
Exemplo n.º 15
0
 def test_project(self):
     cfg = config.BuilderConfig(name="b",
               slavenames=["s1"],
               project="My Project",
               factory=self.factory)
     self.assertIdentical(cfg.factory, self.factory)
     self.assertAttributes(cfg, name='b',
                           slavenames=['s1'],
                           project="My Project")
Exemplo n.º 16
0
    def test_customBuildUrlsFailsInvalidValue(self):
        customBuildUrls="Test Tool"

        self.assertRaisesConfigError(
            "customBuildUrls must be a a dictionary containing only strings and in the format {'name': 'url'}",
            lambda : config.BuilderConfig(name='builder',
                                   slavename='s1',
                                   project="project",
                                   factory=self.factory,
                                   customBuildUrls=customBuildUrls))
Exemplo n.º 17
0
 def test_no_friendly_name(self):
     cfg = config.BuilderConfig(name="b",
               slavenames=["s1"],
               project="default",
               factory=self.factory)
     self.assertIdentical(cfg.factory, self.factory)
     self.assertAttributes(cfg, name='b',
                           slavenames=['s1'],
                           project="default",
                           friendly_name="b")
Exemplo n.º 18
0
    def setUp(self):
        self.setUpTestReactor()
        self.master = fakemaster.make_master(self,
                                             wantData=True,
                                             wantMq=True,
                                             wantDb=True)
        self.master.db.insertTestData([
            fakedb.Builder(id=80, name='test'),
        ])

        self.builder = builder.Builder('test')
        self.builder._builderid = 80
        self.builder.config_version = 0
        self.builder.master = self.master
        self.builder.botmaster = mock.Mock()
        self.builder.botmaster.getLockFromLockAccesses = lambda l, c: []
        yield self.builder.startService()

        self.factory = factory.BuildFactory()  # will have steps added later
        new_config = config.MasterConfig()
        new_config.builders.append(
            config.BuilderConfig(name='test',
                                 workername='testworker',
                                 factory=self.factory))
        yield self.builder.reconfigServiceWithBuildbotConfig(new_config)

        self.worker = Worker('worker', 'pass')
        self.worker.sendBuilderList = lambda: defer.succeed(None)
        self.worker.parent = mock.Mock()
        self.worker.master.botmaster = mock.Mock()
        self.worker.botmaster.maybeStartBuildsForWorker = lambda w: None
        self.worker.botmaster.getBuildersForWorker = lambda w: []
        self.worker.parent = self.master
        self.worker.startService()
        self.conn = fakeprotocol.FakeConnection(self.master, self.worker)
        yield self.worker.attached(self.conn)

        wfb = self.workerforbuilder = workerforbuilder.WorkerForBuilder()
        wfb.setBuilder(self.builder)
        yield wfb.attached(self.worker, {})

        # add the buildset/request
        self.bsid, brids = yield self.master.db.buildsets.addBuildset(
            sourcestamps=[{}],
            reason='x',
            properties={},
            builderids=[80],
            waited_for=False)

        self.brdict = \
            yield self.master.db.buildrequests.getBuildRequest(brids[80])

        self.buildrequest = \
            yield buildrequest.BuildRequest.fromBrdict(self.master, self.brdict)
Exemplo n.º 19
0
    def makeBuilder(self,
                    name="bldr",
                    patch_random=False,
                    noReconfig=False,
                    builderid=None,
                    **config_kwargs):
        """Set up C{self.bldr}"""
        self.factory = factory.BuildFactory()
        self.master = fakemaster.make_master(testcase=self, wantData=True)
        self.mq = self.master.mq
        self.db = self.master.db
        if builderid is None:
            b = fakedb.Builder(name=name)
            yield self.master.db.insertTestData([b])
            builderid = b.id

        # only include the necessary required config, plus user-requested
        config_args = dict(name=name,
                           slavename="slv",
                           builddir="bdir",
                           slavebuilddir="sbdir",
                           factory=self.factory)
        config_args.update(config_kwargs)
        self.builder_config = config.BuilderConfig(**config_args)
        self.bldr = builder.Builder(self.builder_config.name,
                                    _addServices=False)
        self.bldr.master = self.master
        self.bldr.botmaster = self.master.botmaster
        fbi = self.master.data.updates.findBuilderId = mock.Mock(name='fbi')
        fbi.side_effect = lambda name: defer.succeed(builderid)

        # patch into the _startBuildsFor method
        self.builds_started = []

        def _startBuildFor(slavebuilder, buildrequests):
            self.builds_started.append((slavebuilder, buildrequests))
            return defer.succeed(True)

        self.bldr._startBuildFor = _startBuildFor

        if patch_random:
            # patch 'random.choice' to always take the slave that sorts
            # last, based on its name
            self.patch(random, "choice",
                       lambda lst: sorted(lst, key=lambda m: m.name)[-1])

        self.bldr.startService()

        mastercfg = config.MasterConfig()
        mastercfg.builders = [self.builder_config]
        if not noReconfig:
            defer.returnValue((yield self.bldr.reconfigService(mastercfg)))
Exemplo n.º 20
0
    def __init__(self, props=None):
        self.build_status = FakeBuildStatus()
        self.builder = mock.Mock(name='build.builder')
        self.builder.config = config.BuilderConfig(
            name='bldr', slavenames=['a'], factory=factory.BuildFactory())
        self.path_module = posixpath
        self.workdir = 'build'

        self.sources = {}
        if props is None:
            props = properties.Properties()
        props.build = self
        self.build_status.properties = props
Exemplo n.º 21
0
    def test_does_not_reconfig_identical(self):
        yield self.makeBuilder(description="Old", tags=["OldTag"])
        new_builder_config = config.BuilderConfig(**self.config_args)

        mastercfg = MasterConfig()
        mastercfg.builders = [new_builder_config]

        builder_updates = []
        self.master.data.updates.updateBuilderInfo = \
            lambda builderid, desc, tags: builder_updates.append((builderid, desc, tags))

        yield self.bldr.reconfigServiceWithBuildbotConfig(mastercfg)
        self.assertEqual(builder_updates, [])
Exemplo n.º 22
0
    def test_customBuildUrlsFails(self):
        customBuildUrls={
            'Open My Tests Tool': "http://tool.com/Build/View?builderName={builderName}&buildNumber={buildNumber}",
            1: 2
        }

        self.assertRaisesConfigError(
            "customBuildUrls must be a a dictionary containing only strings and in the format {'name': 'url'}",
            lambda : config.BuilderConfig(name='builder',
                                   slavename='s1',
                                   project="project",
                                   factory=self.factory,
                                   customBuildUrls=customBuildUrls))
Exemplo n.º 23
0
    def setUp(self):
        self.master = fakemaster.make_master(testcase=self,
                                             wantData=True,
                                             wantMq=True,
                                             wantDb=True)
        self.master.db.insertTestData([
            fakedb.Builder(id=80, name='test'),
        ])

        self.builder = builder.Builder('test', _addServices=False)
        self.builder._builderid = 80
        self.builder.master = self.master
        yield self.builder.startService()

        self.factory = factory.BuildFactory()  # will have steps added later
        new_config = config.MasterConfig()
        new_config.builders.append(
            config.BuilderConfig(name='test',
                                 slavename='testsl',
                                 factory=self.factory))
        yield self.builder.reconfigServiceWithBuildbotConfig(new_config)

        self.slave = BuildSlave('bsl', 'pass')
        self.slave.sendBuilderList = lambda: defer.succeed(None)
        self.slave.parent = mock.Mock()
        self.slave.master.botmaster = mock.Mock()
        self.slave.botmaster.maybeStartBuildsForSlave = lambda sl: None
        self.slave.botmaster.getBuildersForSlave = lambda sl: []
        self.slave.parent = self.master
        self.slave.startService()
        self.conn = fakeprotocol.FakeConnection(self.master, self.slave)
        yield self.slave.attached(self.conn)

        sb = self.slavebuilder = slavebuilder.SlaveBuilder()
        sb.setBuilder(self.builder)
        yield sb.attached(self.slave, {})

        # add the buildset/request
        self.bsid, brids = yield self.master.db.buildsets.addBuildset(
            sourcestamps=[{}],
            reason=u'x',
            properties={},
            builderids=[80],
            waited_for=False)

        self.brdict = \
            yield self.master.db.buildrequests.getBuildRequest(brids[80])

        self.buildrequest = \
            yield buildrequest.BuildRequest.fromBrdict(self.master, self.brdict)
Exemplo n.º 24
0
 def test_getConfigDict_mergeRequests(self):
     for mr in (False, lambda a, b, c: False):
         cfg = config.BuilderConfig(name='b',
                                    mergeRequests=mr,
                                    factory=self.factory,
                                    slavename='s1')
         self.assertEqual(
             cfg.getConfigDict(), {
                 'builddir': 'b',
                 'mergeRequests': mr,
                 'name': 'b',
                 'slavebuilddir': 'b',
                 'factory': self.factory,
                 'slavenames': ['s1'],
             })
Exemplo n.º 25
0
    def __init__(self, props=None, master=None):
        self.build_status = FakeBuildStatus()
        self.builder = fakemaster.FakeBuilderStatus(master)
        self.builder.config = config.BuilderConfig(
            name='bldr', slavenames=['a'], factory=factory.BuildFactory())
        self.path_module = posixpath
        self.buildid = 92
        self.number = 13
        self.workdir = 'build'

        self.sources = {}
        if props is None:
            props = properties.Properties()
        props.build = self
        self.build_status.properties = props
Exemplo n.º 26
0
 def test_defaults(self):
     cfg = config.BuilderConfig(
         name='a b c', slavename='a', factory=self.factory)
     self.assertIdentical(cfg.factory, self.factory)
     self.assertAttributes(cfg,
         name='a b c',
         slavenames=['a'],
         builddir='a_b_c',
         slavebuilddir='a_b_c',
         category='',
         nextSlave=None,
         locks=[],
         env={},
         properties={},
         mergeRequests=None)
Exemplo n.º 27
0
    def test_reconfig_changed(self, name, new_desc, new_tags):
        yield self.makeBuilder(description="Old", tags=["OldTag"])
        new_builder_config = config.BuilderConfig(**self.config_args)
        new_builder_config.description = new_desc
        new_builder_config.tags = new_tags

        mastercfg = MasterConfig()
        mastercfg.builders = [new_builder_config]

        builder_updates = []
        self.master.data.updates.updateBuilderInfo = \
            lambda builderid, desc, tags: builder_updates.append((builderid, desc, tags))

        yield self.bldr.reconfigServiceWithBuildbotConfig(mastercfg)
        self.assertEqual(builder_updates, [(1, new_desc, new_tags)])
Exemplo n.º 28
0
 def makeBuilder(self, name, sourcestamps):
     self.bstatus = mock.Mock()
     bstatus_properties = mock.Mock()
     bstatus_properties.properties = {}
     self.bstatus.getProperties.return_value = bstatus_properties
     self.bstatus.getSourceStamps.return_value = sourcestamps
     self.factory = mock.Mock()
     self.master = fakemaster.make_master()
     # only include the necessary required config
     builder_config = config.BuilderConfig(
                     name=name, slavename="slv", builddir="bdir",
                     slavebuilddir="sbdir", factory=self.factory)
     self.bldr = builder.Builder(builder_config.name)
     self.master.db = self.db = fakedb.FakeDBConnector(self)
     self.bldr.master = self.master
     self.bldr.master.master.addBuildset.return_value = (1, [100])
Exemplo n.º 29
0
    def makeBuilder(self, name):
        self.bstatus = mock.Mock()
        self.factory = mock.Mock()
        self.master = fakemaster.make_master()
        # only include the necessary required config
        builder_config = config.BuilderConfig(
                        name=name, slavename="slv", builddir="bdir",
                        slavebuilddir="sbdir", factory=self.factory)
        self.bldr = builder.Builder(builder_config.name, _addServices=False)
        self.master.db = self.db = fakedb.FakeDBConnector(self)
        self.bldr.master = self.master

        self.bldr.startService()

        mastercfg = config.MasterConfig()
        mastercfg.builders = [ builder_config ]
        return self.bldr.reconfigService(mastercfg)
Exemplo n.º 30
0
    def setUp(self):
        self.master = fakemaster.make_master(testcase=self, wantDb=True)
        self.builder = builder.Builder('test', _addServices=False)
        self.builder.master = self.master
        yield self.builder.startService()

        self.factory = factory.BuildFactory()  # will have steps added later
        new_config = config.MasterConfig()
        new_config.builders.append(
            config.BuilderConfig(name='test',
                                 slavename='testsl',
                                 factory=self.factory))
        yield self.builder.reconfigService(new_config)

        self.slave = BuildSlave('bsl', 'pass')
        self.slave.sendBuilderList = lambda: defer.succeed(None)
        self.slave.botmaster = mock.Mock()
        self.slave.botmaster.maybeStartBuildsForSlave = lambda sl: None
        self.slave.master = self.master
        self.slave.startService()
        self.remote = FakeBot()
        yield self.slave.attached(self.remote)

        sb = self.slavebuilder = slavebuilder.SlaveBuilder()
        sb.setBuilder(self.builder)
        yield sb.attached(self.slave, self.remote, {})

        # add the buildset/request
        sssid = yield self.master.db.sourcestampsets.addSourceStampSet()
        yield self.master.db.sourcestamps.addSourceStamp(
            branch='br',
            revision='1',
            repository='r://',
            project='',
            sourcestampsetid=sssid)
        self.bsid, brids = yield self.master.db.buildsets.addBuildset(
            sourcestampsetid=sssid,
            reason=u'x',
            properties={},
            builderNames=['test'])

        self.brdict = \
            yield self.master.db.buildrequests.getBuildRequest(brids['test'])

        self.buildrequest = \
            yield buildrequest.BuildRequest.fromBrdict(self.master, self.brdict)