Remove git lockfile flakiness on win (bot_update)

Hypothesis: Sometimes bot update fails because windows fails to delete
a lockfile associated with a git process.

Test: If this happens, let's delete that lockfile and try again.

BUG=651602

Review-Url: https://codereview.chromium.org/2382653005
changes/18/399118/1
katthomas 9 years ago committed by Commit bot
parent bda914b8c3
commit df66a34f68

@ -322,7 +322,7 @@ def gclient_configure(solutions, target_os, target_os_only, git_cache_dir):
solutions, target_os, target_os_only, git_cache_dir))
def gclient_sync(with_branch_heads, shallow):
def gclient_sync(with_branch_heads, shallow, break_repo_locks):
# We just need to allocate a filename.
fd, gclient_output_file = tempfile.mkstemp(suffix='.json')
os.close(fd)
@ -334,6 +334,8 @@ def gclient_sync(with_branch_heads, shallow):
cmd += ['--with_branch_heads']
if shallow:
cmd += ['--shallow']
if break_repo_locks:
cmd += ['--break_repo_locks']
try:
call(*cmd, tries=1)
@ -753,10 +755,14 @@ def ensure_checkout(solutions, revisions, first_sln, target_os, target_os_only,
# Ensure our build/ directory is set up with the correct .gclient file.
gclient_configure(solutions, target_os, target_os_only, git_cache_dir)
# Windows sometimes has trouble deleting files. This can make git commands
# that rely on locks fail.
break_repo_locks = True if sys.platform.startswith('win') else False
# Let gclient do the DEPS syncing.
# The branch-head refspec is a special case because its possible Chrome
# src, which contains the branch-head refspecs, is DEPSed in.
gclient_output = gclient_sync(BRANCH_HEADS_REFSPEC in refs, shallow)
gclient_output = gclient_sync(BRANCH_HEADS_REFSPEC in refs, shallow,
break_repo_locks)
# Now that gclient_sync has finished, we should revert any .DEPS.git so that
# presubmit doesn't complain about it being modified.

@ -15,7 +15,6 @@ import unittest
sys.path.insert(0, os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
'recipe_modules', 'bot_update', 'resources'))
sys.platform = 'linux2' # For consistency, ya know?
import bot_update
DEFAULT_PARAMS = {
@ -164,6 +163,7 @@ def fake_git(*args, **kwargs):
class BotUpdateUnittests(unittest.TestCase):
def setUp(self):
sys.platform = 'linux2' # For consistency, ya know?
self.filesystem = FakeFilesystem()
self.call = MockedCall(self.filesystem)
self.gclient = MockedGclientSync(self.filesystem)
@ -195,6 +195,17 @@ class BotUpdateUnittests(unittest.TestCase):
bot_update.ensure_checkout(**self.params)
return self.call.records
def testBreakLocks(self):
sys.platform = 'win'
self.call.expect(('gclient.bat', 'sync')).returns(self.gclient)
bot_update.ensure_checkout(**self.params)
gclient_sync_cmd = None
for record in self.call.records:
args = record[0]
if args[0] == 'gclient.bat' and args[1] == 'sync':
gclient_sync_cmd = args
self.assertTrue('--break_repo_locks' in gclient_sync_cmd)
if __name__ == '__main__':
unittest.main()

Loading…
Cancel
Save