本文整理汇总了Python中buildbot.process.botmaster.BotMaster类的典型用法代码示例。如果您正苦于以下问题:Python BotMaster类的具体用法?Python BotMaster怎么用?Python BotMaster使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BotMaster类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.master = fakemaster.make_master(testcase=self, wantMq=True,
wantData=True)
self.master.mq = self.master.mq
self.botmaster = BotMaster(self.master)
self.new_config = mock.Mock()
self.botmaster.startService()
示例2: setUp
def setUp(self):
self.master = master = fakemaster.make_master(
testcase=self, wantData=True)
self.botmaster = BotMaster()
self.botmaster.setServiceParent(master)
self.reactor = mock.Mock()
self.botmaster.startService()
示例3: create_child_services
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)
示例4: create_child_services
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)
示例5: setUp
def setUp(self):
self.setUpTestReactor()
self.master = fakemaster.make_master(self, wantMq=True, wantData=True)
self.master.mq = self.master.mq
self.master.botmaster.disownServiceParent()
self.botmaster = BotMaster()
self.botmaster.setServiceParent(self.master)
self.new_config = mock.Mock()
self.botmaster.startService()
示例6: TestBotMaster
class TestBotMaster(unittest.TestCase):
def setUp(self):
self.botmaster = BotMaster(mock.Mock())
def test_maybeStartBuildsForBuilder(self):
brd = self.botmaster.brd = mock.Mock()
self.botmaster.maybeStartBuildsForBuilder('frank')
brd.maybeStartBuildsOn.assert_called_once_with(['frank'])
def test_maybeStartBuildsForSlave(self):
brd = self.botmaster.brd = mock.Mock()
b1 = mock.Mock(name='frank')
b1.name = 'frank'
b2 = mock.Mock(name='larry')
b2.name = 'larry'
self.botmaster.getBuildersForSlave = mock.Mock(return_value=[b1, b2])
self.botmaster.maybeStartBuildsForSlave('centos')
self.botmaster.getBuildersForSlave.assert_called_once_with('centos')
brd.maybeStartBuildsOn.assert_called_once_with(['frank', 'larry'])
def test_maybeStartBuildsForAll(self):
brd = self.botmaster.brd = mock.Mock()
self.botmaster.builderNames = ['frank', 'larry']
self.botmaster.maybeStartBuildsForAllBuilders()
brd.maybeStartBuildsOn.assert_called_once_with(['frank', 'larry'])
示例7: TestBotMaster
class TestBotMaster(unittest.TestCase):
def setUp(self):
self.master = fakemaster.make_master()
self.botmaster = BotMaster(self.master)
self.new_config = mock.Mock()
self.botmaster.startService()
def tearDown(self):
return self.botmaster.stopService()
def test_reconfigService(self):
# check that reconfigServiceSlaves and reconfigServiceBuilders are
# both called; they will be tested invidually below
self.patch(self.botmaster, "reconfigServiceBuilders", mock.Mock(side_effect=lambda c: defer.succeed(None)))
self.patch(self.botmaster, "reconfigServiceSlaves", mock.Mock(side_effect=lambda c: defer.succeed(None)))
self.patch(self.botmaster, "maybeStartBuildsForAllBuilders", mock.Mock())
old_config, new_config = mock.Mock(), mock.Mock()
d = self.botmaster.reconfigService(new_config)
@d.addCallback
def check(_):
self.botmaster.reconfigServiceBuilders.assert_called_with(new_config)
self.botmaster.reconfigServiceSlaves.assert_called_with(new_config)
self.assertTrue(self.botmaster.maybeStartBuildsForAllBuilders.called)
return d
@defer.deferredGenerator
def test_reconfigServiceSlaves_add_remove(self):
sl = FakeBuildSlave("sl1")
self.new_config.slaves = [sl]
wfd = defer.waitForDeferred(self.botmaster.reconfigServiceSlaves(self.new_config))
yield wfd
wfd.getResult()
self.assertIdentical(sl.parent, self.botmaster)
self.assertEqual(self.botmaster.slaves, {"sl1": sl})
self.new_config.slaves = []
wfd = defer.waitForDeferred(self.botmaster.reconfigServiceSlaves(self.new_config))
yield wfd
wfd.getResult()
self.assertIdentical(sl.parent, None)
self.assertIdentical(sl.master, None)
@defer.deferredGenerator
def test_reconfigServiceSlaves_reconfig(self):
sl = FakeBuildSlave("sl1")
self.botmaster.slaves = dict(sl1=sl)
sl.setServiceParent(self.botmaster)
sl.master = self.master
sl.botmaster = self.botmaster
sl_new = FakeBuildSlave("sl1")
self.new_config.slaves = [sl_new]
wfd = defer.waitForDeferred(self.botmaster.reconfigServiceSlaves(self.new_config))
yield wfd
wfd.getResult()
# sl was not replaced..
self.assertIdentical(self.botmaster.slaves["sl1"], sl)
@defer.deferredGenerator
def test_reconfigServiceSlaves_class_changes(self):
sl = FakeBuildSlave("sl1")
self.botmaster.slaves = dict(sl1=sl)
sl.setServiceParent(self.botmaster)
sl.master = self.master
sl.botmaster = self.botmaster
sl_new = FakeBuildSlave2("sl1")
self.new_config.slaves = [sl_new]
wfd = defer.waitForDeferred(self.botmaster.reconfigServiceSlaves(self.new_config))
yield wfd
wfd.getResult()
# sl *was* replaced (different class)
self.assertIdentical(self.botmaster.slaves["sl1"], sl_new)
@defer.deferredGenerator
def test_reconfigServiceBuilders_add_remove(self):
bc = config.BuilderConfig(name="bldr", factory=mock.Mock(), slavename="f")
self.new_config.builders = [bc]
wfd = defer.waitForDeferred(self.botmaster.reconfigServiceBuilders(self.new_config))
yield wfd
wfd.getResult()
bldr = self.botmaster.builders["bldr"]
self.assertIdentical(bldr.parent, self.botmaster)
self.assertIdentical(bldr.master, self.master)
self.assertEqual(self.botmaster.builderNames, ["bldr"])
self.new_config.builders = []
#.........这里部分代码省略.........
示例8: BuildMaster
class BuildMaster(config.ReconfigurableServiceMixin, service.AsyncMultiService):
# frequency with which to reclaim running builds; this should be set to
# something fairly long, to avoid undue database load
RECLAIM_BUILD_INTERVAL = 10 * 60
# multiplier on RECLAIM_BUILD_INTERVAL at which a build is considered
# unclaimed; this should be at least 2 to avoid false positives
UNCLAIMED_BUILD_FACTOR = 6
def __init__(self, basedir, configFileName="master.cfg", umask=None):
service.AsyncMultiService.__init__(self)
self.setName("buildmaster")
self.umask = umask
self.basedir = basedir
if basedir is not None: # None is used in tests
assert os.path.isdir(self.basedir)
self.configFileName = configFileName
# flag so we don't try to do fancy things before the master is ready
self._master_initialized = False
# set up child services
self.create_child_services()
# db configured values
self.configured_db_url = None
# configuration / reconfiguration handling
self.config = config.MasterConfig()
self.reconfig_active = False
self.reconfig_requested = False
self.reconfig_notifier = None
# this stores parameters used in the tac file, and is accessed by the
# WebStatus to duplicate those values.
self.log_rotation = LogRotation()
# local cache for this master's object ID
self._object_id = None
# Check environment is sensible
check_functional_environment(self.config)
# figure out local hostname
try:
self.hostname = os.uname()[1] # only on unix
except AttributeError:
self.hostname = socket.getfqdn()
# public attributes
self.name = ("%s:%s" % (self.hostname,
os.path.abspath(self.basedir or '.')))
self.name = self.name.decode('ascii', 'replace')
self.masterid = None
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)
#.........这里部分代码省略.........
示例9: TestCleanShutdown
class TestCleanShutdown(TestReactorMixin, unittest.TestCase):
def setUp(self):
self.setUpTestReactor()
self.master = fakemaster.make_master(self, wantData=True)
self.botmaster = BotMaster()
self.botmaster.setServiceParent(self.master)
self.botmaster.startService()
def assertReactorStopped(self, _=None):
self.assertTrue(self.reactor.stop_called)
def assertReactorNotStopped(self, _=None):
self.assertFalse(self.reactor.stop_called)
def makeFakeBuild(self, waitedFor=False):
self.fake_builder = builder = mock.Mock()
build_status = mock.Mock()
builder.builder_status.getCurrentBuilds.return_value = [build_status]
self.build_deferred = defer.Deferred()
request = mock.Mock()
request.waitedFor = waitedFor
build = mock.Mock()
build.stopBuild = self.stopFakeBuild
build.waitUntilFinished.return_value = self.build_deferred
build.requests = [request]
builder.building = [build]
self.botmaster.builders = mock.Mock()
self.botmaster.builders.values.return_value = [builder]
def stopFakeBuild(self, reason, results):
self.reason = reason
self.results = results
self.finishFakeBuild()
def finishFakeBuild(self):
self.fake_builder.building = []
self.build_deferred.callback(None)
# tests
def test_shutdown_idle(self):
"""Test that the master shuts down when it's idle"""
self.botmaster.cleanShutdown(_reactor=self.reactor)
self.assertReactorStopped()
def test_shutdown_busy(self):
"""Test that the master shuts down after builds finish"""
self.makeFakeBuild()
self.botmaster.cleanShutdown(_reactor=self.reactor)
# check that we haven't stopped yet, since there's a running build
self.assertReactorNotStopped()
# try to shut it down again, just to check that this does not fail
self.botmaster.cleanShutdown(_reactor=self.reactor)
# Now we cause the build to finish
self.finishFakeBuild()
# And now we should be stopped
self.assertReactorStopped()
def test_shutdown_busy_quick(self):
"""Test that the master shuts down after builds finish"""
self.makeFakeBuild()
self.botmaster.cleanShutdown(quickMode=True, _reactor=self.reactor)
# And now we should be stopped
self.assertReactorStopped()
self.assertEqual(self.results, RETRY)
def test_shutdown_busy_quick_cancelled(self):
"""Test that the master shuts down after builds finish"""
self.makeFakeBuild(waitedFor=True)
self.botmaster.cleanShutdown(quickMode=True, _reactor=self.reactor)
# And now we should be stopped
self.assertReactorStopped()
self.assertEqual(self.results, CANCELLED)
def test_shutdown_cancel_not_shutting_down(self):
"""Test that calling cancelCleanShutdown when none is in progress
works"""
# this just shouldn't fail..
self.botmaster.cancelCleanShutdown()
def test_shutdown_cancel(self):
"""Test that we can cancel a shutdown"""
self.makeFakeBuild()
self.botmaster.cleanShutdown(_reactor=self.reactor)
# Next we check that we haven't stopped yet, since there's a running
# build.
#.........这里部分代码省略.........
示例10: TestCleanShutdown
class TestCleanShutdown(unittest.TestCase):
def setUp(self):
self.botmaster = BotMaster(mock.Mock())
self.reactor = mock.Mock()
self.botmaster.startService()
def assertReactorStopped(self, _=None):
self.assertTrue(self.reactor.stop.called)
def assertReactorNotStopped(self, _=None):
self.assertFalse(self.reactor.stop.called)
def makeFakeBuild(self):
self.fake_builder = builder = mock.Mock()
build = mock.Mock()
builder.builder_status.getCurrentBuilds.return_value = [build]
self.build_deferred = defer.Deferred()
build.waitUntilFinished.return_value = self.build_deferred
self.botmaster.builders = mock.Mock()
self.botmaster.builders.values.return_value = [builder]
def finishFakeBuild(self):
self.fake_builder.builder_status.getCurrentBuilds.return_value = []
self.build_deferred.callback(None)
# tests
def test_shutdown_idle(self):
"""Test that the master shuts down when it's idle"""
self.botmaster.cleanShutdown(_reactor=self.reactor)
self.assertReactorStopped()
def test_shutdown_busy(self):
"""Test that the master shuts down after builds finish"""
self.makeFakeBuild()
self.botmaster.cleanShutdown(_reactor=self.reactor)
# check that we haven't stopped yet, since there's a running build
self.assertReactorNotStopped()
# try to shut it down again, just to check that this does not fail
self.botmaster.cleanShutdown(_reactor=self.reactor)
# Now we cause the build to finish
self.finishFakeBuild()
# And now we should be stopped
self.assertReactorStopped()
def test_shutdown_cancel_not_shutting_down(self):
"""Test that calling cancelCleanShutdown when none is in progress
works"""
# this just shouldn't fail..
self.botmaster.cancelCleanShutdown()
def test_shutdown_cancel(self):
"""Test that we can cancel a shutdown"""
self.makeFakeBuild()
self.botmaster.cleanShutdown(_reactor=self.reactor)
# Next we check that we haven't stopped yet, since there's a running
# build.
self.assertReactorNotStopped()
# but the BuildRequestDistributor should not be running
self.assertFalse(self.botmaster.brd.running)
# Cancel the shutdown
self.botmaster.cancelCleanShutdown()
# Now we cause the build to finish
self.finishFakeBuild()
# We should still be running!
self.assertReactorNotStopped()
# and the BuildRequestDistributor should be, as well
self.assertTrue(self.botmaster.brd.running)
示例11: setUp
def setUp(self):
self.botmaster = BotMaster(mock.Mock())
示例12: TestBotMaster
class TestBotMaster(unittest.TestCase):
def setUp(self):
self.master = fakemaster.make_master(testcase=self, wantMq=True,
wantData=True)
self.master.mq = self.master.mq
self.botmaster = BotMaster(self.master)
self.new_config = mock.Mock()
self.botmaster.startService()
def tearDown(self):
return self.botmaster.stopService()
def test_reconfigService(self):
# check that reconfigServiceBuilders is called.
self.patch(self.botmaster, 'reconfigServiceBuilders',
mock.Mock(side_effect=lambda c: defer.succeed(None)))
self.patch(self.botmaster, 'maybeStartBuildsForAllBuilders',
mock.Mock())
new_config = mock.Mock()
d = self.botmaster.reconfigService(new_config)
@d.addCallback
def check(_):
self.botmaster.reconfigServiceBuilders.assert_called_with(
new_config)
self.assertTrue(
self.botmaster.maybeStartBuildsForAllBuilders.called)
return d
@defer.inlineCallbacks
def test_reconfigServiceBuilders_add_remove(self):
bc = config.BuilderConfig(name='bldr', factory=factory.BuildFactory(),
slavename='f')
self.new_config.builders = [bc]
yield self.botmaster.reconfigServiceBuilders(self.new_config)
bldr = self.botmaster.builders['bldr']
self.assertIdentical(bldr.parent, self.botmaster)
self.assertIdentical(bldr.master, self.master)
self.assertEqual(self.botmaster.builderNames, ['bldr'])
self.new_config.builders = []
yield self.botmaster.reconfigServiceBuilders(self.new_config)
self.assertIdentical(bldr.parent, None)
self.assertIdentical(bldr.master, None)
self.assertEqual(self.botmaster.builders, {})
self.assertEqual(self.botmaster.builderNames, [])
def test_maybeStartBuildsForBuilder(self):
brd = self.botmaster.brd = mock.Mock()
self.botmaster.maybeStartBuildsForBuilder('frank')
brd.maybeStartBuildsOn.assert_called_once_with(['frank'])
def test_maybeStartBuildsForSlave(self):
brd = self.botmaster.brd = mock.Mock()
b1 = mock.Mock(name='frank')
b1.name = 'frank'
b2 = mock.Mock(name='larry')
b2.name = 'larry'
self.botmaster.getBuildersForSlave = mock.Mock(return_value=[b1, b2])
self.botmaster.maybeStartBuildsForSlave('centos')
self.botmaster.getBuildersForSlave.assert_called_once_with('centos')
brd.maybeStartBuildsOn.assert_called_once_with(['frank', 'larry'])
def test_maybeStartBuildsForAll(self):
brd = self.botmaster.brd = mock.Mock()
self.botmaster.builderNames = ['frank', 'larry']
self.botmaster.maybeStartBuildsForAllBuilders()
brd.maybeStartBuildsOn.assert_called_once_with(['frank', 'larry'])
示例13: BuildMaster
class BuildMaster(config.ReconfigurableServiceMixin, service.MultiService):
# frequency with which to reclaim running builds; this should be set to
# something fairly long, to avoid undue database load
RECLAIM_BUILD_INTERVAL = 10*60
# multiplier on RECLAIM_BUILD_INTERVAL at which a build is considered
# unclaimed; this should be at least 2 to avoid false positives
UNCLAIMED_BUILD_FACTOR = 6
# if this quantity of unclaimed build requests are present in the table,
# then something is probably wrong! The master will log a WARNING on every
# database poll operation.
WARNING_UNCLAIMED_COUNT = 10000
def __init__(self, basedir, configFileName="master.cfg"):
service.MultiService.__init__(self)
self.setName("buildmaster")
self.basedir = basedir
assert os.path.isdir(self.basedir)
self.configFileName = configFileName
# set up child services
self.create_child_services()
# loop for polling the db
self.db_loop = None
# configuration / reconfiguration handling
self.config = config.MasterConfig()
self.reconfig_active = False
self.reconfig_requested = False
self.reconfig_notifier = None
# this stores parameters used in the tac file, and is accessed by the
# WebStatus to duplicate those values.
self.log_rotation = LogRotation()
# subscription points
self._change_subs = \
subscription.SubscriptionPoint("changes")
self._new_buildrequest_subs = \
subscription.SubscriptionPoint("buildrequest_additions")
self._new_buildset_subs = \
subscription.SubscriptionPoint("buildset_additions")
self._complete_buildset_subs = \
subscription.SubscriptionPoint("buildset_completion")
# local cache for this master's object ID
self._object_id = None
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)
# setup and reconfig handling
_already_started = False
@defer.deferredGenerator
def startService(self, _reactor=reactor):
assert not self._already_started, "can only start the master once"
self._already_started = True
log.msg("Starting BuildMaster -- buildbot.version: %s" %
buildbot.version)
# first, apply all monkeypatches
monkeypatches.patch_all()
#.........这里部分代码省略.........
示例14: TestBotMaster
class TestBotMaster(unittest.TestCase):
def setUp(self):
self.master = fakemaster.make_master()
self.botmaster = BotMaster(self.master)
self.new_config = mock.Mock()
self.botmaster.startService()
def tearDown(self):
return self.botmaster.stopService()
def test_reconfigService(self):
# check that reconfigServiceSlaves and reconfigServiceBuilders are
# both called; they will be tested invidually below
self.patch(self.botmaster, 'reconfigServiceBuilders',
mock.Mock(side_effect=lambda c : defer.succeed(None)))
self.patch(self.botmaster, 'reconfigServiceSlaves',
mock.Mock(side_effect=lambda c : defer.succeed(None)))
self.patch(self.botmaster, 'maybeStartBuildsForAllBuilders',
mock.Mock())
old_config, new_config = mock.Mock(), mock.Mock()
d = self.botmaster.reconfigService(new_config)
@d.addCallback
def check(_):
self.botmaster.reconfigServiceBuilders.assert_called_with(
new_config)
self.botmaster.reconfigServiceSlaves.assert_called_with(
new_config)
self.assertTrue(
self.botmaster.maybeStartBuildsForAllBuilders.called)
return d
@defer.inlineCallbacks
def test_reconfigServiceSlaves_add_remove(self):
sl = FakeBuildSlave('sl1')
self.new_config.slaves = [ sl ]
yield self.botmaster.reconfigServiceSlaves(self.new_config)
self.assertIdentical(sl.parent, self.botmaster)
self.assertEqual(self.botmaster.slaves, { 'sl1' : sl })
self.new_config.slaves = [ ]
yield self.botmaster.reconfigServiceSlaves(self.new_config)
self.assertIdentical(sl.parent, None)
self.assertIdentical(sl.master, None)
@defer.inlineCallbacks
def test_reconfigServiceSlaves_reconfig(self):
sl = FakeBuildSlave('sl1')
self.botmaster.slaves = dict(sl1=sl)
sl.setServiceParent(self.botmaster)
sl.master = self.master
sl.botmaster = self.botmaster
sl_new = FakeBuildSlave('sl1')
self.new_config.slaves = [ sl_new ]
yield self.botmaster.reconfigServiceSlaves(self.new_config)
# sl was not replaced..
self.assertIdentical(self.botmaster.slaves['sl1'], sl)
@defer.inlineCallbacks
def test_reconfigServiceSlaves_class_changes(self):
sl = FakeBuildSlave('sl1')
self.botmaster.slaves = dict(sl1=sl)
sl.setServiceParent(self.botmaster)
sl.master = self.master
sl.botmaster = self.botmaster
sl_new = FakeBuildSlave2('sl1')
self.new_config.slaves = [ sl_new ]
yield self.botmaster.reconfigServiceSlaves(self.new_config)
# sl *was* replaced (different class)
self.assertIdentical(self.botmaster.slaves['sl1'], sl_new)
@defer.inlineCallbacks
def test_reconfigServiceBuilders_add_remove(self):
bc = config.BuilderConfig(name='bldr', factory=mock.Mock(),
slavename='f')
self.new_config.builders = [ bc ]
yield self.botmaster.reconfigServiceBuilders(self.new_config)
bldr = self.botmaster.builders['bldr']
self.assertIdentical(bldr.parent, self.botmaster)
self.assertIdentical(bldr.master, self.master)
self.assertEqual(self.botmaster.builderNames, [ 'bldr' ])
self.new_config.builders = [ ]
yield self.botmaster.reconfigServiceBuilders(self.new_config)
self.assertIdentical(bldr.parent, None)
#.........这里部分代码省略.........
示例15: setUp
def setUp(self):
self.master = BotMaster(Mock())
self.master.reactor = Mock()
self.master.startService()