[Buildbot-commits] buildbot/buildbot/test test_config.py,1.15,1.16

Brian Warner warner at users.sourceforge.net
Wed Apr 27 11:46:16 UTC 2005


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

Modified Files:
	test_config.py 
Log Message:
* buildbot/master.py (BuildMaster.loadChanges): fix change_svc
setup, it was completely broken for new buildmasters (those which
did not have a 'change.pck' already saved. Thanks to Paul Warren
for catching this (embarrassing!) bug.
(Dispatcher.__getstate__): don't save our registered avatar
factories, since they'll be re-populated when the config file is
re-read.
(BuildMaster.__init__): add a dummy ChangeMaster, used only by
tests (since the real mktap-generated BuildMaster doesn't save
this attribute).
(BuildMaster.__getstate__): don't save any service children,
they'll all be re-populated when the config file is re-read.
* buildbot/test/test_config.py (Save.testSave): test for this


Index: test_config.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_config.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- test_config.py	24 Apr 2005 21:30:25 -0000	1.15
+++ test_config.py	27 Apr 2005 11:46:13 -0000	1.16
@@ -6,6 +6,7 @@
 from twisted.trial import unittest
 dr = unittest.deferredResult
 from twisted.python import components
+from twisted.internet import defer
 
 try:
     import cvstoys
@@ -907,3 +908,55 @@
         m = BuildMaster("test_cf", "alternate.cfg")
         m.loadTheConfigFile()
         self.failUnlessEqual(m.slavePortnum, 9000)
+
+saveCfg1 = \
+"""
+from buildbot.changes import pb
+from buildbot.status import html, client
+c = {}
+c['bots'] = []
+c['sources'] = [pb.PBChangeSource()]
+c['builders'] = []
+c['slavePortnum'] = 0
+c['status'] = [html.Waterfall(http_port=0), client.PBListener(0)]
+BuildmasterConfig = c
+"""
+
+class Save(unittest.TestCase):
+    def setUp(self):
+        self.saved_argv = sys.argv
+    def tearDown(self):
+        sys.argv = self.saved_argv
+
+    def testSave(self):
+        # the idea here is to create the same buildbot.tap file that 'mktap
+        # buildbot master --basedir test_save' would create. Then we load it,
+        # and make sure it looks ok. We copy some code from
+        # twisted.scripts.mktap to avoid spawning a mktap instance (who knows
+        # how to accomplish such a thing under windows).
+
+        from twisted.scripts import mktap, twistd
+        os.mkdir("test_save")
+        f = open(os.path.join("test_save", "master.cfg"), "w")
+        f.write(saveCfg1)
+        f.close()
+        tapname = os.path.join("test_save", "buildbot.tap")
+        self.failIf(os.path.exists(tapname)) # shouldn't ever happen
+        sys.argv = ["mktap", "-a", tapname,
+                    "buildbot", "master", "--basedir", "test_save"]
+        mktap.run() # creates test_save/buildbot.tap
+
+        # now start the buildmaster from there
+        a = service.loadApplication(tapname, "pickle", None)
+        service.IService(a).startService()
+
+        # the buildmaster ought to be running now
+        m = service.IService(a).getServiceNamed("buildmaster")
+        self.failUnless(m.running)
+        self.failUnlessEqual(len(list(m.change_svc)), 1)
+
+        # now shut it down
+        d = defer.maybeDeferred(service.IService(a).stopService)
+        dr(d)
+
+        # done





More information about the Commits mailing list