Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(770)

Side by Side Diff: buildbot/cbuildbot_commands_unittest.py

Issue 6771036: Change RepoSync to use -j4 option. Add tests to check for retries. (Closed) Base URL: http://git.chromium.org/git/chromite.git@master
Patch Set: make reviewer requested changes Created 9 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « buildbot/cbuildbot_commands.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. 3 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Unittests for commands. Needs to be run inside of chroot for mox.""" 7 """Unittests for commands. Needs to be run inside of chroot for mox."""
8 8
9 import __builtin__ 9 import __builtin__
10 import mox 10 import mox
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 binhosts = [binhost, None] 102 binhosts = [binhost, None]
103 check = mox.And(mox.IsA(list), mox.In(binhost), mox.Not(mox.In(None)), 103 check = mox.And(mox.IsA(list), mox.In(binhost), mox.Not(mox.In(None)),
104 mox.In('chromeos-images:/var/www/prebuilt/'), 104 mox.In('chromeos-images:/var/www/prebuilt/'),
105 mox.In('chrome')) 105 mox.In('chrome'))
106 cros_lib.OldRunCommand(check, cwd=os.path.dirname(commands.__file__)) 106 cros_lib.OldRunCommand(check, cwd=os.path.dirname(commands.__file__))
107 self.mox.ReplayAll() 107 self.mox.ReplayAll()
108 commands.UploadPrebuilts(self._buildroot, self._test_board, 'private', 108 commands.UploadPrebuilts(self._buildroot, self._test_board, 'private',
109 binhosts, 'chrome', 'tot') 109 binhosts, 'chrome', 'tot')
110 self.mox.VerifyAll() 110 self.mox.VerifyAll()
111 111
112 def testRepoSyncRetriesFail(self):
113 """Case where we exceed default retry attempts."""
114 cros_lib.OldRunCommand(mox.In('sync'),
115 cwd=self._buildroot).AndRaise(Exception("failed"))
116 cros_lib.OldRunCommand(mox.In('sync'),
117 cwd=self._buildroot).AndRaise(Exception("failed"))
118 cros_lib.OldRunCommand(mox.In('sync'),
119 cwd=self._buildroot).AndRaise(Exception("failed"))
120 self.mox.ReplayAll()
121 self.assertRaises(Exception, lambda: commands._RepoSync(self._buildroot))
122 self.mox.VerifyAll()
123
124 def testRepoSyncRetriesPass(self):
125 """Case where we fail twice and pass on the third try."""
126 cros_lib.OldRunCommand(mox.In('sync'),
127 cwd=self._buildroot).AndRaise(Exception("failed"))
128 cros_lib.OldRunCommand(mox.In('sync'),
129 cwd=self._buildroot).AndRaise(Exception("failed"))
130 cros_lib.OldRunCommand(mox.In('sync'), cwd=self._buildroot)
131 cros_lib.OldRunCommand(mox.In('forall'), cwd=self._buildroot)
132 cros_lib.OldRunCommand(mox.In('manifest'), cwd=self._buildroot)
133 self.mox.ReplayAll()
134 commands._RepoSync(self._buildroot)
135 self.mox.VerifyAll()
136
137 def testRepoSyncCustomRetriesFail(self):
138 """Case where _RepoSync is called with a custom retry value of 1. Should
139 throw exception after first failure."""
140 cros_lib.OldRunCommand(mox.In('sync'),
141 cwd=self._buildroot).AndRaise(Exception("failed"))
142 self.mox.ReplayAll()
143 self.assertRaises(
144 Exception,
145 lambda: commands._RepoSync(self._buildroot, retries=1))
146 self.mox.VerifyAll()
147
148 def testRepoSyncCustomRetriesPass(self):
149 """Case where _RepoSync is called with a custom retry value of 2 and passes
150 the second time."""
151 cros_lib.OldRunCommand(mox.In('sync'),
152 cwd=self._buildroot).AndRaise(Exception("failed"))
153 cros_lib.OldRunCommand(mox.In('sync'), cwd=self._buildroot)
154 cros_lib.OldRunCommand(mox.In('forall'), cwd=self._buildroot)
155 cros_lib.OldRunCommand(mox.In('manifest'), cwd=self._buildroot)
156 self.mox.ReplayAll()
157 commands._RepoSync(self._buildroot, retries=2)
158 self.mox.VerifyAll()
159
112 160
113 if __name__ == '__main__': 161 if __name__ == '__main__':
114 unittest.main() 162 unittest.main()
OLDNEW
« no previous file with comments | « buildbot/cbuildbot_commands.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698