Rev 3801: Change the mocking a bit, so we can be sure it is failing at the right time. in http://bzr.arbash-meinel.com/branches/bzr/1.9-dev/pack_retry_153786
John Arbash Meinel
john at arbash-meinel.com
Fri Oct 24 21:31:31 BST 2008
At http://bzr.arbash-meinel.com/branches/bzr/1.9-dev/pack_retry_153786
------------------------------------------------------------
revno: 3801
revision-id: john at arbash-meinel.com-20081024203126-koei1a77u0qa4abq
parent: john at arbash-meinel.com-20081024202643-1n4w1g6mg2jgb9r0
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: pack_retry_153786
timestamp: Fri 2008-10-24 15:31:26 -0500
message:
Change the mocking a bit, so we can be sure it is failing at the right time.
-------------- next part --------------
=== modified file 'bzrlib/tests/test_knit.py'
--- a/bzrlib/tests/test_knit.py 2008-10-24 20:26:43 +0000
+++ b/bzrlib/tests/test_knit.py 2008-10-24 20:31:26 +0000
@@ -273,16 +273,18 @@
class MockReadvFailingTransport(MockTransport):
"""Fail in the middle of a readv() result.
- This Transport will successfully yield the first requested hunk, but raise
- NoSuchFile for the rest.
+ This Transport will successfully yield the first two requested hunks, but
+ raise NoSuchFile for the rest.
"""
def readv(self, relpath, offsets):
- first = True
+ count = 0
for result in MockTransport.readv(self, relpath, offsets):
- if not first:
+ count += 1
+ # we use 2 because the first offset is the pack header, the second
+ # is the first actual content requset
+ if count > 2:
raise errors.NoSuchFile(relpath)
- first = False
yield result
@@ -422,8 +424,13 @@
transport = self.get_transport()
failing_transport = MockReadvFailingTransport(
[transport.get_bytes('packname')])
- # The readv() will fail mid-way through
access = _DirectPackAccess({'foo':(failing_transport, 'packname')})
+ # Asking for a single record will not trigger the Mock failure
+ self.assertEqual(['1234567890'],
+ list(access.get_raw_records(memos[:1])))
+ self.assertEqual(['12345'],
+ list(access.get_raw_records(memos[1:2])))
+ # A multiple offset readv() will fail mid-way through
e = self.assertListRaises(errors.RetryWithNewPacks,
access.get_raw_records, memos)
# The file has gone missing, so we assume we need to reload
More information about the bazaar-commits
mailing list