[Buildbot-commits] buildbot/buildbot/test runutils.py, 1.22, 1.23 test_transfer.py, 1.5, 1.6

Brian Warner warner at users.sourceforge.net
Tue Jan 1 02:46:40 UTC 2008


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

Modified Files:
	runutils.py test_transfer.py 
Log Message:
[project @ file transfer: avoid tail recursion, to fix stack-depth errors. Closes #106.]

Original author: warner at lothar.com
Date: 2008-01-01 02:44:42+00:00

Index: runutils.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/runutils.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- runutils.py	12 Aug 2007 22:22:41 -0000	1.22
+++ runutils.py	1 Jan 2008 02:46:38 -0000	1.23
@@ -340,7 +340,10 @@
         self.target = target
 
     def callRemote(self, name, *args, **kwargs):
-        d = defer.maybeDeferred(self._callRemote, name, *args, **kwargs)
+        # callRemote is not allowed to fire its Deferred in the same turn
+        d = defer.Deferred()
+        d.addCallback(self._callRemote, *args, **kwargs)
+        reactor.callLater(0, d.callback, name)
         return d
 
     def _callRemote(self, name, *args, **kwargs):

Index: test_transfer.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_transfer.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- test_transfer.py	11 Dec 2006 08:23:29 -0000	1.5
+++ test_transfer.py	1 Jan 2008 02:46:38 -0000	1.6
@@ -7,7 +7,6 @@
 from buildbot.test.runutils import StepTester
 from buildbot.status.builder import SUCCESS, FAILURE
 
-
 # these steps pass a pb.Referenceable inside their arguments, so we have to
 # catch and wrap them. If the LocalAsRemote wrapper were a proper membrane,
 # we wouldn't have to do this.
@@ -154,7 +153,47 @@
         d.addCallback(_checkUpload)
         return d
 
-    
+    def testLotsOfBlocks(self):
+        self.slavebase = "Upload.testLotsOfBlocks.slave"
+        self.masterbase = "Upload.testLotsOfBlocks.master"
+        sb = self.makeSlaveBuilder()
+        os.mkdir(os.path.join(self.slavebase, self.slavebuilderbase,
+                              "build"))
+        # the buildmaster normally runs chdir'ed into masterbase, so uploaded
+        # files will appear there. Under trial, we're chdir'ed into
+        # _trial_temp instead, so use a different masterdest= to keep the
+        # uploaded file in a test-local directory
+        masterdest = os.path.join(self.masterbase, "dest.text")
+        step = self.makeStep(FileUpload,
+                             slavesrc="source.txt",
+                             masterdest=masterdest,
+                             blocksize=15)
+        slavesrc = os.path.join(self.slavebase,
+                                self.slavebuilderbase,
+                                "build",
+                                "source.txt")
+        contents = "".join(["this is the source file #%d\n" % i
+                            for i in range(1000)])
+        open(slavesrc, "w").write(contents)
+        f = open(masterdest, "w")
+        f.write("overwrite me\n")
+        f.close()
+
+        d = self.runStep(step)
+        def _checkUpload(results):
+            step_status = step.step_status
+            #l = step_status.getLogs()
+            #if l:
+            #    logtext = l[0].getText()
+            #    print logtext
+            self.failUnlessEqual(results, SUCCESS)
+            self.failUnless(os.path.exists(masterdest))
+            masterdest_contents = open(masterdest, "r").read()
+            self.failUnlessEqual(masterdest_contents, contents)
+        d.addCallback(_checkUpload)
+        return d
+    testLotsOfBlocks.timeout = 20
+
 
 class Download(StepTester, unittest.TestCase):
 
@@ -289,6 +328,39 @@
 
         return d
 
+    def testLotsOfBlocks(self):
+        self.slavebase = "Download.testLotsOfBlocks.slave"
+        self.masterbase = "Download.testLotsOfBlocks.master"
+        sb = self.makeSlaveBuilder()
+        os.mkdir(os.path.join(self.slavebase, self.slavebuilderbase,
+                              "build"))
+        mastersrc = os.path.join(self.masterbase, "source.text")
+        slavedest = os.path.join(self.slavebase,
+                                 self.slavebuilderbase,
+                                 "build",
+                                 "dest.txt")
+        step = self.makeStep(FileDownload,
+                             mastersrc=mastersrc,
+                             slavedest="dest.txt",
+                             blocksize=15)
+        contents = "".join(["this is the source file #%d\n" % i
+                            for i in range(1000)])
+        open(mastersrc, "w").write(contents)
+        f = open(slavedest, "w")
+        f.write("overwrite me\n")
+        f.close()
+
+        d = self.runStep(step)
+        def _checkDownload(results):
+            step_status = step.step_status
+            self.failUnlessEqual(results, SUCCESS)
+            self.failUnless(os.path.exists(slavedest))
+            slavedest_contents = open(slavedest, "r").read()
+            self.failUnlessEqual(slavedest_contents, contents)
+        d.addCallback(_checkDownload)
+        return d
+    testLotsOfBlocks.timeout = 20
+
 
 # TODO:
 #  test relative paths, ~/paths





More information about the Commits mailing list