[Buildbot-commits] buildbot/buildbot/test test_run.py,1.22,1.23

Brian Warner warner at users.sourceforge.net
Fri Apr 22 21:29:22 UTC 2005


Update of /cvsroot/buildbot/buildbot/buildbot/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15396/buildbot/test

Modified Files:
	test_run.py 
Log Message:
Revision: arch at buildbot.sf.net--2004/buildbot--dev--0--patch-69
Creator:  Brian Warner <warner at monolith.lothar.com>

fix propagation of changes to .builddir

2005-04-22  Brian Warner  <warner at lothar.com>

   * buildbot/test/test_run.py (RunMixin.shutdownSlave): remove the
   whendone= argument, just return the Deferred and let the caller do
   what they want with it.
   (Disconnect.testBuild1): wait for shutdownSlave
   (Basedir.testChangeBuilddir): new test to make sure changes to the
   builddir actually get propagated to the slave

   * buildbot/slave/bot.py (SlaveBuilder.setBuilddir): use an
   explicit method, rather than passing the builddir in __init__ .
   Make sure to update self.basedir too, this was broken before.
   (Bot.remote_setBuilderList): use b.setBuilddir for both new
   builders and for ones that have just had their builddir changed.
   (BotFactory): add a class-level .perspective attribute, so
   BuildSlave.waitUntilDisconnected won't get upset when the
   connection hasn't yet been established
   (BuildSlave.__init__): keep track of the bot.Bot instance, so
   tests can reach through it to inspect the SlaveBuilders

   * buildbot/process/base.py (Build.buildException): explain the
   log.err with a log.msg
   * buildbot/process/builder.py (Builder.startBuild): same
   (Builder._startBuildFailed): improve error message

   * buildbot/pbutil.py (RBCP.failedToGetPerspective): if the failure
   occurred because we lost the brand-new connection, retry instead
   of giving up. If not, it's probably an authorization failure, and
   it makes sense to stop trying. Make sure we log.msg the reason
   that we're log.err'ing the failure, otherwise test failures are
   really hard to figure out.

   * buildbot/master.py: change loadConfig() to return a Deferred
   that doesn't fire until the change has been fully implemented.
   This means any connected slaves have been updated with the new
   builddir. This change makes it easier to test the code which
   actually implements this builddir-updating.
   (BotPerspective.addBuilder): return Deferred
   (BotPerspective.removeBuilder): same
   (BotPerspective.attached): same
   (BotPerspective._attached): same. finish with remote_print before
   starting the getSlaveInfo, instead of doing them in parallel
   (BotPerspective.list_done): same
   (BotMaster.removeSlave): same. Fix the typo that meant we weren't
   actually calling slave.disconnect()
   (BotMaster.addBuilder): same
   (BotMaster.removeBuilder): same
   (BuildMaster.loadConfig): same
   (BuildMaster.loadConfig_Slaves): same
   (BuildMaster.loadConfig_Sources): same
   (BuildMaster.loadConfig_Builders): same
   (BuildMaster.loadConfig_status): same

   * buildbot/changes/changes.py (ChangeMaster.removeSource): return
   a Deferred that fires when the source is finally removed


Index: test_run.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_run.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- test_run.py	2 Apr 2005 01:41:38 -0000	1.22
+++ test_run.py	22 Apr 2005 21:29:20 -0000	1.23
@@ -55,6 +55,25 @@
 BuildmasterConfig = c
 """
 
+config_2_newbasedir = """
+from buildbot.process import factory, step
+
+def s(klass, **kwargs):
+    return (klass, kwargs)
+
+f1 = factory.BuildFactory([
+    s(step.Dummy, timeout=1),
+    s(step.RemoteDummy, timeout=2),
+    ])
+c = {}
+c['bots'] = [['bot1', 'sekrit']]
+c['sources'] = []
+c['builders'] = [{'name': 'dummy', 'slavename': 'bot1',
+                  'builddir': 'dummy2', 'factory': f1}]
+c['slavePortnum'] = 0
+BuildmasterConfig = c
+"""
+
 class MyBot(bot.Bot):
     def remote_getSlaveInfo(self):
         return self.parent.info
@@ -198,14 +217,12 @@
 
     # various forms of slave death
 
-    def shutdownSlave(self, whendone=None):
+    def shutdownSlave(self):
         # the slave has disconnected normally: they SIGINT'ed it, or it shut
         # down willingly. This will kill child processes and give them a
         # chance to finish up. We return a Deferred that will fire when
         # everything is finished shutting down.
 
-        # 'whendone' is an optional Deferred that will be fired when the
-        # shutdown is complete
         log.msg("doing shutdownSlave")
         dl = []
         if self.slave:
@@ -216,8 +233,6 @@
             dl.append(defer.maybeDeferred(self.slave2.stopService))
         d = defer.DeferredList(dl)
         d.addCallback(self._shutdownSlaveDone)
-        if whendone:
-            d.addCallback(whendone.callback)
         return d
     def _shutdownSlaveDone(self, res):
         self.slave = None
@@ -508,8 +523,10 @@
         #
         bc = c.getBuilder("dummy").forceBuild(None, "forced build")
         bs = bc.getStatus()
-        # kill the slave while it's running the first step
-        self.shutdownSlave() # dies before it gets started
+
+        # now kill the slave before it gets to start the first step
+        d = self.shutdownSlave() # dies before it gets started
+        dr(d, 5)
 
         # now examine the just-stopped build and make sure it is really
         # stopped. This is checking for bugs in which the slave-detach gets
@@ -642,3 +659,32 @@
 
         self.failUnless(ss.isConnected())
         self.failUnlessEqual(ss.getAdmin(), "two")
+
+class Basedir(RunMixin, unittest.TestCase):
+    def testChangeBuilddir(self):
+        m = self.master
+        m.loadConfig(config_2)
+        m.readConfig = True
+        m.startService()
+        
+        self.connectSlave()
+        bot = self.slave.bot
+        builder = bot.builders.get("dummy")
+        self.failUnless(builder)
+        self.failUnlessEqual(builder.builddir, "dummy")
+        self.failUnlessEqual(builder.basedir, "slavebase/dummy")
+
+        d = m.loadConfig(config_2_newbasedir)
+        dr(d)
+
+        # this causes the builder to be replaced
+        self.failIfIdentical(builder, bot.builders.get("dummy"))
+        builder = bot.builders.get("dummy")
+        self.failUnless(builder)
+        # the basedir should be updated
+        self.failUnlessEqual(builder.builddir, "dummy2")
+        self.failUnlessEqual(builder.basedir, "slavebase/dummy2")
+
+        # done
+
+        





More information about the Commits mailing list