[Buildbot-commits] buildbot/buildbot/test test_dependencies.py,1.2,1.3 test_config.py,1.32,1.33 test_run.py,1.36,1.37

Brian Warner warner at users.sourceforge.net
Tue Jan 3 09:26:43 UTC 2006


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

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

fix a bug: config-file reload would half-clobber all Schedulers

	* buildbot/master.py (BuildMaster): remove the .schedulers
	attribute, replacing it with an allSchedulers() method that looks
	for all IService children that implement IScheduler. Having only
	one parent/child relationship means fewer opportunities for bugs.
	(BuildMaster.allSchedulers): new method
	(BuildMaster.loadConfig_Schedulers): update to use allSchedulers,
	also fix ugly bug that caused any config-file reload to
	half-forget about the earlier Schedulers, causing an exception
	when a Change arrived and was handed to a half-connected
	Scheduler. The exception was in scheduler.py line 54ish:
	  self.parent.submitBuildSet(bs)
	  exceptions.AttributeError: 'NoneType' object has no attribute
	  'submitBuildSet'
	(BuildMaster.addChange): update to use allSchedulers()

	* buildbot/scheduler.py (BaseScheduler.__implements__): fix this
	to work properly with twisted-1.3.0, where you must explicitly
	include the __implements__ from parent classes
	(BaseScheduler.__repr__): make it easier to distinguish distinct
	instances
	(BaseUpstreamScheduler.__implements__): same

	* buildbot/status/builder.py (Status.getSchedulers): update to
	use allSchedulers()
	* buildbot/test/test_run.py (Run.testMaster): same
	* buildbot/test/test_dependencies.py (Dependencies.findScheduler): same
	* buildbot/test/test_config.py (ConfigTest.testSchedulers): same,
	make sure Scheduler instances are left alone when an identical
	config file is reloaded
	(ConfigElements.testSchedulers): make sure Schedulers are properly
	comparable

	* Makefile (TRIALARGS): my local default Twisted version is now
	2.1.0, update the trial arguments accordingly


Index: test_config.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_config.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- test_config.py	25 Nov 2005 01:25:11 -0000	1.32
+++ test_config.py	3 Jan 2006 09:26:41 -0000	1.33
@@ -16,6 +16,7 @@
 from buildbot.twcompat import providedBy, maybeWait
 from buildbot.master import BuildMaster
 from buildbot import scheduler
+from buildbot import interfaces as ibb
 from twisted.application import service, internet
 from twisted.spread import pb
 from twisted.web.server import Site
@@ -511,7 +512,7 @@
         master = self.buildmaster
         master.loadChanges()
         master.loadConfig(emptyCfg)
-        self.failUnlessEqual(master.schedulers, [])
+        self.failUnlessEqual(master.allSchedulers(), [])
 
         self.schedulersCfg = \
 """
@@ -565,8 +566,9 @@
         d.addCallback(self._testSchedulers_4)
         return d
     def _testSchedulers_4(self, res):
-        self.failUnlessEqual(len(self.buildmaster.schedulers), 1)
-        s = self.buildmaster.schedulers[0]
+        sch = self.buildmaster.allSchedulers()
+        self.failUnlessEqual(len(sch), 1)
+        s = sch[0]
         self.failUnless(isinstance(s, scheduler.Scheduler))
         self.failUnlessEqual(s.name, "full")
         self.failUnlessEqual(s.branch, None)
@@ -579,17 +581,33 @@
 c['schedulers'] = [s1, Dependent('downstream', s1, ['builder1'])]
 """
         d = self.buildmaster.loadConfig(newcfg)
-        d.addCallback(self._testSchedulers_5)
+        d.addCallback(self._testSchedulers_5, newcfg)
         return d
-    def _testSchedulers_5(self, res):
-        self.failUnlessEqual(len(self.buildmaster.schedulers), 2)
-        s = self.buildmaster.schedulers[0]
+    def _testSchedulers_5(self, res, newcfg):
+        sch = self.buildmaster.allSchedulers()
+        self.failUnlessEqual(len(sch), 2)
+        s = sch[0]
         self.failUnless(isinstance(s, scheduler.Scheduler))
-        s = self.buildmaster.schedulers[1]
+        s = sch[1]
         self.failUnless(isinstance(s, scheduler.Dependent))
         self.failUnlessEqual(s.name, "downstream")
         self.failUnlessEqual(s.builderNames, ['builder1'])
 
+        # reloading the same config file should leave the schedulers in place
+        d = self.buildmaster.loadConfig(newcfg)
+        d.addCallback(self._testschedulers_6, sch)
+        return d
+    def _testschedulers_6(self, res, sch1):
+        sch2 = self.buildmaster.allSchedulers()
+        self.failUnlessEqual(len(sch2), 2)
+        sch1.sort()
+        sch2.sort()
+        self.failUnlessEqual(sch1, sch2)
+        self.failUnlessIdentical(sch1[0], sch2[0])
+        self.failUnlessIdentical(sch1[1], sch2[1])
+        self.failUnlessIdentical(sch1[0].parent, self.buildmaster)
+        self.failUnlessIdentical(sch1[1].parent, self.buildmaster)
+
 
     def testBuilders(self):
         master = self.buildmaster
@@ -828,6 +846,32 @@
         master.loadConfig(lockCfg2c)
         self.failIfIdentical(b1, master.botmaster.builders["builder1"])
 
+class ConfigElements(unittest.TestCase):
+    # verify that ComparableMixin is working
+    def testSchedulers(self):
+        s1 = scheduler.Scheduler(name='quick', branch=None,
+                                 treeStableTimer=30,
+                                 builderNames=['quick'])
+        s2 = scheduler.Scheduler(name="all", branch=None,
+                                 treeStableTimer=5*60,
+                                 builderNames=["a", "b"])
+        s3 = scheduler.Try_Userpass("try", ["a","b"], port=9989,
+                                    userpass=[("foo","bar")])
+        s1a = scheduler.Scheduler(name='quick', branch=None,
+                                  treeStableTimer=30,
+                                  builderNames=['quick'])
+        s2a = scheduler.Scheduler(name="all", branch=None,
+                                  treeStableTimer=5*60,
+                                  builderNames=["a", "b"])
+        s3a = scheduler.Try_Userpass("try", ["a","b"], port=9989,
+                                     userpass=[("foo","bar")])
+        self.failUnless(s1 == s1)
+        self.failUnless(s1 == s1a)
+        self.failUnless(s1a in [s1, s2, s3])
+        self.failUnless(s2a in [s1, s2, s3])
+        self.failUnless(s3a in [s1, s2, s3])
+
+
 
 class ConfigFileTest(unittest.TestCase):
 

Index: test_dependencies.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_dependencies.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- test_dependencies.py	14 Oct 2005 19:32:55 -0000	1.2
+++ test_dependencies.py	3 Jan 2006 09:26:41 -0000	1.3
@@ -74,7 +74,7 @@
         return maybeWait(d)
 
     def findScheduler(self, name):
-        for s in self.master.schedulers:
+        for s in self.master.allSchedulers():
             if s.name == name:
                 return s
         raise KeyError("No Scheduler named '%s'" % name)

Index: test_run.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_run.py,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- test_run.py	27 Nov 2005 00:46:13 -0000	1.36
+++ test_run.py	3 Jan 2006 09:26:41 -0000	1.37
@@ -92,7 +92,7 @@
         c = changes.Change("bob", ["Makefile", "foo/bar.c"], "changed stuff")
         cm.addChange(c)
         # verify that the Scheduler is now waiting
-        s = m.schedulers[0]
+        s = m.allSchedulers()[0]
         self.failUnless(s.timer)
         # halting the service will also stop the timer
         d = defer.maybeDeferred(m.stopService)





More information about the Commits mailing list