Exemple #1
0
    def makeBuildRequestRows(self, brid, bsid, changeid, ssid, codebase, branch=None,
                             project=None, repository=None, patchid=None, revision=None):
        rows = [
            fakedb.SourceStamp(id=ssid, codebase=codebase, branch=branch,
                               project=project, repository=repository, patchid=patchid,
                               revision=revision),
            fakedb.Buildset(id=bsid, reason='foo',
                            submitted_at=1300305712, results=-1),
            fakedb.BuildsetSourceStamp(sourcestampid=ssid, buildsetid=bsid),
            fakedb.BuildRequest(id=brid, buildsetid=bsid, builderid=77,
                            priority=13, submitted_at=1300305712, results=-1),
            ]
        if changeid:
            rows.append(
                fakedb.Change(changeid=changeid, branch='trunk', revision='9283',
                              repository='svn://...', project='world-domination',
                              sourcestampid=ssid)
                              )
        if patchid:
            rows.append(
                fakedb.Patch(id=patchid, patch_base64='aGVsbG8sIHdvcmxk',
                 patch_author='bar', patch_comment='foo', subdir='/foo',
                 patchlevel=3))

        return rows
Exemple #2
0
    def insert_buildrequest_new(self, insert_patch=False, **kwargs):
        self.db = self.master.db
        self.db.insertTestData([
            fakedb.Master(id=92),
            fakedb.Worker(id=13, name='wrk'),
            fakedb.Builder(id=79, name='Builder0'),
            fakedb.Builder(id=80, name='Builder1'),
            fakedb.Buildset(id=98, results=None, reason="testReason1",
                            parent_buildid=None),
            fakedb.BuildRequest(id=11, buildsetid=98, builderid=79)
        ])

        patchid = 99 if insert_patch else None

        self.db.insertTestData([
            fakedb.BuildsetSourceStamp(buildsetid=98, sourcestampid=234),
            fakedb.SourceStamp(
                id=234,
                branch=self.reporter_test_branch,
                project=self.reporter_test_project,
                revision=self.reporter_test_revision,
                repository=self.reporter_test_repo,
                codebase=self.reporter_test_codebase,
                patchid=patchid),
            fakedb.Patch(id=99, patch_base64='aGVsbG8sIHdvcmxk',
                         patch_author='him@foo', patch_comment='foo', subdir='/foo',
                         patchlevel=3)
        ])
        request = yield self.master.data.get(("buildrequests", 11))
        return request
Exemple #3
0
 def setUp(self):
     self.setUpEndpoint()
     self.db.insertTestData([
         fakedb.SourceStamp(id=13, branch='oak'),
         fakedb.Patch(id=99,
                      patch_base64='aGVsbG8sIHdvcmxk',
                      patch_author='bar',
                      patch_comment='foo',
                      subdir='/foo',
                      patchlevel=3),
         fakedb.SourceStamp(id=14, patchid=99, branch='poplar'),
     ])
    def setupDb(self):
        self.db = self.master.db
        self.db.insertTestData([
            fakedb.Master(id=92),
            fakedb.Worker(id=13, name='wrk'),
            fakedb.Buildset(id=98, results=SUCCESS, reason="testReason1"),
            fakedb.Builder(id=80, name='Builder1'),
            fakedb.BuildRequest(id=9, buildsetid=97, builderid=80),
            fakedb.BuildRequest(id=10, buildsetid=97, builderid=80),
            fakedb.BuildRequest(id=11, buildsetid=98, builderid=80),
            fakedb.BuildRequest(id=12, buildsetid=98, builderid=80),
            fakedb.Build(id=18, number=0, builderid=80, buildrequestid=9, workerid=13,
                         masterid=92, results=FAILURE),
            fakedb.Build(id=19, number=1, builderid=80, buildrequestid=10, workerid=13,
                         masterid=92, results=RETRY),
            fakedb.Build(id=20, number=2, builderid=80, buildrequestid=11, workerid=13,
                         masterid=92, results=SUCCESS),
            fakedb.Build(id=21, number=3, builderid=80, buildrequestid=12, workerid=13,
                         masterid=92, results=SUCCESS),
            fakedb.BuildsetSourceStamp(buildsetid=98, sourcestampid=234),
            fakedb.SourceStamp(id=234),
            fakedb.Change(changeid=13, branch='trunk', revision='9283', author='me@foo',
                          repository='svn://...', codebase='cbsvn',
                          project='world-domination', sourcestampid=234),
            fakedb.Patch(id=99, patch_base64='aGVsbG8sIHdvcmxk',
                         patch_author='him@foo', patch_comment='foo', subdir='/foo',
                         patchlevel=3),
            fakedb.SourceStamp(id=235, patchid=99),
        ])
        for _id in (20, 21):
            self.db.insertTestData([
                fakedb.BuildProperty(
                    buildid=_id, name="workername", value="wrk"),
                fakedb.BuildProperty(
                    buildid=_id, name="reason", value="because"),
                fakedb.BuildProperty(
                    buildid=_id, name="owner", value="him"),
                fakedb.Step(id=100 + _id, buildid=_id, name="step1"),
                fakedb.Step(id=200 + _id, buildid=_id, name="step2"),
                fakedb.Log(id=60 + _id, stepid=100 + _id, name='stdio', slug='stdio', type='s',
                           num_lines=2),
                fakedb.LogChunk(logid=60 + _id, first_line=0, last_line=1, compressed=0,
                                content=self.LOGCONTENT),
            ])

        @defer.inlineCallbacks
        def getChangesForBuild(buildid):
            assert buildid == 20
            ch = yield self.master.db.changes.getChange(13)
            return [ch]

        self.master.db.changes.getChangesForBuild = getChangesForBuild
Exemple #5
0
    def setupBuildResults(self, results, wantPreviousBuild=False):
        # this testsuite always goes through setupBuildResults so that
        # the data is sure to be the real data schema known coming from data
        # api

        self.db = self.master.db
        self.db.insertTestData([
            fakedb.Master(id=92),
            fakedb.Worker(id=13, name='wrk'),
            fakedb.Buildset(id=98, results=results, reason="testReason1"),
            fakedb.Builder(id=80, name='Builder1'),
            fakedb.BuildRequest(id=11, buildsetid=98, builderid=80),
            fakedb.Build(id=20, number=0, builderid=80, buildrequestid=11, workerid=13,
                         masterid=92, results=results),
            fakedb.Step(id=50, buildid=20, number=5, name='make'),
            fakedb.BuildsetSourceStamp(buildsetid=98, sourcestampid=234),
            fakedb.SourceStamp(id=234, patchid=99),
            fakedb.Change(changeid=13, branch='trunk', revision='9283', author='me@foo',
                          repository='svn://...', codebase='cbsvn',
                          project='world-domination', sourcestampid=234),
            fakedb.Log(id=60, stepid=50, name='stdio', slug='stdio', type='s',
                       num_lines=7),
            fakedb.LogChunk(logid=60, first_line=0, last_line=1, compressed=0,
                            content='Unicode log with non-ascii (\u00E5\u00E4\u00F6).'),
            fakedb.Patch(id=99, patch_base64='aGVsbG8sIHdvcmxk',
                         patch_author='him@foo', patch_comment='foo', subdir='/foo',
                         patchlevel=3),
        ])
        for _id in (20,):
            self.db.insertTestData([
                fakedb.BuildProperty(
                    buildid=_id, name="workername", value="wrk"),
                fakedb.BuildProperty(
                    buildid=_id, name="reason", value="because"),
                fakedb.BuildProperty(
                    buildid=_id, name="scheduler", value="checkin"),
                fakedb.BuildProperty(
                    buildid=_id, name="branch", value="master"),
            ])
        res = yield utils.getDetailsForBuildset(self.master, 98, wantProperties=True,
                                                wantPreviousBuild=wantPreviousBuild)
        builds = res['builds']
        buildset = res['buildset']

        @defer.inlineCallbacks
        def getChangesForBuild(buildid):
            assert buildid == 20
            ch = yield self.master.db.changes.getChange(13)
            return [ch]

        self.master.db.changes.getChangesForBuild = getChangesForBuild
        return (buildset, builds)
    def test_getSourceStamp_patch(self):
        yield self.insertTestData([
            fakedb.Patch(id=99, patch_base64='aGVsbG8sIHdvcmxk',
                         patch_author='bar', patch_comment='foo', subdir='/foo',
                         patchlevel=3),
            fakedb.SourceStamp(id=234, patchid=99),
        ])
        ssdict = yield self.db.sourcestamps.getSourceStamp(234)

        validation.verifyDbDict(self, 'ssdict', ssdict)
        self.assertEqual(dict((k, v) for k, v in ssdict.items()
                              if k.startswith('patch_')),
                         dict(patch_body=b'hello, world',
                              patch_level=3,
                              patch_author='bar',
                              patch_comment='foo',
                              patch_subdir='/foo'))
    def test_getSourceStamps(self):
        yield self.insertTestData([
            fakedb.Patch(id=99, patch_base64='aGVsbG8sIHdvcmxk',
                         patch_author='bar', patch_comment='foo', subdir='/foo',
                         patchlevel=3),
            fakedb.SourceStamp(id=234, revision='r', project='p',
                               codebase='c', repository='rep', branch='b', patchid=99,
                               created_at=CREATED_AT),
            fakedb.SourceStamp(id=235, revision='r2', project='p2',
                               codebase='c2', repository='rep2', branch='b2', patchid=None,
                               created_at=CREATED_AT + 10),
        ])
        sourcestamps = yield self.db.sourcestamps.getSourceStamps()

        self.assertEqual(sorted(sourcestamps, key=sourceStampKey),
                         sorted([{
                                 'branch': 'b',
                                 'codebase': 'c',
                                 'patch_author': 'bar',
                                 'patchid': 99,
                                 'patch_body': b'hello, world',
                                 'patch_comment': 'foo',
                                 'patch_level': 3,
                                 'patch_subdir': '/foo',
                                 'project': 'p',
                                 'repository': 'rep',
                                 'revision': 'r',
                                 'created_at': epoch2datetime(CREATED_AT),
                                 'ssid': 234,
                                 }, {
                                 'branch': 'b2',
                                 'codebase': 'c2',
                                 'patchid': None,
                                 'patch_author': None,
                                 'patch_body': None,
                                 'patch_comment': None,
                                 'patch_level': None,
                                 'patch_subdir': None,
                                 'project': 'p2',
                                 'repository': 'rep2',
                                 'revision': 'r2',
                                 'created_at': epoch2datetime(CREATED_AT + 10),
                                 'ssid': 235,
                                 }], key=sourceStampKey))
Exemple #8
0
    def insertTestData(self,
                       buildResults,
                       finalResult,
                       insertSS=True,
                       parentPlan=False,
                       insert_patch=False):
        self.db = self.master.db
        self.db.insertTestData([
            fakedb.Master(id=92),
            fakedb.Worker(id=13, name='wrk'),
            fakedb.Builder(id=79, name='Builder0'),
            fakedb.Builder(id=80, name='Builder1'),
            fakedb.Buildset(id=98,
                            results=finalResult,
                            reason="testReason1",
                            parent_buildid=19 if parentPlan else None),
            fakedb.Change(changeid=13,
                          branch=self.TEST_BRANCH,
                          revision='9283',
                          author='me@foo',
                          repository=self.TEST_REPO,
                          codebase=self.TEST_CODEBASE,
                          project='world-domination',
                          sourcestampid=234),
        ])

        if parentPlan:
            self.db.insertTestData([
                fakedb.Worker(id=12, name='wrk_parent'),
                fakedb.Builder(id=78, name='Builder_parent'),
                fakedb.Buildset(id=97,
                                results=finalResult,
                                reason="testReason0"),
                fakedb.BuildRequest(id=10, buildsetid=98, builderid=78),
                fakedb.Build(id=19,
                             number=1,
                             builderid=78,
                             buildrequestid=10,
                             workerid=12,
                             masterid=92,
                             results=finalResult,
                             state_string="buildText"),
            ])

        if insertSS:
            patchid = 99 if insert_patch else None

            self.db.insertTestData([
                fakedb.BuildsetSourceStamp(buildsetid=98, sourcestampid=234),
                fakedb.SourceStamp(id=234,
                                   branch=self.TEST_BRANCH,
                                   project=self.TEST_PROJECT,
                                   revision=self.TEST_REVISION,
                                   repository=self.TEST_REPO,
                                   codebase=self.TEST_CODEBASE,
                                   patchid=patchid),
                fakedb.Patch(id=99,
                             patch_base64='aGVsbG8sIHdvcmxk',
                             patch_author='him@foo',
                             patch_comment='foo',
                             subdir='/foo',
                             patchlevel=3),
            ])

        for i, results in enumerate(buildResults):
            started_at = 10000001
            complete_at = None if results is None else 10000005
            self.db.insertTestData([
                fakedb.BuildRequest(id=11 + i, buildsetid=98,
                                    builderid=79 + i),
                fakedb.Build(id=20 + i,
                             number=i,
                             builderid=79 + i,
                             buildrequestid=11 + i,
                             workerid=13,
                             masterid=92,
                             results=results,
                             state_string="buildText",
                             started_at=started_at,
                             complete_at=complete_at),
                fakedb.Step(id=50 + i, buildid=20 + i, number=5, name='make'),
                fakedb.Log(id=60 + i,
                           stepid=50 + i,
                           name='stdio',
                           slug='stdio',
                           type='s',
                           num_lines=7),
                fakedb.LogChunk(
                    logid=60 + i,
                    first_line=0,
                    last_line=1,
                    compressed=0,
                    content='Unicode log with non-ascii (\u00E5\u00E4\u00F6).'
                ),
                fakedb.BuildProperty(buildid=20 + i,
                                     name="workername",
                                     value="wrk"),
                fakedb.BuildProperty(buildid=20 + i,
                                     name="reason",
                                     value="because"),
                fakedb.BuildProperty(buildid=20 + i,
                                     name="buildername",
                                     value="Builder0"),
                fakedb.BuildProperty(buildid=20 + i,
                                     name="buildnumber",
                                     value="{}".format(i)),
                fakedb.BuildProperty(buildid=20 + i,
                                     name="scheduler",
                                     value="checkin"),
            ])
            for k, v in self.TEST_PROPS.items():
                self.db.insertTestData(
                    [fakedb.BuildProperty(buildid=20 + i, name=k, value=v)])

            @defer.inlineCallbacks
            def getChangesForBuild(buildid):
                assert buildid == 20
                ch = yield self.master.db.changes.getChange(13)
                return [ch]

            self.master.db.changes.getChangesForBuild = getChangesForBuild