示例#1
0
    def test_getDetailsForBuildsetWithLogs(self):
        self.setupDb()
        res = yield utils.getDetailsForBuildset(self.master, 98, wantProperties=True,
                                                wantSteps=True, wantPreviousBuild=True, wantLogs=True)

        build1 = res['builds'][0]
        self.assertEqual(build1['steps'][0]['logs'][0]['content']['content'], self.LOGCONTENT)
 def doOneTest(self, lastresults, results, mode="all"):
     self.setupDb(results, lastresults)
     res = yield utils.getDetailsForBuildset(self.master, 99, wantProperties=True)
     build = res['builds'][0]
     buildset = res['buildset']
     res = self.message(mode, "Builder1", buildset, build, self.master,
                        lastresults, ["him@bar", "me@foo"])
     defer.returnValue(res)
示例#3
0
 def buildsetComplete(self, key, msg):
     if not self.summaryCB:
         return
     bsid = msg["bsid"]
     res = yield utils.getDetailsForBuildset(self.master, bsid, wantProperties=True)
     builds = res["builds"]
     buildset = res["buildset"]
     self.sendBuildSetSummary(buildset, builds)
示例#4
0
文件: gerrit.py 项目: Cray/buildbot
 def buildsetComplete(self, key, msg):
     if not self.summaryCB:
         return
     bsid = msg['bsid']
     res = yield utils.getDetailsForBuildset(
         self.master, bsid, wantProperties=True,
         wantSteps=self.wantSteps, wantLogs=self.wantLogs)
     builds = res['builds']
     buildset = res['buildset']
     self.sendBuildSetSummary(buildset, builds)
示例#5
0
    def test_getDetailsForBuildsetWithLogs(self):
        self.setupDb()
        res = yield utils.getDetailsForBuildset(self.master,
                                                98,
                                                wantProperties=True,
                                                wantSteps=True,
                                                wantPreviousBuild=True,
                                                wantLogs=True)

        build1 = res['builds'][0]
        self.assertEqual(build1['steps'][0]['logs'][0]['content']['content'],
                         self.LOGCONTENT)
示例#6
0
文件: gerrit.py 项目: mv740/buildbot
 def buildsetComplete(self, key, msg):
     if not self.summaryCB:
         return
     bsid = msg['bsid']
     res = yield utils.getDetailsForBuildset(self.master,
                                             bsid,
                                             wantProperties=True,
                                             wantSteps=self.wantSteps,
                                             wantLogs=self.wantLogs)
     builds = res['builds']
     buildset = res['buildset']
     self.sendBuildSetSummary(buildset, builds)
示例#7
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=u'trunk', revision=u'9283', author='me@foo',
                          repository=u'svn://...', codebase=u'cbsvn',
                          project=u'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=u'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)
            defer.returnValue([ch])

        self.master.db.changes.getChangesForBuild = getChangesForBuild
        defer.returnValue((buildset, builds))
示例#8
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=u'trunk', revision=u'9283', author='me@foo',
                          repository=u'svn://...', codebase=u'cbsvn',
                          project=u'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=u'Unicode log with non-ascii (\u00E5\u00E4\u00F6).'),
            fakedb.Patch(id=99, patch_base64=u'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)
            defer.returnValue([ch])

        self.master.db.changes.getChangesForBuild = getChangesForBuild
        defer.returnValue((buildset, builds))
示例#9
0
    def setupBuildResults(self, buildResults, finalResult):
        self.insertTestData(buildResults, finalResult)
        res = yield utils.getDetailsForBuildset(self.master, 98, wantProperties=True)
        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)
示例#10
0
    def setupBuildResults(self, buildResults, finalResult):
        self.insertTestData(buildResults, finalResult)
        res = yield utils.getDetailsForBuildset(self.master, 98, wantProperties=True)
        builds = res['builds']
        buildset = res['buildset']

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

        self.master.db.changes.getChangesForBuild = getChangesForBuild
        defer.returnValue((buildset, builds))
示例#11
0
    def setupBuildResults(self, buildResults, finalResult):
        # 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='sl'),
            fakedb.Builder(id=79, name='Builder0'),
            fakedb.Builder(id=80, name='Builder1'),
            fakedb.Buildset(id=98, results=finalResult, reason="testReason1"),
            fakedb.BuildsetSourceStamp(buildsetid=98, sourcestampid=234),
            fakedb.SourceStamp(id=234),
            fakedb.Change(changeid=13, branch=u'master', revision=u'9283', author='me@foo',
                          repository=u'https://...', codebase=u'cbgerrit',
                          project=u'world-domination', sourcestampid=234),
        ])
        i = 0
        for results in buildResults:
            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=u"buildText"),
                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=u'Unicode log with non-ascii (\u00E5\u00E4\u00F6).'),
                fakedb.BuildProperty(buildid=20 + i, name="workername", value="sl"),
                fakedb.BuildProperty(buildid=20 + i, name="reason", value="because"),
            ])
            for k, v in iteritems(self.TEST_PROPS):
                self.db.insertTestData([
                    fakedb.BuildProperty(buildid=20 + i, name=k, value=v)
                    ])
            i += 1
        res = yield utils.getDetailsForBuildset(self.master, 98, wantProperties=True)
        builds = res['builds']
        buildset = res['buildset']

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

        self.master.db.changes.getChangesForBuild = getChangesForBuild
        defer.returnValue((buildset, builds))
    def setupBuildResults(self, buildResults, finalResult):
        # 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.Buildslave(id=13, name='sl'),
            fakedb.Builder(id=79, name='Builder0'),
            fakedb.Builder(id=80, name='Builder1'),
            fakedb.Buildset(id=98, results=finalResult, reason="testReason1"),
            fakedb.BuildsetSourceStamp(buildsetid=98, sourcestampid=234),
            fakedb.SourceStamp(id=234),
            fakedb.Change(changeid=13, branch=u'master', revision=u'9283', author='me@foo',
                          repository=u'https://...', codebase=u'cbgerrit',
                          project=u'world-domination', sourcestampid=234),
        ])
        i = 0
        for results in buildResults:
            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, buildslaveid=13,
                             masterid=92, results=results, state_string=u"buildText"),
                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=u'Unicode log with non-ascii (\u00E5\u00E4\u00F6).'),
                fakedb.BuildProperty(buildid=20 + i, name="slavename", value="sl"),
                fakedb.BuildProperty(buildid=20 + i, name="reason", value="because"),
            ])
            for k, v in iteritems(self.TEST_PROPS):
                self.db.insertTestData([
                    fakedb.BuildProperty(buildid=20 + i, name=k, value=v)
                    ])
            i += 1
        res = yield utils.getDetailsForBuildset(self.master, 98, wantProperties=True)
        builds = res['builds']
        buildset = res['buildset']

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

        self.master.db.changes.getChangesForBuild = getChangesForBuild
        defer.returnValue((buildset, builds))
示例#13
0
    def test_getDetailsForBuildsetWithLogs(self):
        self.setupDb()
        res = yield utils.getDetailsForBuildset(self.master,
                                                98,
                                                want_properties=True,
                                                want_steps=True,
                                                want_previous_build=True,
                                                want_logs=True,
                                                want_logs_content=True)

        build1 = res['builds'][0]
        self.assertEqual(build1['steps'][0]['logs'][0]['content']['content'],
                         self.LOGCONTENT)
        self.assertEqual(
            build1['steps'][0]['logs'][0]['url'],
            'http://localhost:8080/#builders/80/builds/2/steps/29/logs/stdio')
示例#14
0
    def buildsetComplete(self, key, msg):
        if not self.buildSetSummary:
            return
        bsid = msg['bsid']
        res = yield utils.getDetailsForBuildset(
            self.master, bsid,
            wantProperties=self.messageFormatter.wantProperties,
            wantSteps=self.messageFormatter.wantSteps,
            wantPreviousBuild=self.wantPreviousBuild())

        builds = res['builds']
        buildset = res['buildset']

        # only include builds for which isMailNeeded returns true
        builds = [build for build in builds if self.isMailNeeded(build)]
        if builds:
            self.buildMessage("(whole buildset)", builds, buildset['results'])
示例#15
0
    def buildsetComplete(self, key, msg):
        if not self.buildSetSummary:
            return
        bsid = msg['bsid']
        res = yield utils.getDetailsForBuildset(
            self.master, bsid,
            wantProperties=self.messageFormatter.wantProperties,
            wantSteps=self.messageFormatter.wantSteps,
            wantPreviousBuild=self.wantPreviousBuild())

        builds = res['builds']
        buildset = res['buildset']

        # only include builds for which isMailNeeded returns true
        builds = [build for build in builds if self.isMailNeeded(build)]
        if builds:
            self.buildMessage("(whole buildset)", builds, buildset['results'])
示例#16
0
    def test_getDetailsForBuildset(self):
        self.setupDb()
        res = yield utils.getDetailsForBuildset(self.master, 98, wantProperties=True,
                                                wantSteps=True, wantPreviousBuild=True)
        self.assertEqual(len(res['builds']), 2)
        build1 = res['builds'][0]
        build2 = res['builds'][1]
        buildset = res['buildset']
        self.assertEqual(build1['properties'], {u'reason': (u'because', u'fakedb'),
                                                u'slavename': (u'sl', u'fakedb')})
        self.assertEqual(len(build1['steps']), 2)
        self.assertEqual(build1['buildid'], 20)
        self.assertEqual(build2['buildid'], 21)
        self.assertEqual(buildset['bsid'], 98)

        # make sure prev_build was computed
        self.assertEqual(build1['prev_build']['buildid'], 18)
        self.assertEqual(build2['prev_build']['buildid'], 20)
示例#17
0
    def generate(self, master, reporter, key, message):
        bsid = message['bsid']
        res = yield utils.getDetailsForBuildset(
            master,
            bsid,
            wantProperties=self.formatter.wantProperties,
            wantSteps=self.formatter.wantSteps,
            wantPreviousBuild=self._want_previous_build(),
            wantLogs=self.formatter.wantLogs)

        builds = res['builds']
        buildset = res['buildset']

        # only include builds for which isMessageNeeded returns true
        builds = [build for build in builds if self.is_message_needed(build)]
        if not builds:
            return None

        report = yield self.build_message(master, reporter, "whole buildset",
                                          builds, buildset['results'])
        return report
示例#18
0
    def test_get_details_for_buildset_all(self):
        self.setupDb()
        res = yield utils.getDetailsForBuildset(self.master,
                                                98,
                                                want_properties=True,
                                                want_steps=True,
                                                want_previous_build=True,
                                                want_logs=True,
                                                want_logs_content=True)

        self.assertEqual(
            res, {
                'builds': [{
                    'builder': {
                        'builderid': 80,
                        'description': None,
                        'masterids': [],
                        'name': 'Builder1',
                        'tags': []
                    },
                    'builderid':
                    80,
                    'buildid':
                    20,
                    'buildrequestid':
                    11,
                    'buildset': {
                        'bsid':
                        98,
                        'complete':
                        False,
                        'complete_at':
                        None,
                        'external_idstring':
                        'extid',
                        'parent_buildid':
                        None,
                        'parent_relationship':
                        None,
                        'reason':
                        'testReason1',
                        'results':
                        0,
                        'sourcestamps': [{
                            'branch':
                            'master',
                            'codebase':
                            '',
                            'created_at':
                            datetime.datetime(
                                1972, 11, 5, 18, 7, 14, tzinfo=tzutc()),
                            'patch':
                            None,
                            'project':
                            'proj',
                            'repository':
                            'repo',
                            'revision':
                            'abcd',
                            'ssid':
                            234
                        }],
                        'submitted_at':
                        12345678
                    },
                    'complete':
                    False,
                    'complete_at':
                    None,
                    'masterid':
                    92,
                    'number':
                    2,
                    'prev_build': {
                        'builderid':
                        80,
                        'buildid':
                        18,
                        'buildrequestid':
                        9,
                        'complete':
                        False,
                        'complete_at':
                        None,
                        'masterid':
                        92,
                        'number':
                        0,
                        'properties': {},
                        'results':
                        2,
                        'started_at':
                        datetime.datetime(
                            2011, 5, 1, 15, 3, 42, tzinfo=tzutc()),
                        'state_string':
                        'test',
                        'workerid':
                        13
                    },
                    'properties': {
                        'owner': ('him', 'fakedb'),
                        'reason': ('because', 'fakedb'),
                        'workername': ('wrk', 'fakedb')
                    },
                    'results':
                    0,
                    'started_at':
                    datetime.datetime(2011, 5, 1, 15, 3, 42, tzinfo=tzutc()),
                    'state_string':
                    'test',
                    'steps': [{
                        'buildid':
                        20,
                        'complete':
                        False,
                        'complete_at':
                        None,
                        'hidden':
                        False,
                        'logs': [{
                            'complete':
                            False,
                            'content': {
                                'content': 'line zero\nline 1\n',
                                'firstline': 0,
                                'logid': 80
                            },
                            'logid':
                            80,
                            'name':
                            'stdio',
                            'num_lines':
                            2,
                            'slug':
                            'stdio',
                            'stepid':
                            120,
                            'type':
                            's',
                            'url':
                            'http://localhost:8080/#builders/80/builds/2/steps/29/logs/stdio'
                        }],
                        'name':
                        'step1',
                        'number':
                        29,
                        'results':
                        None,
                        'started_at':
                        datetime.datetime(
                            2011, 5, 1, 15, 3, 42, tzinfo=tzutc()),
                        'state_string':
                        '',
                        'stepid':
                        120,
                        'urls': []
                    }, {
                        'buildid':
                        20,
                        'complete':
                        False,
                        'complete_at':
                        None,
                        'hidden':
                        False,
                        'logs': [],
                        'name':
                        'step2',
                        'number':
                        29,
                        'results':
                        None,
                        'started_at':
                        datetime.datetime(
                            2011, 5, 1, 15, 3, 42, tzinfo=tzutc()),
                        'state_string':
                        '',
                        'stepid':
                        220,
                        'urls': []
                    }],
                    'url':
                    'http://localhost:8080/#builders/80/builds/2',
                    'workerid':
                    13
                }, {
                    'builder': {
                        'builderid': 80,
                        'description': None,
                        'masterids': [],
                        'name': 'Builder1',
                        'tags': []
                    },
                    'builderid':
                    80,
                    'buildid':
                    21,
                    'buildrequestid':
                    12,
                    'buildset': {
                        'bsid':
                        98,
                        'complete':
                        False,
                        'complete_at':
                        None,
                        'external_idstring':
                        'extid',
                        'parent_buildid':
                        None,
                        'parent_relationship':
                        None,
                        'reason':
                        'testReason1',
                        'results':
                        0,
                        'sourcestamps': [{
                            'branch':
                            'master',
                            'codebase':
                            '',
                            'created_at':
                            datetime.datetime(
                                1972, 11, 5, 18, 7, 14, tzinfo=tzutc()),
                            'patch':
                            None,
                            'project':
                            'proj',
                            'repository':
                            'repo',
                            'revision':
                            'abcd',
                            'ssid':
                            234
                        }],
                        'submitted_at':
                        12345678
                    },
                    'complete':
                    False,
                    'complete_at':
                    None,
                    'masterid':
                    92,
                    'number':
                    3,
                    'prev_build': {
                        'builderid':
                        80,
                        'buildid':
                        20,
                        'buildrequestid':
                        11,
                        'complete':
                        False,
                        'complete_at':
                        None,
                        'masterid':
                        92,
                        'number':
                        2,
                        'properties': {},
                        'results':
                        0,
                        'started_at':
                        datetime.datetime(
                            2011, 5, 1, 15, 3, 42, tzinfo=tzutc()),
                        'state_string':
                        'test',
                        'workerid':
                        13
                    },
                    'properties': {
                        'owner': ('him', 'fakedb'),
                        'reason': ('because', 'fakedb'),
                        'workername': ('wrk', 'fakedb')
                    },
                    'results':
                    0,
                    'started_at':
                    datetime.datetime(2011, 5, 1, 15, 3, 42, tzinfo=tzutc()),
                    'state_string':
                    'test',
                    'steps': [{
                        'buildid':
                        21,
                        'complete':
                        False,
                        'complete_at':
                        None,
                        'hidden':
                        False,
                        'logs': [{
                            'complete':
                            False,
                            'content': {
                                'content': 'line zero\nline 1\n',
                                'firstline': 0,
                                'logid': 81
                            },
                            'logid':
                            81,
                            'name':
                            'stdio',
                            'num_lines':
                            2,
                            'slug':
                            'stdio',
                            'stepid':
                            121,
                            'type':
                            's',
                            'url':
                            'http://localhost:8080/#builders/80/builds/3/steps/29/logs/stdio'
                        }],
                        'name':
                        'step1',
                        'number':
                        29,
                        'results':
                        None,
                        'started_at':
                        datetime.datetime(
                            2011, 5, 1, 15, 3, 42, tzinfo=tzutc()),
                        'state_string':
                        '',
                        'stepid':
                        121,
                        'urls': []
                    }, {
                        'buildid':
                        21,
                        'complete':
                        False,
                        'complete_at':
                        None,
                        'hidden':
                        False,
                        'logs': [],
                        'name':
                        'step2',
                        'number':
                        29,
                        'results':
                        None,
                        'started_at':
                        datetime.datetime(
                            2011, 5, 1, 15, 3, 42, tzinfo=tzutc()),
                        'state_string':
                        '',
                        'stepid':
                        221,
                        'urls': []
                    }],
                    'url':
                    'http://localhost:8080/#builders/80/builds/3',
                    'workerid':
                    13
                }],
                'buildset': {
                    'bsid':
                    98,
                    'complete':
                    False,
                    'complete_at':
                    None,
                    'external_idstring':
                    'extid',
                    'parent_buildid':
                    None,
                    'parent_relationship':
                    None,
                    'reason':
                    'testReason1',
                    'results':
                    0,
                    'sourcestamps': [{
                        'branch':
                        'master',
                        'codebase':
                        '',
                        'created_at':
                        datetime.datetime(
                            1972, 11, 5, 18, 7, 14, tzinfo=tzutc()),
                        'patch':
                        None,
                        'project':
                        'proj',
                        'repository':
                        'repo',
                        'revision':
                        'abcd',
                        'ssid':
                        234
                    }],
                    'submitted_at':
                    12345678
                }
            })