[Buildbot-commits] buildbot/buildbot/test test_dependencies.py,1.1,1.2 test_buildreq.py,1.3,1.4

Brian Warner warner at users.sourceforge.net
Fri Oct 14 19:32:57 UTC 2005


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

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

BuildSet did not report failure correctly, breaking Dependent builds

	* buildbot/buildset.py (BuildSet): fix bug where BuildSet did not
	report failure correctly, causing Dependent builds to run when
	they shouldn't have.
	* buildbot/status/builder.py (BuildSetStatus): same
	* buildbot/test/test_buildreq.py (Set.testBuildSet): verify it
	(Set.testSuccess): test the both-pass case too
	* buildbot/test/test_dependencies.py (Dependencies.testRun_Fail):
	fix this test: it was ending too early, masking the failure before
	(Logger): specialized StatusReceiver to make sure the dependent
	builds aren't even started, much less completed.


Index: test_buildreq.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_buildreq.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- test_buildreq.py	17 Aug 2005 02:15:38 -0000	1.3
+++ test_buildreq.py	14 Oct 2005 19:32:55 -0000	1.4
@@ -105,6 +105,14 @@
         self.failUnlessEqual(r1.reason, s.reason)
         self.failUnlessEqual(r1.source, s.source)
 
+        st = s.status
+        self.failUnlessEqual(st.getSourceStamp(), source)
+        self.failUnlessEqual(st.getReason(), "forced build")
+        self.failUnlessEqual(st.getBuilderNames(), ["a","b"])
+        self.failIf(st.isFinished())
+        brs = st.getBuildRequests()
+        self.failUnlessEqual(len(brs), 2)
+
         res = []
         d1 = s.waitUntilSuccess()
         d1.addCallback(lambda r: res.append(("success", r)))
@@ -113,22 +121,62 @@
 
         self.failUnlessEqual(res, [])
 
+        # the first build finishes here, with FAILURE
         builderstatus_a = builder.BuilderStatus("a")
-        builderstatus_b = builder.BuilderStatus("b")
         bsa = builder.BuildStatus(builderstatus_a, 1)
         bsa.setResults(builder.FAILURE)
         a.requests[0].finished(bsa)
 
+        # any FAILURE flunks the BuildSet immediately, so the
+        # waitUntilSuccess deferred fires right away. However, the
+        # waitUntilFinished deferred must wait until all builds have
+        # completed.
         self.failUnlessEqual(len(res), 1)
         self.failUnlessEqual(res[0][0], "success")
         bss = res[0][1]
         self.failUnless(interfaces.IBuildSetStatus(bss, None))
+        self.failUnlessEqual(bss.getResults(), builder.FAILURE)
 
+        # here we finish the second build
+        builderstatus_b = builder.BuilderStatus("b")
         bsb = builder.BuildStatus(builderstatus_b, 1)
         bsb.setResults(builder.SUCCESS)
         b.requests[0].finished(bsb)
 
+        # .. which ought to fire the waitUntilFinished deferred
         self.failUnlessEqual(len(res), 2)
         self.failUnlessEqual(res[1][0], "finished")
         self.failUnlessEqual(res[1][1], bss)
 
+        # and finish the BuildSet overall
+        self.failUnless(st.isFinished())
+        self.failUnlessEqual(st.getResults(), builder.FAILURE)
+
+    def testSuccess(self):
+        S = buildset.BuildSet
+        a,b = FakeBuilder(), FakeBuilder()
+        # this time, both builds succeed
+
+        source = sourcestamp.SourceStamp()
+        s = S(["a","b"], source, "forced build")
+        s.start([a,b])
+
+        st = s.status
+        self.failUnlessEqual(st.getSourceStamp(), source)
+        self.failUnlessEqual(st.getReason(), "forced build")
+        self.failUnlessEqual(st.getBuilderNames(), ["a","b"])
+        self.failIf(st.isFinished())
+
+        builderstatus_a = builder.BuilderStatus("a")
+        bsa = builder.BuildStatus(builderstatus_a, 1)
+        bsa.setResults(builder.SUCCESS)
+        a.requests[0].finished(bsa)
+
+        builderstatus_b = builder.BuilderStatus("b")
+        bsb = builder.BuildStatus(builderstatus_b, 1)
+        bsb.setResults(builder.SUCCESS)
+        b.requests[0].finished(bsb)
+
+        self.failUnless(st.isFinished())
+        self.failUnlessEqual(st.getResults(), builder.SUCCESS)
+        

Index: test_dependencies.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_dependencies.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- test_dependencies.py	19 Jul 2005 23:11:58 -0000	1.1
+++ test_dependencies.py	14 Oct 2005 19:32:55 -0000	1.2
@@ -10,6 +10,7 @@
 from buildbot.process.base import BuildRequest
 from buildbot.test.runutils import RunMixin
 from buildbot.twcompat import maybeWait
+from buildbot.status import base
 
 config_1 = """
 from buildbot import scheduler
@@ -23,6 +24,12 @@
 c['schedulers'] = []
 c['slavePortnum'] = 0
 
+# upstream1 (fastfail, slowpass)
+#  -> downstream2 (b3, b4)
+# upstream3 (slowfail, slowpass)
+#  -> downstream4 (b3, b4)
+#  -> downstream5 (b5)
+
 s1 = scheduler.Scheduler('upstream1', None, 10, ['slowpass', 'fastfail'])
 s2 = scheduler.Dependent('downstream2', s1, ['b3', 'b4'])
 s3 = scheduler.Scheduler('upstream3', None, 10, ['fastpass', 'slowpass'])
@@ -47,6 +54,16 @@
                  ]
 """
 
+class Logger(base.StatusReceiverMultiService):
+    def __init__(self, master):
+        base.StatusReceiverMultiService.__init__(self)
+        self.builds = []
+        for bn in master.status.getBuilderNames():
+            master.status.getBuilder(bn).subscribe(self)
+
+    def buildStarted(self, builderName, build):
+        self.builds.append(builderName)
+
 class Dependencies(RunMixin, unittest.TestCase):
     def setUp(self):
         RunMixin.setUp(self)
@@ -67,6 +84,10 @@
         # that's it, just make sure this config file is loaded successfully
 
     def testRun_Fail(self):
+        # add an extra status target to make pay attention to which builds
+        # start and which don't.
+        self.logger = Logger(self.master)
+
         # kick off upstream1, which has a failing Builder and thus will not
         # trigger downstream3
         s = self.findScheduler("upstream1")
@@ -77,7 +98,7 @@
         # t=2: builder 'slowpass' finishes
         d = defer.Deferred()
         d.addCallback(self._testRun_Fail_1)
-        reactor.callLater(3, d.callback, None)
+        reactor.callLater(5, d.callback, None)
         return maybeWait(d)
 
     def _testRun_Fail_1(self, res):
@@ -94,6 +115,14 @@
         self.failIf(self.status.getBuilder('b4').getLastFinishedBuild())
         self.failIf(self.status.getBuilder('b5').getLastFinishedBuild())
 
+        # in fact, none of them should have even started
+        self.failUnlessEqual(len(self.logger.builds), 2)
+        self.failUnless("slowpass" in self.logger.builds)
+        self.failUnless("fastfail" in self.logger.builds)
+        self.failIf("b3" in self.logger.builds)
+        self.failIf("b4" in self.logger.builds)
+        self.failIf("b5" in self.logger.builds)
+
     def testRun_Pass(self):
         # kick off upstream3, which will fire downstream4 and then
         # downstream5





More information about the Commits mailing list