Exemplo n.º 1
0
 def test_getBuilders_masterid(self):
     yield self.insertTestData([
         fakedb.Builder(id=7, name='some:builder'),
         fakedb.Builder(id=8, name='other:builder'),
         fakedb.Builder(id=9, name='third:builder'),
         fakedb.Master(id=3, name='m1'),
         fakedb.Master(id=4, name='m2'),
         fakedb.BuilderMaster(builderid=7, masterid=3),
         fakedb.BuilderMaster(builderid=8, masterid=3),
         fakedb.BuilderMaster(builderid=8, masterid=4),
     ])
     builderlist = yield self.db.builders.getBuilders(masterid=3)
     for builderdict in builderlist:
         validation.verifyDbDict(self, 'builderdict', builderdict)
     self.assertEqual(
         sorted(builderlist, key=builderKey),
         sorted([
             dict(id=7,
                  name='some:builder',
                  masterids=[3],
                  tags=[],
                  description=None),
             dict(id=8,
                  name='other:builder',
                  masterids=[3, 4],
                  tags=[],
                  description=None),
         ],
                key=builderKey))
Exemplo n.º 2
0
    def test_masterActive(self):
        self.reactor.advance(60)

        self.master.db.insertTestData([
            fakedb.Master(id=13, name='myname', active=0,
                          last_active=0),
            fakedb.Master(id=14, name='other', active=1,
                          last_active=0),
            fakedb.Master(id=15, name='other2', active=1,
                          last_active=0),
        ])

        # initial checkin
        yield self.rtype.masterActive(name='myname', masterid=13)
        master = yield self.master.db.masters.getMaster(13)
        self.assertEqual(master, dict(id=13, name='myname',
                                      active=True, last_active=epoch2datetime(60)))
        self.assertEqual(self.master.mq.productions, [
            (('masters', '13', 'started'),
             dict(masterid=13, name='myname', active=True)),
        ])
        self.master.mq.productions = []

        # updated checkin time, re-activation
        self.reactor.advance(60)
        yield self.master.db.masters.markMasterInactive(13)
        yield self.rtype.masterActive('myname', masterid=13)
        master = yield self.master.db.masters.getMaster(13)
        self.assertEqual(master, dict(id=13, name='myname',
                                      active=True, last_active=epoch2datetime(120)))
        self.assertEqual(self.master.mq.productions, [
            (('masters', '13', 'started'),
             dict(masterid=13, name='myname', active=True)),
        ])
        self.master.mq.productions = []
Exemplo n.º 3
0
    def test_getMasters(self):
        yield self.insertTestData([
            fakedb.Master(id=7,
                          name='some:master',
                          active=0,
                          last_active=SOMETIME),
            fakedb.Master(id=8,
                          name='other:master',
                          active=1,
                          last_active=OTHERTIME),
        ])
        masterlist = yield self.db.masters.getMasters()
        for masterdict in masterlist:
            validation.verifyDbDict(self, 'masterdict', masterdict)

        def masterKey(master):
            return master['id']

        expected = sorted([
            dict(id=7, name='some:master', active=0, last_active=SOMETIME_DT),
            dict(id=8, name='other:master', active=1,
                 last_active=OTHERTIME_DT),
        ],
                          key=masterKey)
        self.assertEqual(sorted(masterlist, key=masterKey), expected)
Exemplo n.º 4
0
 def setUp(self):
     self.setUpTestReactor()
     self.master = fakemaster.make_master(self, wantMq=True, wantDb=True,
                                          wantData=True)
     self.rtype = workers.Worker(self.master)
     return self.master.db.insertTestData([
         fakedb.Master(id=13),
         fakedb.Master(id=14),
     ])
Exemplo n.º 5
0
 def setUp(self):
     self.setup_test_reactor()
     self.master = fakemaster.make_master(self, wantMq=True, wantDb=True,
                                          wantData=True)
     self.rtype = builders.Builder(self.master)
     return self.master.db.insertTestData([
         fakedb.Master(id=13),
         fakedb.Master(id=14),
     ])
Exemplo n.º 6
0
 def setUp(self):
     self.setUpEndpoint()
     self.master.name = "myname"
     self.db.insertTestData([
         fakedb.Master(id=13, name='some:master', active=False,
                       last_active=SOMETIME),
         fakedb.Master(id=14, name='other:master', active=True,
                       last_active=OTHERTIME),
         fakedb.Builder(id=22),
         fakedb.BuilderMaster(masterid=13, builderid=22),
     ])
Exemplo n.º 7
0
 def setUp(self):
     self.setUpEndpoint()
     self.db.insertTestData([
         fakedb.Master(id=22, active=0),
         fakedb.Master(id=33, active=1),
         fakedb.Scheduler(id=13, name='some:scheduler'),
         fakedb.SchedulerMaster(schedulerid=13, masterid=None),
         fakedb.Scheduler(id=14, name='other:scheduler'),
         fakedb.SchedulerMaster(schedulerid=14, masterid=22),
         fakedb.Scheduler(id=15, name='another:scheduler'),
         fakedb.SchedulerMaster(schedulerid=15, masterid=33),
     ])
Exemplo n.º 8
0
 def setUp(self):
     self.setUpEndpoint()
     self.master.name = "myname"
     self.db.insertTestData([
         fakedb.Master(id=13, name='some:master', active=False,
                       last_active=SOMETIME),
         fakedb.Master(id=14, name='other:master', active=False,
                       last_active=SOMETIME),
         fakedb.Builder(id=23, name='bldr1'),
         fakedb.BuilderMaster(builderid=23, masterid=13),
         fakedb.Builder(id=24, name='bldr2'),
     ])
Exemplo n.º 9
0
 def test_addBuilderMaster_already_present(self):
     yield self.insertTestData([
         fakedb.Builder(id=7),
         fakedb.Master(id=9, name='abc'),
         fakedb.Master(id=10, name='def'),
         fakedb.BuilderMaster(builderid=7, masterid=9),
     ])
     yield self.db.builders.addBuilderMaster(builderid=7, masterid=9)
     builderdict = yield self.db.builders.getBuilder(7)
     validation.verifyDbDict(self, 'builderdict', builderdict)
     self.assertEqual(builderdict,
                      dict(id=7, name='some:builder', tags=[],
                           masterids=[9], description=None))
Exemplo n.º 10
0
 def test_getBuilder_with_masters(self):
     yield self.insertTestData([
         fakedb.Builder(id=7, name='some:builder'),
         fakedb.Master(id=3, name='m1'),
         fakedb.Master(id=4, name='m2'),
         fakedb.BuilderMaster(builderid=7, masterid=3),
         fakedb.BuilderMaster(builderid=7, masterid=4),
     ])
     builderdict = yield self.db.builders.getBuilder(7)
     validation.verifyDbDict(self, 'builderdict', builderdict)
     self.assertEqual(builderdict,
                      dict(id=7, name='some:builder', tags=[],
                           masterids=[3, 4], description=None))
Exemplo n.º 11
0
    def setUp(self):
        self.setUpEndpoint()

        self.db.insertTestData([
            fakedb.Master(id=22, active=0),
            fakedb.Master(id=33, active=1),
            fakedb.ChangeSource(id=13, name='some:changesource'),
            fakedb.ChangeSourceMaster(changesourceid=13, masterid=None),
            fakedb.ChangeSource(id=14, name='other:changesource'),
            fakedb.ChangeSourceMaster(changesourceid=14, masterid=22),
            fakedb.ChangeSource(id=15, name='another:changesource'),
            fakedb.ChangeSourceMaster(changesourceid=15, masterid=33),
        ])
Exemplo n.º 12
0
 def test_removeBuilderMaster(self):
     yield self.insertTestData([
         fakedb.Builder(id=7),
         fakedb.Master(id=9, name='some:master'),
         fakedb.Master(id=10, name='other:master'),
         fakedb.BuilderMaster(builderid=7, masterid=9),
         fakedb.BuilderMaster(builderid=7, masterid=10),
     ])
     yield self.db.builders.removeBuilderMaster(builderid=7, masterid=9)
     builderdict = yield self.db.builders.getBuilder(7)
     validation.verifyDbDict(self, 'builderdict', builderdict)
     self.assertEqual(builderdict,
                      dict(id=7, name='some:builder', tags=[],
                           masterids=[10], description=None))
Exemplo n.º 13
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.º 14
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.º 15
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.º 16
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
Exemplo n.º 17
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.º 18
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.º 19
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.º 20
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.º 21
0
 def test_schedulerEnable(self):
     SOMETIME = 1348971992
     yield self.master.db.insertTestData([
         fakedb.Master(id=22, active=0, last_active=SOMETIME),
         fakedb.Scheduler(id=13, name='some:scheduler'),
         fakedb.SchedulerMaster(schedulerid=13, masterid=22),
     ])
     yield self.rtype.schedulerEnable(13, False)
     self.master.mq.assertProductions(
         [(('schedulers', '13', 'updated'),
           {'enabled': False,
            'master': {'active': False,
                       'last_active': epoch2datetime(SOMETIME),
                       'masterid': 22,
                       'name': 'some:master'},
            'name': 'some:scheduler',
            'schedulerid': 13})])
     yield self.rtype.schedulerEnable(13, True)
     self.master.mq.assertProductions(
         [(('schedulers', '13', 'updated'),
           {'enabled': True,
            'master': {'active': False,
                       'last_active': epoch2datetime(SOMETIME),
                       'masterid': 22,
                       'name': 'some:master'},
            'name': 'some:scheduler',
            'schedulerid': 13})])
Exemplo n.º 22
0
    def test_masters(self):
        yield self.insertTestData([
            fakedb.Master(id=7,
                          name='some:master',
                          active=0,
                          last_active=SOMETIME),
            fakedb.Master(id=8,
                          name='other:master',
                          active=1,
                          last_active=OTHERTIME),
        ])

        res = yield self.apiGet(self.link(b'masters'))
        self.assertEqual(
            res, {
                'masters': [
                    {
                        'active': False,
                        'masterid': 7,
                        'name': 'some:master',
                        'last_active': SOMETIME
                    },
                    {
                        'active': True,
                        'masterid': 8,
                        'name': 'other:master',
                        'last_active': OTHERTIME
                    },
                ],
                'meta': {
                    'total': 2,
                }
            })

        res = yield self.apiGet(self.link(b'masters/7'))
        self.assertEqual(
            res, {
                'masters': [
                    {
                        'active': False,
                        'masterid': 7,
                        'name': 'some:master',
                        'last_active': SOMETIME
                    },
                ],
                'meta': {}
            })
Exemplo n.º 23
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.º 24
0
 def setUp(self):
     self.setUpEndpoint()
     return self.db.insertTestData([
         fakedb.Builder(id=1, name='buildera'),
         fakedb.Builder(id=2, name='builderb'),
         fakedb.Master(id=13),
         fakedb.BuilderMaster(id=1, builderid=2, masterid=13),
     ])
Exemplo n.º 25
0
    def setUpTests(self):
        # set up a sourcestamp and buildset for use below
        self.MASTER_ID = fakedb.FakeBuildRequestsComponent.MASTER_ID
        self.OTHER_MASTER_ID = self.MASTER_ID + 1111
        self.db.master.masterid = self.MASTER_ID

        return self.insertTestData([
            fakedb.SourceStamp(id=234),
            fakedb.Master(id=self.MASTER_ID, name="fake master"),
            fakedb.Master(id=self.OTHER_MASTER_ID, name="other"),
            fakedb.Buildset(id=self.BSID),
            fakedb.Builder(id=self.BLDRID1, name="builder1"),
            fakedb.Builder(id=self.BLDRID2, name="builder2"),
            fakedb.Builder(id=self.BLDRID3, name="builder3"),
            fakedb.BuildsetSourceStamp(buildsetid=self.BSID,
                                       sourcestampid=234),
        ])
Exemplo n.º 26
0
    def test_masterStopped_already(self):
        self.reactor.advance(60)

        self.master.db.insertTestData([
            fakedb.Master(id=13, name='aname', active=0, last_active=0),
        ])

        self.rtype._masterDeactivated = mock.Mock()
        yield self.rtype.masterStopped(name='aname', masterid=13)
        self.rtype._masterDeactivated.assert_not_called()
Exemplo n.º 27
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.º 28
0
 def test__masterDeactivated(self):
     yield self.master.db.insertTestData([
         fakedb.Master(id=22, active=0),
         fakedb.ChangeSource(id=13, name='some:changesource'),
         fakedb.ChangeSourceMaster(changesourceid=13, masterid=22),
         fakedb.ChangeSource(id=14, name='other:changesource'),
         fakedb.ChangeSourceMaster(changesourceid=14, masterid=22),
     ])
     yield self.rtype._masterDeactivated(22)
     self.master.db.changesources.assertChangeSourceMaster(13, None)
     self.master.db.changesources.assertChangeSourceMaster(14, None)
Exemplo n.º 29
0
 def test__masterDeactivated(self):
     yield self.master.db.insertTestData([
         fakedb.Master(id=22, active=0),
         fakedb.Scheduler(id=13, name='some:scheduler'),
         fakedb.SchedulerMaster(schedulerid=13, masterid=22),
         fakedb.Scheduler(id=14, name='other:scheduler'),
         fakedb.SchedulerMaster(schedulerid=14, masterid=22),
     ])
     yield self.rtype._masterDeactivated(22)
     self.master.db.schedulers.assertSchedulerMaster(13, None)
     self.master.db.schedulers.assertSchedulerMaster(14, None)
Exemplo n.º 30
0
    def test_masterStopped(self):
        self.reactor.advance(60)

        self.master.db.insertTestData([
            fakedb.Master(id=13, name='aname', active=1,
                          last_active=self.reactor.seconds()),
        ])

        self.rtype._masterDeactivated = mock.Mock()
        yield self.rtype.masterStopped(name='aname', masterid=13)
        self.rtype._masterDeactivated. \
            assert_called_with(13, 'aname')