def setServiceParent(self, p): yield super().setServiceParent(p) self.model = model.Model(self) self.changes = changes.ChangesConnectorComponent(self) self.changesources = changesources.ChangeSourcesConnectorComponent( self) self.schedulers = schedulers.SchedulersConnectorComponent(self) self.sourcestamps = sourcestamps.SourceStampsConnectorComponent(self) self.buildsets = buildsets.BuildsetsConnectorComponent(self) self.buildrequests = buildrequests.BuildRequestsConnectorComponent( self) self.state = state.StateConnectorComponent(self) self.builds = builds.BuildsConnectorComponent(self) self.workers = workers.WorkersConnectorComponent(self) self.users = users.UsersConnectorComponent(self) self.masters = masters.MastersConnectorComponent(self) self.builders = builders.BuildersConnectorComponent(self) self.steps = steps.StepsConnectorComponent(self) self.tags = tags.TagsConnectorComponent(self) self.logs = logs.LogsConnectorComponent(self) self.cleanup_timer = internet.TimerService(self.CLEANUP_PERIOD, self._doCleanup) self.cleanup_timer.clock = self.master.reactor yield self.cleanup_timer.setServiceParent(self)
def setServiceParent(self, p): d = service.AsyncMultiService.setServiceParent(self, p) self.model = model.Model(self) self.changes = changes.ChangesConnectorComponent(self) self.changesources = changesources.ChangeSourcesConnectorComponent( self) self.schedulers = schedulers.SchedulersConnectorComponent(self) self.sourcestamps = sourcestamps.SourceStampsConnectorComponent(self) self.buildsets = buildsets.BuildsetsConnectorComponent(self) self.buildrequests = buildrequests.BuildRequestsConnectorComponent( self) self.state = state.StateConnectorComponent(self) self.builds = builds.BuildsConnectorComponent(self) self.workers = workers.WorkersConnectorComponent(self) self._registerOldWorkerAttr("workers", name="buildslaves") self.users = users.UsersConnectorComponent(self) self.masters = masters.MastersConnectorComponent(self) self.builders = builders.BuildersConnectorComponent(self) self.steps = steps.StepsConnectorComponent(self) self.tags = tags.TagsConnectorComponent(self) self.logs = logs.LogsConnectorComponent(self) self.cleanup_timer = internet.TimerService(self.CLEANUP_PERIOD, self._doCleanup) self.cleanup_timer.clock = self.master.reactor self.cleanup_timer.setServiceParent(self) return d
def __init__(self, master, db_url, basedir): service.MultiService.__init__(self) self.master = master self.basedir = basedir self._engine = enginestrategy.create_engine(db_url, basedir=self.basedir) self.pool = pool.DBThreadPool(self._engine) # set up components self.model = model.Model(self) self.changes = changes.ChangesConnectorComponent(self) self.schedulers = schedulers.SchedulersConnectorComponent(self) self.sourcestamps = sourcestamps.SourceStampsConnectorComponent(self) self.buildsets = buildsets.BuildsetsConnectorComponent(self) self.buildrequests = buildrequests.BuildRequestsConnectorComponent( self) self.state = state.StateConnectorComponent(self) self.builds = builds.BuildsConnectorComponent(self) self.cleanup_timer = internet.TimerService(self.CLEANUP_PERIOD, self.doCleanup) self.cleanup_timer.setServiceParent(self) self.changeHorizon = None # default value; set by master
def __init__(self, master, basedir): service.MultiService.__init__(self) self.setName('db') self.master = master self.basedir = basedir # not configured yet - we don't build an engine until the first # reconfig self.configured_url = None # set up components self._engine = None # set up in reconfigService self.pool = None # set up in reconfigService self.cleanup_timer = None self.model = model.Model(self) self.changes = changes.ChangesConnectorComponent(self) self.schedulers = schedulers.SchedulersConnectorComponent(self) self.sourcestamps = sourcestamps.SourceStampsConnectorComponent(self) self.sourcestampsets = sourcestampsets.SourceStampSetsConnectorComponent(self) self.buildsets = buildsets.BuildsetsConnectorComponent(self) self.buildrequests = buildrequests.BuildRequestsConnectorComponent(self) self.state = state.StateConnectorComponent(self) self.builds = builds.BuildsConnectorComponent(self) self.users = users.UsersConnectorComponent(self) self.mastersconfig = mastersconfig.MastersConfigConnectorComponent(self)
def __init__(self, master, basedir): service.AsyncMultiService.__init__(self) self.setName('db') self.master = master self.basedir = basedir # not configured yet - we don't build an engine until the first # reconfig self.configured_url = None # set up components self._engine = None # set up in reconfigService self.pool = None # set up in reconfigService self.model = model.Model(self) self.changes = changes.ChangesConnectorComponent(self) self.changesources = changesources.ChangeSourcesConnectorComponent( self) self.schedulers = schedulers.SchedulersConnectorComponent(self) self.sourcestamps = sourcestamps.SourceStampsConnectorComponent(self) self.buildsets = buildsets.BuildsetsConnectorComponent(self) self.buildrequests = buildrequests.BuildRequestsConnectorComponent( self) self.state = state.StateConnectorComponent(self) self.builds = builds.BuildsConnectorComponent(self) self.buildslaves = buildslaves.BuildslavesConnectorComponent(self) self.users = users.UsersConnectorComponent(self) self.masters = masters.MastersConnectorComponent(self) self.builders = builders.BuildersConnectorComponent(self) self.steps = steps.StepsConnectorComponent(self) self.logs = logs.LogsConnectorComponent(self) self.cleanup_timer = internet.TimerService(self.CLEANUP_PERIOD, self._doCleanup) self.cleanup_timer.setServiceParent(self)
def make_fake_pool(_): engine = enginestrategy.create_engine(self.db_url, basedir=os.path.abspath('basedir')) # mock out the pool, and set up the model self.db = mock.Mock() self.db.pool.do_with_engine = lambda thd: defer.maybeDeferred(thd, engine) self.db.model = model.Model(self.db) self.db.start()
def setUpConnectorComponent(self, table_names=None, basedir='basedir'): """Set up C{self.db}, using the given db_url and basedir.""" if table_names is None: table_names = [] yield self.setUpRealDatabase(table_names=table_names, basedir=basedir) self.db = FakeDBConnector() self.db.pool = self.db_pool self.db.master = fakemaster.make_master() self.db.model = model.Model(self.db)
def setUp(self): yield self.setUpRealDatabase() engine = enginestrategy.create_engine( self.db_url, basedir=os.path.abspath('basedir')) # mock out the pool, and set up the model self.db = mock.Mock() self.db.pool.do_with_engine = lambda thd: defer.maybeDeferred( thd, engine) self.db.model = model.Model(self.db) self.db.start()
def setUpConnectorComponent(self, table_names=None, basedir='basedir', dialect_name='sqlite'): self.setUpTestReactor() """Set up C{self.db}, using the given db_url and basedir.""" if table_names is None: table_names = [] yield self.setUpRealDatabase(table_names=table_names, basedir=basedir) self.db = FakeDBConnector() self.db.pool = self.db_pool self.db.master = fakemaster.make_master(self) self.db.model = model.Model(self.db) self.db._engine = types.SimpleNamespace(dialect=types.SimpleNamespace(name=dialect_name))
def __init__(self, master, db_url, basedir): service.MultiService.__init__(self) self.master = master self.basedir = basedir "basedir for this master - used for upgrades" self._engine = enginestrategy.create_engine(db_url, basedir=self.basedir) self.pool = pool.DBThreadPool(self._engine) "thread pool (L{buildbot.db.pool.DBThreadPool}) for this db" self._oldpool = TempAdbapiPool(self._engine) self._sourcestamp_cache = util.LRUCache() # TODO: remove self._active_operations = set( ) # protected by synchronized= TODO: remove self._pending_notifications = [] # TODO: remove self._subscribers = bbcollections.defaultdict(set) self._started = False # set up components self.model = model.Model(self) "L{buildbot.db.model.Model} instance" self.changes = changes.ChangesConnectorComponent(self) "L{buildbot.db.changes.ChangesConnectorComponent} instance" self.schedulers = schedulers.SchedulersConnectorComponent(self) "L{buildbot.db.schedulers.ChangesConnectorComponent} instance" self.sourcestamps = sourcestamps.SourceStampsConnectorComponent(self) "L{buildbot.db.sourcestamps.SourceStampsConnectorComponent} instance" self.buildsets = buildsets.BuildsetsConnectorComponent(self) "L{buildbot.db.sourcestamps.BuildsetsConnectorComponent} instance" self.buildrequests = buildrequests.BuildRequestsConnectorComponent( self) "L{buildbot.db.sourcestamps.BuildRequestsConnectorComponent} instance" self.state = state.StateConnectorComponent(self) "L{buildbot.db.state.StateConnectorComponent} instance" self.cleanup_timer = internet.TimerService(self.CLEANUP_PERIOD, self.doCleanup) self.cleanup_timer.setServiceParent(self) self.changeHorizon = None # default value; set by master
def getDb(self): try: db_engine = enginestrategy.create_engine(self.db_url, basedir=self.basedir) except Exception: # db_url is probably trash. Just ignore, config.py db part will create proper message return None db = FakeDBConnector() db.master = FakeMaster() db.pool = FakePool() db.pool.engine = db_engine db.master.caches = FakeCacheManager() db.model = model.Model(db) db.state = state.StateConnectorComponent(db) try: self.objectid = db.state.thdGetObjectId(db_engine, self.name, "DbConfig")['id'] except (ProgrammingError, OperationalError): # ProgrammingError: mysql&pg, OperationalError: sqlite # assume db is not initialized db.pool.engine.close() return None return db
def finish_setup(_): self.db = FakeDBConnector() self.db.pool = self.db_pool self.db.master = fakemaster.make_master() self.db.model = model.Model(self.db)
def finish_setup(_): self.db = FakeDBConnector() self.db.pool = self.db_pool self.db.model = model.Model(self.db) self.db.master = mock.Mock()