Exemplo n.º 1
0
 def setUp(self):
     self.setUpEndpoint()
     self.db.insertTestData([
         fakedb.Builder(id=77, name='builder77'),
         fakedb.Master(id=88),
         fakedb.Worker(id=13, name='wrk'),
         fakedb.Buildset(id=8822),
         fakedb.BuildRequest(id=82, buildsetid=8822, builderid=77),
         fakedb.Build(id=13,
                      builderid=77,
                      masterid=88,
                      workerid=13,
                      buildrequestid=82,
                      number=3),
         fakedb.Build(id=14,
                      builderid=77,
                      masterid=88,
                      workerid=13,
                      buildrequestid=82,
                      number=4),
         fakedb.Build(id=15,
                      builderid=77,
                      masterid=88,
                      workerid=13,
                      buildrequestid=82,
                      number=5),
         fakedb.BuildProperty(buildid=13,
                              name='reason',
                              value='"force build"',
                              source="Force Build Form"),
     ])
Exemplo n.º 2
0
    def setupDb(self, results1, results2):

        self.db = self.master.db
        self.db.insertTestData([
            fakedb.Master(id=92),
            fakedb.Worker(id=13, name='wrkr'),
            fakedb.Buildset(id=98, results=results1, reason="testReason1"),
            fakedb.Buildset(id=99, results=results2, reason="testReason2"),
            fakedb.Builder(id=80, name='Builder1'),
            fakedb.BuildRequest(id=11, buildsetid=98, builderid=80),
            fakedb.BuildRequest(id=12, buildsetid=99, builderid=80),
            fakedb.Build(id=20,
                         number=0,
                         builderid=80,
                         buildrequestid=11,
                         workerid=13,
                         masterid=92,
                         results=results1),
            fakedb.Build(id=21,
                         number=1,
                         builderid=80,
                         buildrequestid=12,
                         workerid=13,
                         masterid=92,
                         results=results2),
        ])
        for _id in (20, 21):
            self.db.insertTestData([
                fakedb.BuildProperty(buildid=_id,
                                     name="workername",
                                     value="wrkr"),
                fakedb.BuildProperty(buildid=_id,
                                     name="reason",
                                     value="because"),
            ])
Exemplo n.º 3
0
 def setupSomeBuilds(self):
     self.master.db.insertTestData([
         # Three builds on builder#0, One build on builder#1
         fakedb.Build(id=13,
                      masterid=88,
                      workerid=13,
                      builderid=self.BUILDER_IDS[0],
                      buildrequestid=82,
                      number=3),
         fakedb.Build(id=14,
                      masterid=88,
                      workerid=13,
                      builderid=self.BUILDER_IDS[0],
                      buildrequestid=83,
                      number=4),
         fakedb.Build(id=15,
                      masterid=88,
                      workerid=13,
                      builderid=self.BUILDER_IDS[1],
                      buildrequestid=84,
                      number=5),
         fakedb.Build(id=16,
                      masterid=88,
                      workerid=13,
                      builderid=self.BUILDER_IDS[0],
                      buildrequestid=85,
                      number=6),
     ])
     self.master.db.builds.finishBuild(buildid=14, results=SUCCESS)
Exemplo n.º 4
0
 def setUp(self):
     self.setUpEndpoint()
     self.db.insertTestData([
         fakedb.Builder(id=77, name='builder77'),
         fakedb.Master(id=88),
         fakedb.Worker(id=13, name='wrk'),
         fakedb.Buildset(id=8822),
         fakedb.BuildRequest(id=82, buildsetid=8822, builderid=77),
         fakedb.Build(id=13,
                      builderid=77,
                      masterid=88,
                      workerid=13,
                      buildrequestid=82,
                      number=3),
         fakedb.Build(id=14,
                      builderid=77,
                      masterid=88,
                      workerid=13,
                      buildrequestid=82,
                      number=4),
         fakedb.Build(id=15,
                      builderid=77,
                      masterid=88,
                      workerid=13,
                      buildrequestid=82,
                      number=5),
     ])
Exemplo n.º 5
0
    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
Exemplo n.º 6
0
    def test_source_stamp_no_props_nightly_scheduler(self):
        # no status updates are expected

        self.master.db.insertTestData([
            fakedb.Master(id=92),
            fakedb.Worker(id=13, name='wrk'),
            fakedb.Builder(id=79, name='Builder0'),
            fakedb.Buildset(id=98, results=SUCCESS, reason="test_reason1"),
            fakedb.BuildsetSourceStamp(buildsetid=98, sourcestampid=234),
            fakedb.SourceStamp(id=234, project=None, branch=None, revision=None,
                               repository=None, codebase=None),
            fakedb.BuildRequest(id=11, buildsetid=98, builderid=79),
            fakedb.Build(id=20, number=0, builderid=79, buildrequestid=11,
                         workerid=13, masterid=92, results=SUCCESS, state_string="build_text"),
            fakedb.BuildProperty(buildid=20, name="workername", value="wrk"),
            fakedb.BuildProperty(buildid=20, name="reason", value="because"),
            fakedb.BuildProperty(buildid=20, name="buildername", value="Builder0"),
            fakedb.BuildProperty(buildid=20, name="branch", value=None),
            fakedb.BuildProperty(buildid=20, name="codebase", value=""),
            fakedb.BuildProperty(buildid=20, name="project", value=""),
            fakedb.BuildProperty(buildid=20, name="repository", value=""),
            fakedb.BuildProperty(buildid=20, name="revision", value=None),
        ])

        self.setup_fake_get_changes_for_build(has_change=False)

        build = yield self.master.data.get(("builds", 20))

        build['complete'] = False
        yield self.sp._got_event(('builds', 20, 'new'), build)
        build['complete'] = True
        yield self.sp._got_event(('builds', 20, 'finished'), build)
        build['results'] = SUCCESS
        yield self.sp._got_event(('builds', 20, 'finished'), build)
Exemplo n.º 7
0
        def addBuild(codebase_ss, results=0):

            lastID["buildid"] += 1
            lastID["buildsetid"] += 1
            lastID["buildrequestid"] += 1

            buildRows = [fakedb.Buildset(id=lastID["buildsetid"],
                                         reason='foo',
                                         submitted_at=1300305012, results=-1)]
            for cb, ss in codebase_ss.items():
                lastID["buildsetSourceStampid"] += 1
                buildRows.append(
                    fakedb.BuildsetSourceStamp(id=lastID["buildsetSourceStampid"],
                                               sourcestampid=ss,
                                               buildsetid=lastID["buildsetid"]))
            codebase_ss.clear()
            buildRows.extend([
                fakedb.BuildRequest(id=lastID["buildrequestid"],
                                    buildsetid=lastID["buildsetid"],
                                    builderid=77,
                                    priority=13, submitted_at=1300305712, results=-1),
                fakedb.Build(id=lastID["buildid"],
                             buildrequestid=lastID["buildrequestid"],
                             number=lastID["buildid"],
                             masterid=88,
                             builderid=77,
                             state_string="test",
                             workerid=13,
                             started_at=SOMETIME + lastID["buildid"],
                             complete_at=SOMETIME + 2 * lastID["buildid"],
                             results=results)])
            return buildRows
Exemplo n.º 8
0
 def setUp(self):
     self.setUpEndpoint()
     self.db.insertTestData([
         fakedb.Worker(id=47, name='linux'),
         fakedb.Buildset(id=20),
         fakedb.Builder(id=88, name='b1'),
         fakedb.BuildRequest(id=41, buildsetid=20, builderid=88),
         fakedb.Master(id=88),
         fakedb.Build(id=30,
                      buildrequestid=41,
                      number=7,
                      masterid=88,
                      builderid=88,
                      workerid=47),
         fakedb.Step(id=131, number=132, name='step132', buildid=30),
         fakedb.TestResultSet(id=13,
                              builderid=88,
                              buildid=30,
                              stepid=131,
                              description='desc',
                              category='cat',
                              value_unit='ms',
                              complete=1),
         fakedb.TestResultSet(id=14,
                              builderid=88,
                              buildid=30,
                              stepid=131,
                              description='desc',
                              category='cat',
                              value_unit='ms',
                              complete=1),
     ])
Exemplo n.º 9
0
    def test_getBuildsForChange_OneCodebase(self):
        rows = [fakedb.Master(id=88, name="bar"),
                fakedb.Worker(id=13, name='one'),
                fakedb.Builder(id=77, name='A'),
                fakedb.SourceStamp(id=234, created_at=CREATED_AT,
                                   revision="aaa"),
                fakedb.Change(changeid=14, codebase='A', sourcestampid=234),
                fakedb.Buildset(id=30, reason='foo',
                                submitted_at=1300305712, results=1),
                fakedb.BuildsetSourceStamp(sourcestampid=234, buildsetid=30),
                fakedb.BuildRequest(id=19, buildsetid=30, builderid=77,
                                    priority=13, submitted_at=1300305712, results=1,
                                    complete=0, complete_at=None),
                fakedb.Build(id=50, buildrequestid=19, number=5, masterid=88,
                             builderid=77, state_string="test", workerid=13,
                             started_at=1304262222, results=1), ]

        expected = [{
            'id': 50,
            'number': 5,
            'builderid': 77,
            'buildrequestid': 19,
            'workerid': 13,
            'masterid': 88,
            'started_at': epoch2datetime(1304262222),
            'complete_at': None,
            'state_string': 'test',
            'results': 1}]

        return self.do_test_getBuildsForChange(rows, 14, expected)
Exemplo n.º 10
0
    def test_getSourceStampsForBuild_OneCodeBase(self):
        rows = [fakedb.Master(id=88, name="bar"),
                fakedb.Worker(id=13, name='one'),
                fakedb.Builder(id=77, name='A'),
                fakedb.SourceStamp(id=234, codebase='A', created_at=CREATED_AT,
                                   revision="aaa"),
                # fakedb.Change(changeid=14, codebase='A', sourcestampid=234),
                fakedb.Buildset(id=30, reason='foo',
                                submitted_at=1300305712, results=-1),
                fakedb.BuildsetSourceStamp(sourcestampid=234, buildsetid=30),
                fakedb.BuildRequest(id=19, buildsetid=30, builderid=77,
                                    priority=13, submitted_at=1300305712, results=-1),
                fakedb.Build(id=50, buildrequestid=19, number=5, masterid=88,
                             builderid=77, state_string="test", workerid=13,
                             started_at=1304262222), ]

        expected = [{
            'branch': 'master',
            'codebase': 'A',
            'created_at': epoch2datetime(CREATED_AT),
            'patch_author': None,
            'patch_body': None,
            'patch_comment': None,
            'patch_level': None,
            'patch_subdir': None,
            'patchid': None,
            'project': 'proj',
            'repository': 'repo',
            'revision': 'aaa',
            'ssid': 234}]

        return self.do_test_getSourceStampsForBuild(rows, 50, expected)
Exemplo n.º 11
0
 def make_fake_build(brid, builderid):
     return fakedb.Build(buildrequestid=brid,
                         id=BRID_TO_BID(brid),
                         number=BRID_TO_BUILD_NUMBER(brid),
                         masterid=9,
                         workerid=13,
                         builderid=builderid)
Exemplo n.º 12
0
    def test_multiple_source_stamps_no_props(self):
        repository = 'http://test_repo'
        project = 'test_user/test_project'
        codebase1 = 'test_codebase1'
        codebase2 = 'test_codebase2'
        codebase3 = 'test_codebase3'
        branch2 = 'refs/pull/4192/merge'
        branch3 = 'refs/pull/4193/merge'

        self._http.expect(
            'post',
            '/repos/test_user/test_project/issues/4192/comments',
            json={'body': 'Build done.'})
        self._http.expect(
            'post',
            '/repos/test_user/test_project/issues/4192/comments',
            json={'body': 'Build done.'})
        self._http.expect(
            'post',
            '/repos/test_user/test_project/issues/4192/comments',
            json={'body': 'Build done.'})
        self._http.expect(
            'post',
            '/repos/test_user/test_project/issues/4192/comments',
            json={'body': 'Build done.'})

        # note that the first sourcestamp only has revision, second only branch and only the third
        # has both
        self.master.db.insertTestData([
            fakedb.Master(id=92),
            fakedb.Worker(id=13, name='wrk'),
            fakedb.Builder(id=79, name='Builder0'),
            fakedb.Buildset(id=98, results=SUCCESS, reason="test_reason1"),
            fakedb.BuildsetSourceStamp(buildsetid=98, sourcestampid=234),
            fakedb.BuildsetSourceStamp(buildsetid=98, sourcestampid=235),
            fakedb.BuildsetSourceStamp(buildsetid=98, sourcestampid=236),
            fakedb.SourceStamp(id=234, project=project, branch=None, revision='rev1',
                               repository=repository, codebase=codebase1),
            fakedb.SourceStamp(id=235, project=project, branch=branch2, revision=None,
                               repository=repository, codebase=codebase2),
            fakedb.SourceStamp(id=236, project=project, branch=branch3, revision='rev3',
                               repository=repository, codebase=codebase3),
            fakedb.BuildRequest(id=11, buildsetid=98, builderid=79),
            fakedb.Build(id=20, number=0, builderid=79, buildrequestid=11,
                         workerid=13, masterid=92, results=SUCCESS, state_string="build_text"),
            fakedb.BuildProperty(buildid=20, name="buildername", value="Builder0"),
            fakedb.BuildProperty(buildid=20, name="branch", value=branch2),
        ])

        self.setup_fake_get_changes_for_build(has_change=False)

        build = yield self.master.data.get(("builds", 20))

        build['complete'] = False
        yield self.sp._got_event(('builds', 20, 'new'), build)
        build['complete'] = True
        yield self.sp._got_event(('builds', 20, 'finished'), build)
        build['results'] = SUCCESS
        yield self.sp._got_event(('builds', 20, 'finished'), build)
Exemplo n.º 13
0
 def setUp(self):
     self.setUpEndpoint()
     self.db.insertTestData([
         fakedb.Worker(id=47, name='linux'),
         fakedb.Builder(id=77, name='builder77'),
         fakedb.Master(id=88),
         fakedb.Buildset(id=8822),
         fakedb.BuildRequest(id=82, buildsetid=8822),
         fakedb.Build(id=30,
                      builderid=77,
                      number=7,
                      masterid=88,
                      buildrequestid=82,
                      workerid=47),
         fakedb.Build(id=31,
                      builderid=77,
                      number=8,
                      masterid=88,
                      buildrequestid=82,
                      workerid=47),
         fakedb.Step(id=70,
                     number=0,
                     name='one',
                     buildid=30,
                     started_at=TIME1,
                     complete_at=TIME2,
                     results=0),
         fakedb.Step(id=71,
                     number=1,
                     name='two',
                     buildid=30,
                     started_at=TIME2,
                     complete_at=TIME3,
                     results=2,
                     urls_json='[{"name":"url","url":"http://url"}]'),
         fakedb.Step(id=72,
                     number=2,
                     name='three',
                     buildid=30,
                     started_at=TIME3),
         fakedb.Step(id=73,
                     number=0,
                     name='otherbuild',
                     buildid=31,
                     started_at=TIME2),
     ])
Exemplo n.º 14
0
 def insert_test_data(self):
     self.master.db.insertTestData([
         fakedb.Master(id=92),
         fakedb.Worker(id=13, name='wrk'),
         fakedb.Builder(id=100, name='builder1'),
         fakedb.Builder(id=101, name='builder2'),
         fakedb.Builder(id=102, name='builder3'),
         fakedb.Buildset(id=200, results=None, reason="reason98"),
         fakedb.BuildsetSourceStamp(buildsetid=200, sourcestampid=300),
         fakedb.SourceStamp(id=300,
                            revision='revision1',
                            project='project1',
                            codebase='codebase1',
                            repository='repository1',
                            branch='branch1'),
         fakedb.BuildRequest(id=400, buildsetid=200, builderid=100),
         fakedb.BuildRequestClaim(brid=400, masterid=92, claimed_at=1),
         fakedb.Build(id=500,
                      number=1,
                      builderid=100,
                      buildrequestid=400,
                      workerid=13,
                      masterid=92,
                      results=None,
                      state_string="state1"),
         fakedb.BuildRequest(id=401, buildsetid=200, builderid=101),
         fakedb.BuildRequestClaim(brid=401, masterid=92, claimed_at=1),
         fakedb.Build(id=501,
                      number=1,
                      builderid=101,
                      buildrequestid=401,
                      workerid=13,
                      masterid=92,
                      results=None,
                      state_string="state2"),
         fakedb.BuildRequest(id=402, buildsetid=200, builderid=102),
         fakedb.BuildRequestClaim(brid=402, masterid=92, claimed_at=1),
         fakedb.Build(id=502,
                      number=1,
                      builderid=102,
                      buildrequestid=402,
                      workerid=13,
                      masterid=92,
                      results=None,
                      state_string="state3"),
     ])
Exemplo n.º 15
0
 def setupBuild(self):
     self.master.db.insertTestData([
         fakedb.Build(id=1,
                      masterid=1,
                      workerid=1,
                      builderid=self.BUILDER_IDS[0],
                      buildrequestid=1,
                      number=1),
     ])
Exemplo n.º 16
0
 def setUp(self):
     self.setUpEndpoint()
     self.db.insertTestData([
         fakedb.Worker(id=47, name='linux'),
         fakedb.Buildset(id=20),
         fakedb.Builder(id=88, name='b1'),
         fakedb.Master(id=88),
         fakedb.BuildRequest(id=41, buildsetid=20, builderid=88),
         fakedb.BuildRequest(id=42, buildsetid=20, builderid=88),
         fakedb.BuildRequest(id=43, buildsetid=20, builderid=88),
         fakedb.Build(id=30,
                      buildrequestid=41,
                      number=7,
                      masterid=88,
                      builderid=88,
                      workerid=47),
         fakedb.Build(id=31,
                      buildrequestid=42,
                      number=8,
                      masterid=88,
                      builderid=88,
                      workerid=47),
         fakedb.Build(id=32,
                      buildrequestid=42,
                      number=9,
                      masterid=88,
                      builderid=88,
                      workerid=47),
         fakedb.BuildData(id=91,
                          buildid=30,
                          name='name1',
                          value=b'value1',
                          source='source1'),
         fakedb.BuildData(id=92,
                          buildid=30,
                          name='name2',
                          value=b'value2',
                          source='source2'),
         fakedb.BuildData(id=93,
                          buildid=31,
                          name='name3',
                          value=b'value3',
                          source='source3'),
     ])
Exemplo n.º 17
0
    def test_masterDeactivated(self):
        self.master.db.insertTestData([
            fakedb.Master(id=14, name='other', active=0,
                          last_active=0),

            # set up a running build with some steps
            fakedb.Builder(id=77, name='b1'),
            fakedb.Worker(id=13, name='wrk'),
            fakedb.Buildset(id=8822),
            fakedb.BuildRequest(id=82, builderid=77, buildsetid=8822),
            fakedb.BuildRequestClaim(brid=82, masterid=14,
                                     claimed_at=SOMETIME),
            fakedb.Build(id=13, builderid=77, masterid=14, workerid=13,
                         buildrequestid=82, number=3, results=None),
            fakedb.Step(id=200, buildid=13),
            fakedb.Log(id=2000, stepid=200, num_lines=2),
            fakedb.LogChunk(logid=2000, first_line=1, last_line=2,
                            content='ab\ncd')
        ])

        # mock out the _masterDeactivated methods this will call
        for rtype in 'builder', 'scheduler', 'changesource':
            rtype_obj = getattr(self.master.data.rtypes, rtype)
            m = mock.Mock(name=f'{rtype}._masterDeactivated',
                          spec=rtype_obj._masterDeactivated)
            m.side_effect = lambda masterid: defer.succeed(None)
            rtype_obj._masterDeactivated = m

        # and the update methods..
        for meth in 'finishBuild', 'finishStep', 'finishLog':
            m = mock.create_autospec(getattr(self.master.data.updates, meth))
            m.side_effect = lambda *args, **kwargs: defer.succeed(None)
            setattr(self.master.data.updates, meth, m)

        yield self.rtype._masterDeactivated(14, 'other')

        self.master.data.rtypes.builder._masterDeactivated. \
            assert_called_with(masterid=14)
        self.master.data.rtypes.scheduler._masterDeactivated. \
            assert_called_with(masterid=14)
        self.master.data.rtypes.changesource._masterDeactivated. \
            assert_called_with(masterid=14)

        # see that we finished off that build and its steps and logs
        updates = self.master.data.updates
        updates.finishLog.assert_called_with(logid=2000)
        updates.finishStep.assert_called_with(
            stepid=200, results=RETRY, hidden=False)
        updates.finishBuild.assert_called_with(buildid=13, results=RETRY)

        self.assertEqual(self.master.mq.productions, [
            (('masters', '14', 'stopped'),
             dict(masterid=14, name='other', active=False)),
        ])
Exemplo n.º 18
0
 def insert_test_data(self):
     self.master.db.insertTestData([
         fakedb.Master(id=92),
         fakedb.Worker(id=13, name='wrk'),
         fakedb.Builder(id=79, name='builder1'),
         fakedb.Builder(id=80, name='builder2'),
         fakedb.Buildset(id=98, results=None, reason="reason98"),
         fakedb.BuildsetSourceStamp(buildsetid=98, sourcestampid=234),
         fakedb.SourceStamp(id=234,
                            revision='revision1',
                            project='project1',
                            codebase='codebase1',
                            repository='repository1',
                            branch='branch1'),
         fakedb.BuildRequest(id=10, buildsetid=98, builderid=79),
         fakedb.Build(id=19,
                      number=1,
                      builderid=79,
                      buildrequestid=10,
                      workerid=13,
                      masterid=92,
                      results=None,
                      state_string="state1"),
         fakedb.Buildset(id=99, results=None, reason="reason99"),
         fakedb.BuildsetSourceStamp(buildsetid=99, sourcestampid=235),
         fakedb.SourceStamp(id=235,
                            revision='revision2',
                            project='project2',
                            codebase='codebase2',
                            repository='repository2',
                            branch='branch2'),
         fakedb.BuildRequest(id=11, buildsetid=99, builderid=80),
         fakedb.Build(id=20,
                      number=1,
                      builderid=80,
                      buildrequestid=11,
                      workerid=13,
                      masterid=92,
                      results=None,
                      state_string="state2"),
     ])
Exemplo n.º 19
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)
Exemplo n.º 20
0
 def insertData(self):
     self.db.insertTestData([
         fakedb.SourceStamp(id=13, branch='secret'),
         fakedb.Build(id=15,
                      buildrequestid=16,
                      masterid=1,
                      workerid=2,
                      builderid=21),
         fakedb.BuildRequest(id=16, buildsetid=17),
         fakedb.Buildset(id=17),
         fakedb.BuildsetSourceStamp(id=20, buildsetid=17, sourcestampid=13),
         fakedb.Builder(id=21, name="builder"),
     ])
Exemplo n.º 21
0
 def setUp(self):
     self.setUpEndpoint()
     self.db.insertTestData([
         fakedb.Buildset(id=28),
         fakedb.BuildRequest(id=5, buildsetid=28),
         fakedb.Master(id=3),
         fakedb.Worker(id=42, name="Friday"),
         fakedb.Build(id=786, buildrequestid=5, masterid=3, workerid=42),
         fakedb.BuildProperty(
             buildid=786, name="year", value=1651, source="Wikipedia"),
         fakedb.BuildProperty(
             buildid=786, name="island_name", value="despair", source="Book"),
     ])
Exemplo n.º 22
0
 def setUp(self):
     self.setUpEndpoint()
     self.db.insertTestData([
         fakedb.SourceStamp(id=133),
         fakedb.Change(changeid=13, branch='trunk', revision='9283',
                       repository='svn://...', codebase='cbsvn',
                       project='world-domination', sourcestampid=133),
         fakedb.SourceStamp(id=144),
         fakedb.Change(changeid=14, branch='devel', revision='9284',
                       repository='svn://...', codebase='cbsvn',
                       project='world-domination', sourcestampid=144),
         fakedb.Build(buildrequestid=1, masterid=1, workerid=1, builderid=1),
     ])
Exemplo n.º 23
0
 def setUp(self):
     self.setUpEndpoint()
     self.db.insertTestData([
         fakedb.Builder(id=77, name='builder77'),
         fakedb.Builder(id=78, name='builder78'),
         fakedb.Builder(id=79, name='builder79'),
         fakedb.Master(id=88),
         fakedb.Worker(id=13, name='wrk'),
         fakedb.Buildset(id=8822),
         fakedb.BuildRequest(id=82, buildsetid=8822),
         fakedb.Build(id=13,
                      builderid=77,
                      masterid=88,
                      workerid=13,
                      buildrequestid=82,
                      number=3),
         fakedb.Build(id=14,
                      builderid=77,
                      masterid=88,
                      workerid=13,
                      buildrequestid=82,
                      number=4),
         fakedb.Build(id=15,
                      builderid=78,
                      masterid=88,
                      workerid=12,
                      buildrequestid=83,
                      number=5,
                      complete_at=1),
         fakedb.Build(id=16,
                      builderid=79,
                      masterid=88,
                      workerid=12,
                      buildrequestid=84,
                      number=6,
                      complete_at=1),
     ])
Exemplo n.º 24
0
    def setUp(self):
        self.setup_test_reactor()
        self.master = fakemaster.make_master(self, wantData=True, wantDb=True)
        yield self.master.startService()

        self.master.db.insertTestData([
            fakedb.Worker(id=47, name='linux'),
            fakedb.Buildset(id=20),
            fakedb.Builder(id=88, name='b1'),
            fakedb.BuildRequest(id=41, buildsetid=20, builderid=88),
            fakedb.Master(id=88),
            fakedb.Build(id=30, buildrequestid=41, number=7, masterid=88,
                         builderid=88, workerid=47),
            fakedb.Step(id=131, number=132, name='step132', buildid=30),
        ])
Exemplo n.º 25
0
 def setUp(self):
     self.setUpEndpoint()
     self.db.insertTestData([
         fakedb.Worker(id=47, name='linux'),
         fakedb.Buildset(id=20),
         fakedb.Builder(id=88, name='b1'),
         fakedb.BuildRequest(id=41, buildsetid=20, builderid=88),
         fakedb.Master(id=88),
         fakedb.Build(id=30,
                      buildrequestid=41,
                      number=7,
                      masterid=88,
                      builderid=88,
                      workerid=47),
         fakedb.Step(id=131, number=132, name='step132', buildid=30),
         fakedb.TestResultSet(id=13,
                              builderid=88,
                              buildid=30,
                              stepid=131,
                              description='desc',
                              category='cat',
                              value_unit='ms',
                              complete=1),
         fakedb.TestName(id=301, builderid=88, name='name301'),
         fakedb.TestName(id=302, builderid=88, name='name302'),
         fakedb.TestCodePath(id=401, builderid=88, path='path401'),
         fakedb.TestCodePath(id=402, builderid=88, path='path402'),
         fakedb.TestResult(id=101,
                           builderid=88,
                           test_result_setid=13,
                           line=400,
                           value='v101'),
         fakedb.TestResult(id=102,
                           builderid=88,
                           test_result_setid=13,
                           test_nameid=301,
                           test_code_pathid=401,
                           line=401,
                           value='v102'),
         fakedb.TestResult(id=103,
                           builderid=88,
                           test_result_setid=13,
                           test_nameid=302,
                           test_code_pathid=402,
                           line=402,
                           duration_ns=1012,
                           value='v103'),
     ])
Exemplo n.º 26
0
 def test_addBuild_existing(self):
     self.reactor.advance(TIME1)
     yield self.insertTestData(self.backgroundData + [
         fakedb.Build(number=10, buildrequestid=41, builderid=77,
                      masterid=88, workerid=13),
     ])
     id, number = yield self.db.builds.addBuild(builderid=77,
                                                buildrequestid=41,
                                                workerid=13, masterid=88,
                                                state_string='test test2')
     bdict = yield self.db.builds.getBuild(id)
     validation.verifyDbDict(self, 'dbbuilddict', bdict)
     self.assertEqual(number, 11)
     self.assertEqual(bdict, {'buildrequestid': 41, 'builderid': 77,
                              'id': id, 'masterid': 88, 'number': number, 'workerid': 13,
                              'started_at': epoch2datetime(TIME1),
                              'complete_at': None, 'state_string': 'test test2',
                              'results': None})
Exemplo n.º 27
0
    def test_setBuildProperties(self):
        self.master.db.insertTestData([
            fakedb.Buildset(id=28),
            fakedb.BuildRequest(id=5, buildsetid=28),
            fakedb.Master(id=3),
            fakedb.Worker(id=42, name="Friday"),
            fakedb.Build(id=1234, buildrequestid=5, masterid=3, workerid=42),
        ])

        self.master.db.builds.setBuildProperty = mock.Mock(
            wraps=self.master.db.builds.setBuildProperty)
        props = processProperties.fromDict(
            dict(a=(1, 't'), b=(['abc', 9], 't')))
        yield self.rtype.setBuildProperties(1234, props)
        setBuildPropertiesCalls = sorted(
            self.master.db.builds.setBuildProperty.mock_calls)
        self.assertEqual(setBuildPropertiesCalls, [
            mock.call(1234, 'a', 1, 't'),
            mock.call(1234, 'b', ['abc', 9], 't')
        ])
        self.master.mq.assertProductions([
            (('builds', '1234', 'properties', 'update'), {
                'a': (1, 't'),
                'b': (['abc', 9], 't')
            }),
        ])
        # sync without changes: no db write
        self.master.db.builds.setBuildProperty.reset_mock()
        self.master.mq.clearProductions()
        yield self.rtype.setBuildProperties(1234, props)
        self.master.db.builds.setBuildProperty.assert_not_called()
        self.master.mq.assertProductions([])

        # sync with one changes: one db write
        props.setProperty('b', 2, 'step')
        self.master.db.builds.setBuildProperty.reset_mock()
        yield self.rtype.setBuildProperties(1234, props)

        self.master.db.builds.setBuildProperty.assert_called_with(
            1234, 'b', 2, 'step')
        self.master.mq.assertProductions([(('builds', '1234', 'properties',
                                            'update'), {
                                                'b': (2, 'step')
                                            })])
Exemplo n.º 28
0
 def setUp(self):
     self.setUpEndpoint()
     self.db.insertTestData([
         fakedb.Builder(id=77, name='builder77'),
         fakedb.Master(id=88),
         fakedb.Worker(id=13, name='wrk'),
         fakedb.Buildset(id=8822),
         fakedb.BuildRequest(id=82, buildsetid=8822),
         fakedb.Build(id=13,
                      builderid=77,
                      masterid=88,
                      workerid=13,
                      buildrequestid=82,
                      number=3),
         fakedb.Step(id=50, buildid=13, number=5, name='make'),
         fakedb.Log(id=60, stepid=50, name='stdio', slug='stdio', type='s'),
         fakedb.Log(id=61,
                    stepid=50,
                    name='errors',
                    slug='errors',
                    type='t'),
     ])
Exemplo n.º 29
0
 def setUp(self):
     self.setUpEndpoint()
     self.db.insertTestData([
         fakedb.Builder(id=77),
         fakedb.Master(id=88),
         fakedb.Worker(id=13, name='wrk'),
         fakedb.Buildset(id=8822),
         fakedb.BuildRequest(id=82, buildsetid=8822),
         fakedb.Build(id=13,
                      builderid=77,
                      masterid=88,
                      workerid=13,
                      buildrequestid=82,
                      number=3),
         fakedb.Step(id=50, buildid=13, number=9, name='make'),
         fakedb.Log(id=60, stepid=50, name='stdio', type='s'),
         fakedb.Log(id=61, stepid=50, name='errors', type='t'),
         fakedb.Step(id=51, buildid=13, number=10, name='make_install'),
         fakedb.Log(id=70, stepid=51, name='stdio', type='s'),
         fakedb.Log(id=71, stepid=51, name='results_html', type='h'),
         fakedb.Step(id=52, buildid=13, number=11, name='nothing'),
     ])
Exemplo n.º 30
0
 def setUp(self):
     self.setUpEndpoint()
     self.db.insertTestData([
         fakedb.Builder(id=77),
         fakedb.Worker(id=13, name='wrk'),
         fakedb.Master(id=88),
         fakedb.Buildset(id=8822),
         fakedb.BuildRequest(id=82, buildsetid=8822),
         fakedb.Build(id=13, builderid=77, masterid=88, workerid=13,
                      buildrequestid=82, number=3),
         fakedb.Step(id=50, buildid=13, number=9, name='make'),
         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=textwrap.dedent("""\
                     line zero
                     line 1""")),
         fakedb.LogChunk(logid=60, first_line=2, last_line=4, compressed=0,
                         content=textwrap.dedent("""\
                     line TWO
                     line 3
                     line 2**2""")),
         fakedb.LogChunk(logid=60, first_line=5, last_line=5, compressed=0,
                         content="another line"),
         fakedb.LogChunk(logid=60, first_line=6, last_line=6, compressed=0,
                         content="yet another line"),
         fakedb.Log(id=61, stepid=50, name='errors', slug='errors',
                    type='t', num_lines=100),
     ] + [
         fakedb.LogChunk(logid=61, first_line=i, last_line=i, compressed=0,
                         content=f"{i:08d}")
         for i in range(100)
     ] + [
         fakedb.Log(id=62, stepid=50, name='notes', slug='notes', type='t',
                    num_lines=0),
         # logid 62 is empty
     ])