Exemplo n.º 1
0
    def test_reconfigService_manhole(self):
        master = fakemaster.make_master(self)
        ds = debug.DebugServices()
        yield ds.setServiceParent(master)
        yield master.startService()

        # start off with no manhole
        yield ds.reconfigServiceWithBuildbotConfig(self.config)

        # set a manhole, fire it up
        self.config.manhole = manhole = FakeManhole()
        yield ds.reconfigServiceWithBuildbotConfig(self.config)

        self.assertTrue(manhole.running)
        self.assertIdentical(manhole.master, master)

        # unset it, see it stop
        self.config.manhole = None
        yield ds.reconfigServiceWithBuildbotConfig(self.config)

        self.assertFalse(manhole.running)
        self.assertIdentical(manhole.master, None)

        # re-start to test stopService
        self.config.manhole = manhole
        yield ds.reconfigServiceWithBuildbotConfig(self.config)

        # disown the service, and see that it unregisters
        yield ds.disownServiceParent()

        self.assertFalse(manhole.running)
        self.assertIdentical(manhole.master, None)
Exemplo n.º 2
0
    def create_child_services(self):
        # note that these are order-dependent.  If you get the order wrong,
        # you'll know it, as the master will fail to start.

        self.metrics = metrics.MetricLogObserver()
        self.metrics.setServiceParent(self)

        self.caches = cache.CacheManager()
        self.caches.setServiceParent(self)

        self.pbmanager = buildbot.pbmanager.PBManager()
        self.pbmanager.setServiceParent(self)

        self.change_svc = ChangeManager(self)
        self.change_svc.setServiceParent(self)

        self.botmaster = BotMaster(self)
        self.botmaster.setServiceParent(self)

        self.scheduler_manager = SchedulerManager(self)
        self.scheduler_manager.setServiceParent(self)

        self.user_manager = UserManagerManager(self)
        self.user_manager.setServiceParent(self)

        self.db = connector.DBConnector(self, self.basedir)
        self.db.setServiceParent(self)

        self.debug = debug.DebugServices(self)
        self.debug.setServiceParent(self)

        self.status = Status(self)
        self.status.setServiceParent(self)
Exemplo n.º 3
0
    def test_reconfigService_manhole(self):
        master = mock.Mock(name='master')
        ds = debug.DebugServices(master)
        ds.startService()

        # start off with no manhole
        yield ds.reconfigServiceWithBuildbotConfig(self.config)

        # set a manhole, fire it up
        self.config.manhole = manhole = FakeManhole()
        yield ds.reconfigServiceWithBuildbotConfig(self.config)

        self.assertTrue(manhole.running)
        self.assertIdentical(manhole.master, master)

        # unset it, see it stop
        self.config.manhole = None
        yield ds.reconfigServiceWithBuildbotConfig(self.config)

        self.assertFalse(manhole.running)
        self.assertIdentical(manhole.master, None)

        # re-start to test stopService
        self.config.manhole = manhole
        yield ds.reconfigServiceWithBuildbotConfig(self.config)

        # stop the service, and see that it unregisters
        yield ds.stopService()

        self.assertFalse(manhole.running)
        self.assertIdentical(manhole.master, None)
Exemplo n.º 4
0
    def create_child_services(self):
        # note that these are order-dependent.  If you get the order wrong,
        # you'll know it, as the master will fail to start.

        self.metrics = metrics.MetricLogObserver()
        self.metrics.setServiceParent(self)

        self.caches = cache.CacheManager()
        self.caches.setServiceParent(self)

        self.pbmanager = buildbot.pbmanager.PBManager()
        self.pbmanager.setServiceParent(self)

        self.buildslaves = bslavemanager.BuildslaveManager(self)
        self.buildslaves.setServiceParent(self)

        self.change_svc = ChangeManager(self)
        self.change_svc.setServiceParent(self)

        self.botmaster = BotMaster(self)
        self.botmaster.setServiceParent(self)

        self.scheduler_manager = SchedulerManager(self)
        self.scheduler_manager.setServiceParent(self)

        self.user_manager = UserManagerManager(self)
        self.user_manager.setServiceParent(self)

        self.db = dbconnector.DBConnector(self, self.basedir)
        self.db.setServiceParent(self)

        self.mq = mqconnector.MQConnector(self)
        self.mq.setServiceParent(self)

        self.data = dataconnector.DataConnector(self)
        self.data.setServiceParent(self)

        self.www = wwwservice.WWWService(self)
        self.www.setServiceParent(self)

        self.debug = debug.DebugServices(self)
        self.debug.setServiceParent(self)

        self.status = Status(self)
        self.status.setServiceParent(self)

        self.masterHouskeepingTimer = 0

        @defer.inlineCallbacks
        def heartbeat():
            if self.masterid is not None:
                yield self.data.updates.masterActive(name=self.name,
                                                     masterid=self.masterid)
            # force housekeeping once a day
            yield self.data.updates.expireMasters(
                (self.masterHouskeepingTimer % (24 * 60)) == 0)
            self.masterHouskeepingTimer += 1

        self.masterHeartbeatService = internet.TimerService(60, heartbeat)
        self.masterHeartbeatService.setServiceParent(self)
Exemplo n.º 5
0
    def test_reconfigService_debug(self):
        # mock out PBManager
        self.master.pbmanager = pbmanager = mock.Mock()
        registration = mock.Mock(name='registration')
        registration.unregister = mock.Mock(
            name='unregister', side_effect=lambda: defer.succeed(None))
        pbmanager.register.return_value = registration

        ds = debug.DebugServices(self.master)
        ds.startService()

        # start off with no debug password
        self.config.protocols = {'pb': {'port': '9824'}}
        self.config.debugPassword = None
        yield ds.reconfigService(self.config)

        self.assertFalse(pbmanager.register.called)

        # set the password, and see it register
        self.config.debugPassword = '******'
        yield ds.reconfigService(self.config)

        self.assertTrue(pbmanager.register.called)
        self.assertEqual(pbmanager.register.call_args[0][:3],
                         ('9824', 'debug', 'seeeekrit'))
        factory = pbmanager.register.call_args[0][3]
        self.assertIsInstance(factory(mock.Mock(), mock.Mock()),
                              debug.DebugPerspective)

        # change the password, and see it re-register
        self.config.debugPassword = '******'
        pbmanager.register.reset_mock()
        yield ds.reconfigService(self.config)

        self.assertTrue(registration.unregister.called)
        self.assertTrue(pbmanager.register.called)
        self.assertEqual(pbmanager.register.call_args[0][:3],
                         ('9824', 'debug', 'lies'))

        # remove the password, and see it unregister
        self.config.debugPassword = None
        pbmanager.register.reset_mock()
        registration.unregister.reset_mock()
        yield ds.reconfigService(self.config)

        self.assertTrue(registration.unregister.called)
        self.assertFalse(pbmanager.register.called)

        # re-register to test stopService
        self.config.debugPassword = '******'
        pbmanager.register.reset_mock()
        yield ds.reconfigService(self.config)

        # stop the service, and see that it unregisters
        pbmanager.register.reset_mock()
        registration.unregister.reset_mock()
        yield ds.stopService()

        self.assertTrue(registration.unregister.called)
    def test_reconfigService_manhole(self):
        master = mock.Mock(name='master')
        ds = debug.DebugServices(master)
        ds.startService()

        # start off with no manhole
        wfd = defer.waitForDeferred(ds.reconfigService(self.config))
        yield wfd
        wfd.getResult()

        # set a manhole, fire it up
        self.config.manhole = manhole = FakeManhole()
        wfd = defer.waitForDeferred(ds.reconfigService(self.config))
        yield wfd
        wfd.getResult()

        self.assertTrue(manhole.running)
        self.assertIdentical(manhole.master, master)

        # unset it, see it stop
        self.config.manhole = None
        wfd = defer.waitForDeferred(ds.reconfigService(self.config))
        yield wfd
        wfd.getResult()

        self.assertFalse(manhole.running)
        self.assertIdentical(manhole.master, None)

        # re-start to test stopService
        self.config.manhole = manhole
        wfd = defer.waitForDeferred(ds.reconfigService(self.config))
        yield wfd
        wfd.getResult()

        # stop the service, and see that it unregisters
        wfd = defer.waitForDeferred(ds.stopService())
        yield wfd
        wfd.getResult()

        self.assertFalse(manhole.running)
        self.assertIdentical(manhole.master, None)
Exemplo n.º 7
0
    def create_child_services(self):
        # note that these are order-dependent.  If you get the order wrong,
        # you'll know it, as the master will fail to start.

        self.metrics = metrics.MetricLogObserver()
        self.metrics.setServiceParent(self)

        self.caches = cache.CacheManager()
        self.caches.setServiceParent(self)

        self.pbmanager = buildbot.pbmanager.PBManager()
        self.pbmanager.setServiceParent(self)

        self.workers = workermanager.WorkerManager(self)
        self.workers.setServiceParent(self)

        self.change_svc = ChangeManager()
        self.change_svc.setServiceParent(self)

        self.botmaster = BotMaster()
        self.botmaster.setServiceParent(self)

        self.scheduler_manager = SchedulerManager()
        self.scheduler_manager.setServiceParent(self)

        self.user_manager = UserManagerManager(self)
        self.user_manager.setServiceParent(self)

        self.db = dbconnector.DBConnector(self.basedir)
        self.db.setServiceParent(self)

        self.wamp = wampconnector.WampConnector()
        self.wamp.setServiceParent(self)

        self.mq = mqconnector.MQConnector()
        self.mq.setServiceParent(self)

        self.data = dataconnector.DataConnector()
        self.data.setServiceParent(self)

        self.www = wwwservice.WWWService()
        self.www.setServiceParent(self)

        self.debug = debug.DebugServices()
        self.debug.setServiceParent(self)

        self.status = Status()
        self.status.setServiceParent(self)

        self.secrets_manager = SecretManager()
        self.secrets_manager.setServiceParent(self)
        self.secrets_manager.reconfig_priority = 2000

        self.service_manager = service.BuildbotServiceManager()
        self.service_manager.setServiceParent(self)
        self.service_manager.reconfig_priority = 1000

        self.masterHouskeepingTimer = 0

        @defer.inlineCallbacks
        def heartbeat():
            if self.masterid is not None:
                yield self.data.updates.masterActive(name=self.name,
                                                     masterid=self.masterid)
            yield self.data.updates.expireMasters()

        self.masterHeartbeatService = internet.TimerService(60, heartbeat)
        self.masterHeartbeatService.clock = self.reactor