comparison tests/test-cache-abuse.t @ 29041:b962ae0a0a05 stable

tests: test a variety of cache invariants We've historically had a problem maintaining the expected invariants on our caches, especially when introducing new caches. This tests documents the invariants and exercises them across most of our existing cache files.
author Matt Mackall <mpm@selenic.com>
date Thu, 28 Apr 2016 16:38:15 -0500
parents
children b0b85d8695cb
comparison
equal deleted inserted replaced
29040:a4dc5fe7bf54 29041:b962ae0a0a05
1 Enable obsolete markers
2
3 $ cat >> $HGRCPATH << EOF
4 > [experimental]
5 > evolution=createmarkers
6 > [phases]
7 > publish=False
8 > EOF
9
10 Build a repo with some cacheable bits:
11
12 $ hg init a
13 $ cd a
14
15 $ echo a > a
16 $ hg ci -qAm0
17 $ hg tag t1
18 $ hg book -i bk1
19
20 $ hg branch -q b2
21 $ hg ci -Am1
22 $ hg tag t2
23
24 $ echo dumb > dumb
25 $ hg ci -qAmdumb
26 $ hg debugobsolete b1174d11b69e63cb0c5726621a43c859f0858d7f
27
28 $ hg phase -pr t1
29 $ hg phase -fsr t2
30
31 Make a helper function to check cache damage invariants:
32
33 - command output shouldn't change
34 - cache should be present after first use
35 - corruption/repair should be silent (no exceptions or warnings)
36 - cache should survive deletion, overwrite, and append
37 - unreadable / unwriteable caches should be ignored
38 - cache should be rebuilt after corruption
39
40 $ damage() {
41 > CMD=$1
42 > CACHE=.hg/cache/$2
43 > CLEAN=$3
44 > hg $CMD > before
45 > test -f $CACHE || echo "not present"
46 > echo bad > $CACHE
47 > test -z "$CLEAN" || $CLEAN
48 > hg $CMD > after
49 > diff -u before after || echo "*** overwrite corruption"
50 > echo corruption >> $CACHE
51 > test -z "$CLEAN" || $CLEAN
52 > hg $CMD > after
53 > diff -u before after || echo "*** append corruption"
54 > rm $CACHE
55 > mkdir $CACHE
56 > test -z "$CLEAN" || $CLEAN
57 > hg $CMD > after
58 > diff -u before after || echo "*** read-only corruption"
59 > test -d $CACHE || echo "*** directory clobbered"
60 > rmdir $CACHE
61 > test -z "$CLEAN" || $CLEAN
62 > hg $CMD > after
63 > diff -u before after || echo "*** missing corruption"
64 > test -f $CACHE || echo "not rebuilt"
65 > }
66
67 Beat up tags caches:
68
69 $ damage "tags --hidden" tags2
70 $ damage tags tags2-visible
71 $ damage "tag -f t3" hgtagsfnodes1
72
73 Beat up hidden cache:
74
75 $ damage log hidden
76
77 Beat up branch caches:
78
79 $ damage branches branch2-base "rm .hg/cache/branch2-[vs]*"
80 $ damage branches branch2-served "rm .hg/cache/branch2-[bv]*"
81 $ damage branches branch2-visible
82 $ damage "log -r branch(.)" rbc-names-v1
83 $ damage "log -r branch(default)" rbc-names-v1
84 $ damage "log -r branch(b2)" rbc-revs-v1
85
86 We currently can't detect an rbc cache with unknown names:
87
88 $ damage "log -qr branch(b2)" rbc-names-v1
89 --- before * (glob)
90 +++ after * (glob)
91 @@ -1,8 +0,0 @@
92 -2:5fb7d38b9dc4
93 -3:60b597ffdafa
94 -4:b1174d11b69e
95 -5:6354685872c0
96 -6:5ebc725f1bef
97 -7:7b76eec2f273
98 -8:ef3428d9d644
99 -9:ba7a936bc03c
100 *** append corruption