Skip to content

Commit

Permalink
fix login functionality for master side CVS source checkout step
Browse files Browse the repository at this point in the history
* perform login only when password is provided
* do actually use the password
* fix the test cases (for vast majority remove use of login parameter)
* update docs to document the `login` parameter
  • Loading branch information
Mikhail Sobolev committed Mar 1, 2015
1 parent 03c55d8 commit 5f7145c
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 66 deletions.
20 changes: 9 additions & 11 deletions master/buildbot/steps/source/cvs.py
Expand Up @@ -253,27 +253,25 @@ def _gotResults(results):

def checkLogin(self, _):
if self.login:
d = defer.succeed(0)
d = self._dovccmd(['-d', self.cvsroot, 'login'],
initialStdin=self.login + "\n")
else:
d = self._dovccmd(['-d', self.cvsroot, 'login'])
d = defer.succeed(0)

@d.addCallback
def setLogin(res):
# this happens only if the login command succeeds.
self.login = True
return res
return d

def _dovccmd(self, command, workdir=None, abandonOnFailure=True):
def _dovccmd(self, command, workdir=None, abandonOnFailure=True,
initialStdin=None):
if workdir is None:
workdir = self.workdir
if not command:
raise ValueError("No command specified")
cmd = remotecommand.RemoteShellCommand(workdir, ['cvs'] +
command,
cmd = remotecommand.RemoteShellCommand(workdir,
['cvs'] + command,
env=self.env,
timeout=self.timeout,
logEnviron=self.logEnviron)
logEnviron=self.logEnviron,
initialStdin=initialStdin)
cmd.useLog(self.stdio_log, False)
d = self.runCommand(cmd)

Expand Down
95 changes: 40 additions & 55 deletions master/buildbot/test/unit/test_steps_source_cvs.py
Expand Up @@ -78,15 +78,22 @@ def test_cvsEntriesContainStickyDates(self):
self.assertEqual(step._cvsEntriesContainStickyDates('/file/1.1/Fri May 17 23:20:00//D2013.10.08.11.20.33\nD'), True)
self.assertEqual(step._cvsEntriesContainStickyDates('/file1/1.1/Fri May 17 23:20:00//\n/file2/1.1.2.3/Fri May 17 23:20:00//D2013.10.08.11.20.33\nD'), True)

def test_mode_full_clean(self):
def test_mode_full_clean_and_login(self):
self.setupStep(
cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='full', method='clean',
login=True))
login="a password"))
self.expectCommands(
ExpectShell(workdir='wkdir',
command=['cvs', '--version'])
+ 0,
ExpectShell(workdir='wkdir',
command=['cvs',
'-d',
':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot',
'login'],
initialStdin="a password\n")
+ 0,
Expect('stat', dict(file='wkdir/.buildbot-patched',
logEnviron=True))
+ 1,
Expand Down Expand Up @@ -120,8 +127,8 @@ def test_mode_full_clean(self):
def test_mode_full_clean_patch(self):
self.setupStep(
cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='full', method='clean',
login=True), patch=(1, 'patch'))
cvsmodule="mozilla/browser/", mode='full', method='clean'),
patch=(1, 'patch'))
self.expectCommands(
ExpectShell(workdir='wkdir',
command=['cvs', '--version'])
Expand Down Expand Up @@ -179,7 +186,7 @@ def test_mode_full_clean_timeout(self):
self.setupStep(
cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='full', method='clean',
login=True, timeout=1))
timeout=1))
self.expectCommands(
ExpectShell(workdir='wkdir',
timeout=1,
Expand Down Expand Up @@ -221,7 +228,7 @@ def test_mode_full_clean_branch(self):
self.setupStep(
cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='full', method='clean',
branch='branch', login=True))
branch='branch'))
self.expectCommands(
ExpectShell(workdir='wkdir',
command=['cvs', '--version'])
Expand Down Expand Up @@ -259,8 +266,8 @@ def test_mode_full_clean_branch(self):
def test_mode_full_clean_branch_sourcestamp(self):
self.setupStep(
cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='full', method='clean',
login=True), args={'branch': 'my_branch'})
cvsmodule="mozilla/browser/", mode='full', method='clean'),
args={'branch': 'my_branch'})
self.expectCommands(
ExpectShell(workdir='wkdir',
command=['cvs', '--version'])
Expand Down Expand Up @@ -298,8 +305,7 @@ def test_mode_full_clean_branch_sourcestamp(self):
def test_mode_full_fresh(self):
self.setupStep(
cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='full', method='fresh',
login=True))
cvsmodule="mozilla/browser/", mode='full', method='fresh'))
self.expectCommands(
ExpectShell(workdir='wkdir',
command=['cvs', '--version'])
Expand Down Expand Up @@ -336,8 +342,7 @@ def test_mode_full_fresh(self):

def test_mode_full_clobber(self):
step = cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='full', method='clobber',
login=True)
cvsmodule="mozilla/browser/", mode='full', method='clobber')
self.setupStep(step)
self.expectCommands(
ExpectShell(workdir='wkdir',
Expand Down Expand Up @@ -365,7 +370,7 @@ def test_mode_full_clobber(self):
def test_mode_full_clobber_retry(self):
step = cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='full', method='clobber',
login=True, retry=(0, 2))
retry=(0, 2))
self.setupStep(step)
self.expectCommands(
ExpectShell(workdir='wkdir',
Expand Down Expand Up @@ -412,8 +417,7 @@ def test_mode_full_clobber_retry(self):

def test_mode_full_copy(self):
step = cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='full', method='copy',
login=True)
cvsmodule="mozilla/browser/", mode='full', method='copy')
self.setupStep(step)
self.expectCommands(
ExpectShell(workdir='wkdir',
Expand Down Expand Up @@ -455,8 +459,7 @@ def test_mode_full_copy(self):

def test_mode_full_copy_wrong_repo(self):
step = cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='full', method='copy',
login=True)
cvsmodule="mozilla/browser/", mode='full', method='copy')
self.setupStep(step)
self.expectCommands(
ExpectShell(workdir='wkdir',
Expand Down Expand Up @@ -496,8 +499,7 @@ def test_mode_full_copy_wrong_repo(self):
def test_mode_incremental(self):
self.setupStep(
cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='incremental',
login=True))
cvsmodule="mozilla/browser/", mode='incremental'))
self.expectCommands(
ExpectShell(workdir='wkdir',
command=['cvs', '--version'])
Expand Down Expand Up @@ -531,8 +533,7 @@ def test_mode_incremental(self):

def test_mode_incremental_sticky_date(self):
step = cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='incremental',
login=True)
cvsmodule="mozilla/browser/", mode='incremental')
self.setupStep(step)
self.expectCommands(
ExpectShell(workdir='wkdir',
Expand Down Expand Up @@ -575,8 +576,7 @@ def test_mode_incremental_sticky_date(self):
def test_mode_incremental_password_windows(self):
self.setupStep(
cvs.CVS(cvsroot=":pserver:dustin:secrets@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='incremental',
login=True))
cvsmodule="mozilla/browser/", mode='incremental'))
self.expectCommands(
ExpectShell(workdir='wkdir',
command=['cvs', '--version'])
Expand Down Expand Up @@ -613,7 +613,7 @@ def test_mode_incremental_branch(self):
self.setupStep(
cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='incremental',
branch='my_branch', login=True))
branch='my_branch'))
self.expectCommands(
ExpectShell(workdir='wkdir',
command=['cvs', '--version'])
Expand Down Expand Up @@ -649,7 +649,7 @@ def test_mode_incremental_special_case(self):
self.setupStep(
cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='incremental',
branch='HEAD', login=True),
branch='HEAD'),
args=dict(revision='2012-08-16 16:05:16 +0000'))
self.expectCommands(
ExpectShell(workdir='wkdir',
Expand Down Expand Up @@ -686,8 +686,8 @@ def test_mode_incremental_special_case(self):
def test_mode_incremental_branch_sourcestamp(self):
self.setupStep(
cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='incremental',
login=True), args={'branch': 'my_branch'})
cvsmodule="mozilla/browser/", mode='incremental'),
args={'branch': 'my_branch'})
self.expectCommands(
ExpectShell(workdir='wkdir',
command=['cvs', '--version'])
Expand Down Expand Up @@ -722,17 +722,11 @@ def test_mode_incremental_branch_sourcestamp(self):
def test_mode_incremental_not_loggedin(self):
self.setupStep(
cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='incremental',
login=False))
cvsmodule="mozilla/browser/", mode='incremental'))
self.expectCommands(
ExpectShell(workdir='wkdir',
command=['cvs', '--version'])
+ 0,
ExpectShell(workdir='wkdir',
command=['cvs', '-d',
':pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot',
'login'])
+ 0,
Expect('stat', dict(file='wkdir/.buildbot-patched',
logEnviron=True))
+ 1,
Expand Down Expand Up @@ -762,8 +756,7 @@ def test_mode_incremental_not_loggedin(self):

def test_mode_incremental_no_existing_repo(self):
step = cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='incremental',
login=True)
cvsmodule="mozilla/browser/", mode='incremental')
self.setupStep(step)
self.expectCommands(
ExpectShell(workdir='wkdir',
Expand Down Expand Up @@ -794,7 +787,7 @@ def test_mode_incremental_no_existing_repo(self):
def test_mode_incremental_retry(self):
step = cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='incremental',
login=True, retry=(0, 1))
retry=(0, 1))
self.setupStep(step)
self.expectCommands(
ExpectShell(workdir='wkdir',
Expand Down Expand Up @@ -834,8 +827,7 @@ def test_mode_incremental_retry(self):

def test_mode_incremental_wrong_repo(self):
step = cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='incremental',
login=True)
cvsmodule="mozilla/browser/", mode='incremental')
self.setupStep(step)
self.expectCommands(
ExpectShell(workdir='wkdir',
Expand Down Expand Up @@ -866,8 +858,7 @@ def test_mode_incremental_wrong_repo(self):

def test_mode_incremental_wrong_module(self):
step = cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='incremental',
login=True)
cvsmodule="mozilla/browser/", mode='incremental')
self.setupStep(step)
self.expectCommands(
ExpectShell(workdir='wkdir',
Expand Down Expand Up @@ -904,8 +895,7 @@ def test_mode_incremental_wrong_module(self):
def test_mode_full_clean_no_existing_repo(self):
self.setupStep(
cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='full', method='clean',
login=True))
cvsmodule="mozilla/browser/", mode='full', method='clean'))
self.expectCommands(
ExpectShell(workdir='wkdir',
command=['cvs', '--version'])
Expand All @@ -931,8 +921,7 @@ def test_mode_full_clean_no_existing_repo(self):
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))
cvsmodule="mozilla/browser/", mode='full', method='clean'))
self.expectCommands(
ExpectShell(workdir='wkdir',
command=['cvs', '--version'])
Expand All @@ -959,8 +948,7 @@ def test_mode_full_clean_wrong_repo(self):
def test_mode_full_no_method(self):
self.setupStep(
cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='full',
login=True))
cvsmodule="mozilla/browser/", mode='full'))
self.expectCommands(
ExpectShell(workdir='wkdir',
command=['cvs', '--version'])
Expand Down Expand Up @@ -998,7 +986,7 @@ def test_mode_full_no_method(self):
def test_mode_incremental_with_options(self):
step = cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='incremental',
login=True, global_options=['-q'], extra_options=['-l'])
global_options=['-q'], extra_options=['-l'])
self.setupStep(step)
self.expectCommands(
ExpectShell(workdir='wkdir',
Expand Down Expand Up @@ -1029,7 +1017,7 @@ def test_mode_incremental_with_env_logEnviron(self):
self.setupStep(
cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='incremental',
login=True, env={'abc': '123'}, logEnviron=False))
env={'abc': '123'}, logEnviron=False))
self.expectCommands(
ExpectShell(workdir='wkdir',
command=['cvs', '--version'],
Expand Down Expand Up @@ -1068,8 +1056,7 @@ def test_mode_incremental_with_env_logEnviron(self):
def test_command_fails(self):
self.setupStep(
cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='incremental',
login=True))
cvsmodule="mozilla/browser/", mode='incremental'))
self.expectCommands(
ExpectShell(workdir='wkdir',
command=['cvs', '--version'])
Expand All @@ -1082,8 +1069,7 @@ def test_command_fails(self):
def test_cvsdiscard_fails(self):
self.setupStep(
cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='full', method='fresh',
login=True))
cvsmodule="mozilla/browser/", mode='full', method='fresh'))
self.expectCommands(
ExpectShell(workdir='wkdir',
command=['cvs', '--version'])
Expand Down Expand Up @@ -1119,8 +1105,7 @@ def test_cvsdiscard_fails(self):
def test_slave_connection_lost(self):
self.setupStep(
cvs.CVS(cvsroot=":pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot",
cvsmodule="mozilla/browser/", mode='full', method='clean',
login=True))
cvsmodule="mozilla/browser/", mode='full', method='clean'))
self.expectCommands(
ExpectShell(workdir='wkdir',
command=['cvs', '--version'])
Expand Down
4 changes: 4 additions & 0 deletions master/docs/manual/cfg-buildsteps.rst
Expand Up @@ -583,6 +583,10 @@ This step takes the following arguments:
This maintains a ``source`` directory for source, which it updates copies to the build directory.
This allows Buildbot to start with a fresh directory, without downloading the entire repository on every build.

``login``
Password to use while performing login to the remote CVS server.
Default is ``None`` meaning that no login needs to be peformed.

.. bb:step:: Bzr
.. _Step-Bzr:
Expand Down

0 comments on commit 5f7145c

Please sign in to comment.