From 4721f5468705e2f303215c12fd46adf8a4b54240 Mon Sep 17 00:00:00 2001 From: Pierre Tardy Date: Mon, 27 Oct 2014 15:22:34 +0100 Subject: [PATCH] integration test for trac #2951 add a test for the case which the db is too slow to complete the newLog before end of the step if I revert previous commit, I get the error reported by benallard =============================================================================== [ERROR] Traceback (most recent call last): File "/Users/ptardy/dev/bb/buildbot-heroku/buildbot/master/buildbot/process/buildstep.py", line 157, in next self._catchup() File "/Users/ptardy/dev/bb/buildbot-heroku/buildbot/master/buildbot/process/buildstep.py", line 159, in _catchup self.step._start_unhandled_deferreds.append(d) exceptions.AttributeError: 'NoneType' object has no attribute 'append' buildbot.test.integration.test_custom_buildstep.RunSteps.test_OldStyleCustomBuildStepSlowDB buildbot.test.integration.test_custom_buildstep.RunSteps.test_OldStyleCustomBuildStepSlowDB =============================================================================== [ERROR] Traceback (most recent call last): File "/Users/ptardy/dev/bb/buildbot-heroku/buildbot/master/buildbot/process/buildstep.py", line 135, in gotAsync self._catchup() File "/Users/ptardy/dev/bb/buildbot-heroku/buildbot/master/buildbot/process/buildstep.py", line 159, in _catchup self.step._start_unhandled_deferreds.append(d) exceptions.AttributeError: 'NoneType' object has no attribute 'append' buildbot.test.integration.test_custom_buildstep.RunSteps.test_OldStyleCustomBuildStepSlowDB Signed-off-by: Pierre Tardy --- .../test/integration/test_custom_buildstep.py | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/master/buildbot/test/integration/test_custom_buildstep.py b/master/buildbot/test/integration/test_custom_buildstep.py index 9b2d5864e3a..87f8ecd9611 100644 --- a/master/buildbot/test/integration/test_custom_buildstep.py +++ b/master/buildbot/test/integration/test_custom_buildstep.py @@ -227,7 +227,21 @@ def assertLogs(self, exp_logs): self.assertEqual(got_logs, exp_logs) @defer.inlineCallbacks - def test_OldStyleCustomBuildStep(self): + def doOldStyleCustomBuildStep(self, slowDB=False): + if slowDB: + oldNewLog = self.master.data.updates.newLog + + def newLog(*args, **kw): + d = defer.Deferred() + + def delayed(): + r = oldNewLog(*args, **kw) + r.addCallback(d.callback) + + reactor.callLater(.1, delayed) + return d + self.patch(self.master.data.updates, "newLog", newLog) + self.factory.addStep(OldStyleCustomBuildStep(arg1=1, arg2=2)) yield self.do_test_step() @@ -239,10 +253,18 @@ def test_OldStyleCustomBuildStep(self): # 'stdout\n\xe2\x98\x83\nstderr\n', u'ostdout\no\N{SNOWMAN}\nestderr\n', u'obs': + # if slowDB, the observer wont see anything before the end of this instant step + u'Observer saw []\n' if slowDB else # 'Observer saw [\'stdout\\n\', \'\\xe2\\x98\\x83\\n\']', u'Observer saw [u\'stdout\\n\', u\'\\u2603\\n\']\n', }) + def test_OldStyleCustomBuildStep(self): + return self.doOldStyleCustomBuildStep(False) + + def test_OldStyleCustomBuildStepSlowDB(self): + return self.doOldStyleCustomBuildStep(True) + @defer.inlineCallbacks def test_OldStyleCustomBuildStep_failure(self): self.factory.addStep(OldStyleCustomBuildStep(arg1=1, arg2=2, doFail=1))