Repository: buildbot/buildbot

Issue:
Workerinfo



Discussion:

Resolving patch:
diff --git a/master/buildbot/process/build.py b/master/buildbot/process/build.py
--- a/master/buildbot/process/build.py
+++ b/master/buildbot/process/build.py
@@ -184,13 +184,15 @@ def setupProperties(self):
     def setupSlaveBuilder(self, slavebuilder):
         self.slavebuilder = slavebuilder
 
+        self.path_module = slavebuilder.slave.path_module
+
         # navigate our way back to the L{buildbot.buildslave.BuildSlave}
         # object that came from the config, and get its properties
         buildslave_properties = slavebuilder.slave.properties
         self.getProperties().updateFromProperties(buildslave_properties)
         if slavebuilder.slave.slave_basedir:
             self.setProperty("workdir",
-                    slavebuilder.slave.path_module.join(
+                    self.path_module.join(
                         slavebuilder.slave.slave_basedir,
                         self.builder.config.slavebuilddir),
                     "slave")
diff --git a/master/buildbot/steps/source/cvs.py b/master/buildbot/steps/source/cvs.py
--- a/master/buildbot/steps/source/cvs.py
+++ b/master/buildbot/steps/source/cvs.py
@@ -20,6 +20,7 @@
 from twisted.internet import defer
 
 from buildbot.process import buildstep
+from buildbot.steps.shell import StringFileWriter
 from buildbot.steps.source.base import Source
 from buildbot.interfaces import BuildSlaveTooOldError
 
@@ -72,7 +73,7 @@ def incremental(self):
         if updatable:
             rv = yield self.doUpdate()
         else:
-            rv = yield self.doCheckout(self.workdir)
+            rv = yield self.clobber()
         defer.returnValue(rv)
 
     @defer.inlineCallbacks
@@ -161,13 +162,13 @@ def evaluate(rc):
         return d
         
     def doCheckout(self, dir):
-        command = ['-d', self.cvsroot, '-z3', 'checkout', '-d', dir,
-                   self.cvsmodule]
+        command = ['-d', self.cvsroot, '-z3', 'checkout', '-d', dir ]
         command = self.global_options + command + self.extra_options
         if self.branch:
             command += ['-r', self.branch]
         if self.revision:
             command += ['-D', self.revision]
+        command += [ self.cvsmodule ]
         d = self._dovccmd(command, '')
         return d
 
@@ -221,17 +222,40 @@ def evaluateCommand(cmd):
         d.addCallback(lambda _: evaluateCommand(cmd))
         return d
 
+    @defer.inlineCallbacks
     def _sourcedirIsUpdatable(self):
-        cmd = buildstep.RemoteCommand('stat', {'file': self.workdir + '/CVS',
-                                               'logEnviron': self.logEnviron})
-        cmd.useLog(self.stdio_log, False)
-        d = self.runCommand(cmd)
-        def _fail(tmp):
-            if cmd.rc != 0:
-                return False
-            return True
-        d.addCallback(_fail)
-        return d
+        myFileWriter = StringFileWriter()
+        args = {
+                'workdir': self.build.path_module.join(self.workdir, 'CVS'),
+                'writer': myFileWriter,
+                'maxsize': None,
+                'blocksize': 32*1024,
+                }
+
+        cmd = buildstep.RemoteCommand('uploadFile',
+                dict(slavesrc='Root', **args),
+                ignore_updates=True)
+        yield self.runCommand(cmd)
+        if cmd.rc is not None and cmd.rc != 0:
+            defer.returnValue(False)
+            return
+        if myFileWriter.buffer.strip() != self.cvsroot:
+            defer.returnValue(False)
+            return
+
+        myFileWriter.buffer = ""
+        cmd = buildstep.RemoteCommand('uploadFile',
+                dict(slavesrc='Repository', **args),
+                ignore_updates=True)
+        yield self.runCommand(cmd)
+        if cmd.rc is not None and cmd.rc != 0:
+            defer.returnValue(False)
+            return
+        if myFileWriter.buffer.strip() != self.cvsmodule:
+            defer.returnValue(False)
+            return
+
+        defer.returnValue(True)
 
     def parseGotRevision(self, res):
         revision = time.strftime("%Y-%m-%d %H:%M:%S +0000", time.gmtime())


Test patch:
diff --git a/master/buildbot/test/fake/fakebuild.py b/master/buildbot/test/fake/fakebuild.py
--- a/master/buildbot/test/fake/fakebuild.py
+++ b/master/buildbot/test/fake/fakebuild.py
@@ -14,6 +14,7 @@
 # Copyright Buildbot Team Members
 
 import mock
+import posixpath
 from twisted.python import components
 from buildbot.process import properties
 from buildbot import interfaces
@@ -34,6 +35,7 @@ class FakeBuild(mock.Mock, properties.PropertiesMixin):
     def __init__(self, *args, **kwargs):
         mock.Mock.__init__(self, *args, **kwargs)
         self.build_status = FakeBuildStatus()
+        self.path_module = posixpath
         pr = self.build_status.properties = properties.Properties()
         pr.build = self
 
diff --git a/master/buildbot/test/unit/test_steps_source_cvs.py b/master/buildbot/test/unit/test_steps_source_cvs.py
--- a/master/buildbot/test/unit/test_steps_source_cvs.py
+++ b/master/buildbot/test/unit/test_steps_source_cvs.py
@@ -14,10 +14,18 @@
 # Copyright Buildbot Team Members
 
 from twisted.trial import unittest
+from buildbot.steps import shell
 from buildbot.steps.source import cvs
 from buildbot.status.results import SUCCESS, FAILURE
 from buildbot.test.util import sourcesteps
-from buildbot.test.fake.remotecommand import ExpectShell, Expect
+from buildbot.test.fake.remotecommand import ExpectShell, Expect, ExpectRemoteRef
+
+def uploadString(cvsroot):
+    def behavior(command):
+        writer = command.args['writer']
+        writer.remote_write(cvsroot + "\n")
+        writer.remote_close()
+    return behavior
 
 class TestCVS(sourcesteps.SourceStepMixin, unittest.TestCase):
 
@@ -36,8 +44,15 @@ def test_mode_full_clean(self):
             ExpectShell(workdir='wkdir',
                         command=['cvs', '--version'])
             + 0,
-            Expect('stat', dict(file='wkdir/CVS',
-                                logEnviron=True))
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Root', workdir='wkdir/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
+            + Expect.behavior(uploadString(':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot'))
+            + 0,
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Repository', workdir='wkdir/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
+            + Expect.behavior(uploadString('mozilla/browser/'))
             + 0,
             ExpectShell(workdir='wkdir',
                         command=['cvsdiscard'])
@@ -59,8 +74,15 @@ def test_mode_full_fresh(self):
             ExpectShell(workdir='wkdir',
                         command=['cvs', '--version'])
             + 0,
-            Expect('stat', dict(file='wkdir/CVS',
-                                logEnviron=True))
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Root', workdir='wkdir/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
+            + Expect.behavior(uploadString(':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot'))
+            + 0,
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Repository', workdir='wkdir/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
+            + Expect.behavior(uploadString('mozilla/browser/'))
             + 0,
             ExpectShell(workdir='wkdir',
                         command=['cvsdiscard', '--ignore'])
@@ -108,9 +130,16 @@ def test_mode_full_copy(self):
             Expect('rmdir', dict(dir='wkdir',
                                  logEnviron=True))
             + 0,
-            Expect('stat', dict(file='source/CVS',
-                                logEnviron=True))
-            + 0,            
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Root', workdir='source/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
+            + Expect.behavior(uploadString(':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot'))
+            + 0,
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Repository', workdir='source/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
+            + Expect.behavior(uploadString('mozilla/browser/'))
+            + 0,
             ExpectShell(workdir='source',
                         command=['cvs', '-z3', 'update', '-dP'])
             + 0,
@@ -122,6 +151,41 @@ def test_mode_full_copy(self):
         self.expectOutcome(result=SUCCESS, status_text=["update"])
         return self.runStep()
 
+
+    def test_mode_full_copy_wrong_repo(self):
+        self.setupStep(
+            cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
+                    cvsmodule="mozilla/browser/", mode='full', method='copy',
+                    login=True))
+        self.expectCommands(
+            ExpectShell(workdir='wkdir',
+                        command=['cvs', '--version'])
+            + 0,
+            Expect('rmdir', dict(dir='wkdir',
+                                 logEnviron=True))
+            + 0,
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Root', workdir='source/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
+            + Expect.behavior(uploadString('the-end-of-the-universe'))
+            + 0,
+            Expect('rmdir', dict(dir='source',
+                                 logEnviron=True))
+            + 0,
+            ExpectShell(workdir='',
+                        command=['cvs',
+                                 '-d',
+                                 ':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot',
+                                 '-z3', 'checkout', '-d', 'source', 'mozilla/browser/'])
+            + 0,
+            Expect('cpdir', {'fromdir': 'source', 'todir': 'build',
+                             'logEnviron': True})
+            + 0,
+            )
+
+        self.expectOutcome(result=SUCCESS, status_text=["update"])
+        return self.runStep()
+
     def test_mode_incremental(self):
         self.setupStep(
             cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
@@ -131,9 +195,16 @@ def test_mode_incremental(self):
             ExpectShell(workdir='wkdir',
                         command=['cvs', '--version'])
             + 0,
-            Expect('stat', dict(file='wkdir/CVS',
-                                logEnviron=True))
-            + 0,            
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Root', workdir='wkdir/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
+            + Expect.behavior(uploadString(':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot'))
+            + 0,
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Repository', workdir='wkdir/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
+            + Expect.behavior(uploadString('mozilla/browser/'))
+            + 0,
             ExpectShell(workdir='wkdir',
                         command=['cvs', '-z3', 'update', '-dP'])
             + 0,
@@ -156,9 +227,16 @@ def test_mode_incremental_not_loggedin(self):
                                  ':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot',
                                  'login'])
             + 0,
-            Expect('stat', dict(file='wkdir/CVS',
-                                logEnviron=True))
-            + 0,            
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Root', workdir='wkdir/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
+            + Expect.behavior(uploadString(':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot'))
+            + 0,
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Repository', workdir='wkdir/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
+            + Expect.behavior(uploadString('mozilla/browser/'))
+            + 0,
             ExpectShell(workdir='wkdir',
                         command=['cvs', '-z3', 'update', '-dP'])
             + 0,
@@ -177,9 +255,74 @@ def test_mode_incremental_no_existing_repo(self):
             ExpectShell(workdir='wkdir',
                         command=['cvs', '--version'])
             + 0,
-            Expect('stat', dict(file='wkdir/CVS',
-                                logEnviron=True))
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Root', workdir='wkdir/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
             + 1,
+            Expect('rmdir', dict(dir='wkdir',
+                                 logEnviron=True))
+            + 0,
+            ExpectShell(workdir='',
+                        command=['cvs',
+                                 '-d',
+                                 ':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot',
+                                 '-z3', 'checkout', '-d', 'wkdir', 'mozilla/browser/'])
+            + 0,
+            )
+        self.expectOutcome(result=SUCCESS, status_text=["update"])
+        return self.runStep()
+
+
+    def test_mode_incremental_wrong_repo(self):
+        self.setupStep(
+            cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
+                    cvsmodule="mozilla/browser/", mode='incremental',
+                    login=True))
+        self.expectCommands(
+            ExpectShell(workdir='wkdir',
+                        command=['cvs', '--version'])
+            + 0,
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Root', workdir='wkdir/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
+            + Expect.behavior(uploadString('the-end-of-the-universe'))
+            + 0,
+            Expect('rmdir', dict(dir='wkdir',
+                                 logEnviron=True))
+            + 0,
+            ExpectShell(workdir='',
+                        command=['cvs',
+                                 '-d',
+                                 ':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot',
+                                 '-z3', 'checkout', '-d', 'wkdir', 'mozilla/browser/'])
+            + 0,
+            )
+        self.expectOutcome(result=SUCCESS, status_text=["update"])
+        return self.runStep()
+
+
+    def test_mode_incremental_wrong_module(self):
+        self.setupStep(
+            cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
+                    cvsmodule="mozilla/browser/", mode='incremental',
+                    login=True))
+        self.expectCommands(
+            ExpectShell(workdir='wkdir',
+                        command=['cvs', '--version'])
+            + 0,
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Root', workdir='wkdir/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
+            + Expect.behavior(uploadString(':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot'))
+            + 0,
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Repository', workdir='wkdir/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
+            + Expect.behavior(uploadString('the-end-of-the-universe'))
+            + 0,
+            Expect('rmdir', dict(dir='wkdir',
+                                 logEnviron=True))
+            + 0,
             ExpectShell(workdir='',
                         command=['cvs',
                                  '-d',
@@ -200,8 +343,9 @@ def test_mode_full_clean_no_existing_repo(self):
             ExpectShell(workdir='wkdir',
                         command=['cvs', '--version'])
             + 0,
-            Expect('stat', dict(file='wkdir/CVS',
-                                logEnviron=True))
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Root', workdir='wkdir/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
             + 1,
             ExpectShell(workdir='',
                         command=['cvs',
@@ -213,6 +357,30 @@ def test_mode_full_clean_no_existing_repo(self):
         self.expectOutcome(result=SUCCESS, status_text=["update"])
         return self.runStep()
 
+    def test_mode_full_clean_wrong_repo(self):
+        self.setupStep(
+            cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
+                    cvsmodule="mozilla/browser/", mode='full', method='clean',
+                    login=True))
+        self.expectCommands(
+            ExpectShell(workdir='wkdir',
+                        command=['cvs', '--version'])
+            + 0,
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Root', workdir='wkdir/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
+            + Expect.behavior(uploadString('the-end-of-the-universe'))
+            + 0,
+            ExpectShell(workdir='',
+                        command=['cvs',
+                                 '-d',
+                                 ':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot',
+                                 '-z3', 'checkout', '-d', 'wkdir', 'mozilla/browser/'])
+            + 0,
+            )
+        self.expectOutcome(result=SUCCESS, status_text=["update"])
+        return self.runStep()
+
     def test_mode_full_no_method(self):
         self.setupStep(
             cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
@@ -222,8 +390,15 @@ def test_mode_full_no_method(self):
             ExpectShell(workdir='wkdir',
                         command=['cvs', '--version'])
             + 0,
-            Expect('stat', dict(file='wkdir/CVS',
-                                logEnviron=True))
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Root', workdir='wkdir/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
+            + Expect.behavior(uploadString(':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot'))
+            + 0,
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Repository', workdir='wkdir/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
+            + Expect.behavior(uploadString('mozilla/browser/'))
             + 0,
             ExpectShell(workdir='wkdir',
                         command=['cvsdiscard', '--ignore'])
@@ -245,13 +420,17 @@ def test_mode_incremental_with_options(self):
             ExpectShell(workdir='wkdir',
                         command=['cvs', '--version'])
             + 0,
-            Expect('stat', dict(file='wkdir/CVS',
-                                logEnviron=True))
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Root', workdir='wkdir/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
             + 1,
+            Expect('rmdir', dict(dir='wkdir',
+                                 logEnviron=True))
+            + 0,
             ExpectShell(workdir='',
                         command=['cvs', '-q', '-d',
                                  ':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot',
-                                 '-z3', 'checkout', '-d', 'wkdir', 'mozilla/browser/', '-l'])
+                                 '-z3', 'checkout', '-d', 'wkdir', '-l', 'mozilla/browser/'])
             + 0,
             )
         self.expectOutcome(result=SUCCESS, status_text=["update"])
@@ -268,8 +447,15 @@ def test_mode_incremental_with_env_logEnviron(self):
                         env={'abc': '123'},
                         logEnviron=False)
             + 0,
-            Expect('stat', dict(file='wkdir/CVS',
-                                logEnviron=False))
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Root', workdir='wkdir/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
+            + Expect.behavior(uploadString(':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot'))
+            + 0,
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Repository', workdir='wkdir/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
+            + Expect.behavior(uploadString('mozilla/browser/'))
             + 0,
             ExpectShell(workdir='wkdir',
                         command=['cvs', '-z3', 'update', '-dP'],
@@ -304,8 +490,15 @@ def test_cvsdiscard_fails(self):
             ExpectShell(workdir='wkdir',
                         command=['cvs', '--version'])
             + 0,
-            Expect('stat', dict(file='wkdir/CVS',
-                                logEnviron=True))
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Root', workdir='wkdir/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
+            + Expect.behavior(uploadString(':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot'))
+            + 0,
+            Expect('uploadFile', dict(blocksize=32768, maxsize=None,
+                        slavesrc='Repository', workdir='wkdir/CVS',
+                        writer=ExpectRemoteRef(shell.StringFileWriter)))
+            + Expect.behavior(uploadString('mozilla/browser/'))
             + 0,
             ExpectShell(workdir='wkdir',
                         command=['cvsdiscard', '--ignore'])