Merge lp:~vila/bzr/807032-broken-pack-failure into lp:bzr

Proposed by Vincent Ladeuil
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merged at revision: 6162
Proposed branch: lp:~vila/bzr/807032-broken-pack-failure
Merge into: lp:bzr
Diff against target: 43 lines (+17/-4)
2 files modified
bzrlib/tests/blackbox/test_branch.py (+14/-4)
doc/en/release-notes/bzr-2.5.txt (+3/-0)
To merge this branch: bzr merge lp:~vila/bzr/807032-broken-pack-failure
Reviewer Review Type Date Requested Status
Jelmer Vernooij (community) Approve
Review via email: mp+76614@code.launchpad.net

Commit message

Get rid of randomness in blackbox.test_branch.TestBranch.test_branch_broken_pack

Description of the change

Since I was bitten again by a random pqm failure, I decided to try fixing
bug #807032: a random failure of
blackbox.test_branch.TestBranch.test_branch_broken_pack.

I haven't been able to reproduce the failure so I guessed (the diff displays
the whole test so I won't repeat it here):

- the pack file is less than 750 so writing there has no effect,

- the file already contains '\xFF' at this position.

I avoid both of the issues by chosing a place from the end of the file and
making sure I'm changing the value found there.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 09/22/2011 06:40 PM, Vincent Ladeuil wrote:
> Vincent Ladeuil has proposed merging lp:~vila/bzr/807032-broken-pack-failure into lp:bzr.
>
> Requested reviews:
> bzr-core (bzr-core)
> Related bugs:
> Bug #807032 in Bazaar: "blackbox.test_branch.TestBranch.test_branch_broken_pack can (and did) fail ramdonly on pqm"
> https://bugs.launchpad.net/bzr/+bug/807032
>
> For more details, see:
> https://code.launchpad.net/~vila/bzr/807032-broken-pack-failure/+merge/76614
>
> Since I was bitten again by a random pqm failure, I decided to try fixing
> bug #807032: a random failure of
> blackbox.test_branch.TestBranch.test_branch_broken_pack.
>
> I haven't been able to reproduce the failure so I guessed (the diff displays
> the whole test so I won't repeat it here):
>
> - the pack file is less than 750 so writing there has no effect,
>
> - the file already contains '\xFF' at this position.
>
> I avoid both of the issues by chosing a place from the end of the file and
> making sure I'm changing the value found there.

I would tend to say we should just try to write a few bytes. If you
write something like 100 bytes of \xFF you're pretty sure it will fail.

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk57bF8ACgkQJdeBCYSNAANwDQCdEgJqYi81M6fu7THdr266o2ZP
rf4An2/REVukY4AQhv9xrY6jk0WlKPSg
=0ekB
-----END PGP SIGNATURE-----

Revision history for this message
Vincent Ladeuil (vila) wrote :

> I would tend to say we should just try to write a few bytes. If you
> write something like 100 bytes of \xFF you're pretty sure it will fail.

Well, we were "pretty sure" with writing \xFF once and we were wrong. Writing it 100 times will make us even more almost sure, but still open to failure. It looks like I've been the unlucky guy twice here, I fail to see why I won't be hit again by bad luck :)

Revision history for this message
Vincent Ladeuil (vila) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/tests/blackbox/test_branch.py'
2--- bzrlib/tests/blackbox/test_branch.py 2011-09-16 15:37:58 +0000
3+++ bzrlib/tests/blackbox/test_branch.py 2011-09-22 16:39:23 +0000
4@@ -66,11 +66,21 @@
5 def test_branch_broken_pack(self):
6 """branching with a corrupted pack file."""
7 self.example_branch('a')
8- #now add some random corruption
9- fname = 'a/.bzr/repository/packs/' + os.listdir('a/.bzr/repository/packs')[0]
10+ # add some corruption
11+ packs_dir = 'a/.bzr/repository/packs/'
12+ fname = packs_dir + os.listdir(packs_dir)[0]
13 with open(fname, 'rb+') as f:
14- f.seek(750)
15- f.write("\xff")
16+ # Start from the end of the file to avoid choosing a place bigger
17+ # than the file itself.
18+ f.seek(-5, os.SEEK_END)
19+ c = f.read(1)
20+ f.seek(-5, os.SEEK_END)
21+ # Make sure we inject a value different than the one we just read
22+ if c == '\xFF':
23+ corrupt = '\x00'
24+ else:
25+ corrupt = '\xFF'
26+ f.write(corrupt) # make sure we corrupt something
27 self.run_bzr_error(['Corruption while decompressing repository file'],
28 'branch a b', retcode=3)
29
30
31=== modified file 'doc/en/release-notes/bzr-2.5.txt'
32--- doc/en/release-notes/bzr-2.5.txt 2011-09-22 12:13:12 +0000
33+++ doc/en/release-notes/bzr-2.5.txt 2011-09-22 16:39:23 +0000
34@@ -67,6 +67,9 @@
35 suite. This can include new facilities for writing tests, fixes to
36 spurious test failures and changes to the way things should be tested.
37
38+* Really corrupt the pack file without depending on a special length or value.
39+ (Vincent Ladeuil, #807032)
40+
41
42 bzr 2.5b1
43 #########