Mercurial > evolve
comparison tests/test-cache-corruption.t @ 5868:c61e1577c62f stable
tests: add a separate test file to test cache corruption and recovery
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Mon, 05 Apr 2021 16:35:47 +0800 |
parents | |
children | 5435777c307c |
comparison
equal
deleted
inserted
replaced
5867:3c3809c3f603 | 5868:c61e1577c62f |
---|---|
1 Testing cache corruption and recovery | |
2 https://bz.mercurial-scm.org/show_bug.cgi?id=6354 | |
3 | |
4 $ . $TESTDIR/testlib/pythonpath.sh | |
5 | |
6 $ cat << EOF >> $HGRCPATH | |
7 > [extensions] | |
8 > evolve = | |
9 > [experimental] | |
10 > obshashrange = 1 | |
11 > obshashrange.warm-cache = yes | |
12 > [ui] | |
13 > logtemplate = "{rev} {node|short} {desc} {tags}\n" | |
14 > EOF | |
15 | |
16 $ cat >> repack.py << EOF | |
17 > import struct | |
18 > import sys | |
19 > data = [] | |
20 > with open(sys.argv[1], 'rb') as f: | |
21 > header = f.read(24) | |
22 > while True: | |
23 > buf = f.read(8) | |
24 > if not buf: break | |
25 > data.append(struct.unpack('<q', buf)[0]) | |
26 > with open(sys.argv[1], 'wb') as f: | |
27 > f.write(header) | |
28 > for item in data: | |
29 > f.write(struct.pack('<l', item)) | |
30 > EOF | |
31 | |
32 $ cat >> truncate.py << EOF | |
33 > import os | |
34 > import sys | |
35 > with open(sys.argv[1], 'ab') as fp: | |
36 > fp.seek(int(sys.argv[2]), os.SEEK_END) | |
37 > fp.truncate() | |
38 > EOF | |
39 | |
40 Simple linear setup | |
41 | |
42 $ hg init linear | |
43 $ cd linear | |
44 | |
45 $ hg debugbuilddag '+3' | |
46 $ hg log -G | |
47 o 2 01241442b3c2 r2 tip | |
48 | | |
49 o 1 66f7d451a68b r1 | |
50 | | |
51 o 0 1ea73414a91b r0 | |
52 | |
53 $ f -s .hg/cache/evoext-* | |
54 .hg/cache/evoext-depthcache-00: size=48 | |
55 .hg/cache/evoext-firstmerge-00: size=48 | |
56 .hg/cache/evoext-obscache-00: size=67 | |
57 .hg/cache/evoext-stablesortcache-00: size=52 | |
58 | |
59 testing depthcache | |
60 | |
61 $ f -H .hg/cache/evoext-depthcache-00 | |
62 .hg/cache/evoext-depthcache-00: | |
63 0000: 00 00 00 02 01 24 14 42 b3 c2 bf 32 11 e5 93 b5 |.....$.B...2....| | |
64 0010: 49 c6 55 ea 65 b2 95 e3 01 00 00 00 00 00 00 00 |I.U.e...........| | |
65 0020: 02 00 00 00 00 00 00 00 03 00 00 00 00 00 00 00 |................| | |
66 | |
67 $ hg debugdepth --rev 'all()' --method compare --debug | |
68 1ea73414a91b 1 | |
69 66f7d451a68b 2 | |
70 01241442b3c2 3 | |
71 | |
72 $ "$PYTHON" ../repack.py .hg/cache/evoext-depthcache-00 | |
73 $ f -H .hg/cache/evoext-depthcache-00 | |
74 .hg/cache/evoext-depthcache-00: | |
75 0000: 00 00 00 02 01 24 14 42 b3 c2 bf 32 11 e5 93 b5 |.....$.B...2....| | |
76 0010: 49 c6 55 ea 65 b2 95 e3 01 00 00 00 02 00 00 00 |I.U.e...........| | |
77 0020: 03 00 00 00 |....| | |
78 | |
79 $ hg debugdepth --rev 'all()' --method compare --debug | |
80 depthcache file seems to be corrupted, it will be rebuilt from scratch | |
81 1ea73414a91b 1 | |
82 66f7d451a68b 2 | |
83 01241442b3c2 3 | |
84 | |
85 $ "$PYTHON" ../truncate.py .hg/cache/evoext-depthcache-00 -4 | |
86 $ f -H .hg/cache/evoext-depthcache-00 | |
87 .hg/cache/evoext-depthcache-00: | |
88 0000: 00 00 00 02 01 24 14 42 b3 c2 bf 32 11 e5 93 b5 |.....$.B...2....| | |
89 0010: 49 c6 55 ea 65 b2 95 e3 01 00 00 00 00 00 00 00 |I.U.e...........| | |
90 0020: 02 00 00 00 00 00 00 00 03 00 00 00 |............| | |
91 | |
92 $ hg debugdepth --rev 'all()' --method compare --debug | |
93 depthcache file seems to be corrupted, it will be rebuilt from scratch | |
94 1ea73414a91b 1 | |
95 66f7d451a68b 2 | |
96 01241442b3c2 3 | |
97 | |
98 testing firstmergecache | |
99 | |
100 $ f -H .hg/cache/evoext-firstmerge-00 | |
101 .hg/cache/evoext-firstmerge-00: | |
102 0000: 00 00 00 02 01 24 14 42 b3 c2 bf 32 11 e5 93 b5 |.....$.B...2....| | |
103 0010: 49 c6 55 ea 65 b2 95 e3 ff ff ff ff ff ff ff ff |I.U.e...........| | |
104 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| | |
105 | |
106 $ hg debugfirstmergecache --debug | |
107 1ea73414a91b -1 | |
108 66f7d451a68b -1 | |
109 01241442b3c2 -1 | |
110 | |
111 $ "$PYTHON" ../repack.py .hg/cache/evoext-firstmerge-00 | |
112 $ f -H .hg/cache/evoext-firstmerge-00 | |
113 .hg/cache/evoext-firstmerge-00: | |
114 0000: 00 00 00 02 01 24 14 42 b3 c2 bf 32 11 e5 93 b5 |.....$.B...2....| | |
115 0010: 49 c6 55 ea 65 b2 95 e3 ff ff ff ff ff ff ff ff |I.U.e...........| | |
116 0020: ff ff ff ff |....| | |
117 | |
118 $ hg debugfirstmergecache --debug | |
119 firstmergecache file seems to be corrupted, it will be rebuilt from scratch | |
120 1ea73414a91b -1 | |
121 66f7d451a68b -1 | |
122 01241442b3c2 -1 | |
123 | |
124 $ "$PYTHON" ../truncate.py .hg/cache/evoext-firstmerge-00 -4 | |
125 $ f -H .hg/cache/evoext-firstmerge-00 | |
126 .hg/cache/evoext-firstmerge-00: | |
127 0000: 00 00 00 02 01 24 14 42 b3 c2 bf 32 11 e5 93 b5 |.....$.B...2....| | |
128 0010: 49 c6 55 ea 65 b2 95 e3 ff ff ff ff ff ff ff ff |I.U.e...........| | |
129 0020: ff ff ff ff ff ff ff ff ff ff ff ff |............| | |
130 | |
131 $ hg debugfirstmergecache --debug | |
132 firstmergecache file seems to be corrupted, it will be rebuilt from scratch | |
133 1ea73414a91b -1 | |
134 66f7d451a68b -1 | |
135 01241442b3c2 -1 | |
136 | |
137 testing stablesortcache | |
138 | |
139 $ f -H .hg/cache/evoext-stablesortcache-00 | |
140 .hg/cache/evoext-stablesortcache-00: | |
141 0000: 00 00 00 02 01 24 14 42 b3 c2 bf 32 11 e5 93 b5 |.....$.B...2....| | |
142 0010: 49 c6 55 ea 65 b2 95 e3 00 00 00 18 00 00 00 00 |I.U.e...........| | |
143 0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| | |
144 0030: 00 00 00 00 |....| | |
145 | |
146 $ hg debugstablesortcache --debug | |
147 number of revisions: 3 | |
148 number of merge: 0 | |
149 number of jumps: 0 | |
150 | |
151 $ "$PYTHON" ../truncate.py .hg/cache/evoext-stablesortcache-00 -4 | |
152 $ f -H .hg/cache/evoext-stablesortcache-00 | |
153 .hg/cache/evoext-stablesortcache-00: | |
154 0000: 00 00 00 02 01 24 14 42 b3 c2 bf 32 11 e5 93 b5 |.....$.B...2....| | |
155 0010: 49 c6 55 ea 65 b2 95 e3 00 00 00 18 00 00 00 00 |I.U.e...........| | |
156 0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| | |
157 | |
158 $ hg debugstablesortcache --debug | |
159 number of revisions: 3 | |
160 stablesortcache file seems to be corrupted, it will be rebuilt from scratch | |
161 number of merge: 0 | |
162 number of jumps: 0 | |
163 | |
164 $ cd .. | |
165 | |
166 A "diamond" setup with a merge | |
167 | |
168 $ hg init with-a-merge | |
169 $ cd with-a-merge | |
170 | |
171 $ hg debugbuilddag '+2 *2 /2' | |
172 $ hg log -G | |
173 o 3 2b6d669947cd r3 tip | |
174 |\ | |
175 | o 2 fa942426a6fd r2 | |
176 | | | |
177 o | 1 66f7d451a68b r1 | |
178 |/ | |
179 o 0 1ea73414a91b r0 | |
180 | |
181 $ f -s .hg/cache/evoext-* | |
182 .hg/cache/evoext-depthcache-00: size=56 | |
183 .hg/cache/evoext-firstmerge-00: size=56 | |
184 .hg/cache/evoext-obscache-00: size=68 | |
185 .hg/cache/evoext-stablesortcache-00: size=84 | |
186 | |
187 testing depthcache | |
188 | |
189 $ f -H .hg/cache/evoext-depthcache-00 | |
190 .hg/cache/evoext-depthcache-00: | |
191 0000: 00 00 00 03 2b 6d 66 99 47 cd 52 4d 74 f4 3c 1b |....+mf.G.RMt.<.| | |
192 0010: 11 c7 84 85 89 70 7e ef 01 00 00 00 00 00 00 00 |.....p~.........| | |
193 0020: 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 |................| | |
194 0030: 04 00 00 00 00 00 00 00 |........| | |
195 | |
196 $ hg debugdepth --rev 'all()' --method compare --debug | |
197 1ea73414a91b 1 | |
198 66f7d451a68b 2 | |
199 fa942426a6fd 2 | |
200 2b6d669947cd 4 | |
201 | |
202 $ "$PYTHON" ../repack.py .hg/cache/evoext-depthcache-00 | |
203 $ f -H .hg/cache/evoext-depthcache-00 | |
204 .hg/cache/evoext-depthcache-00: | |
205 0000: 00 00 00 03 2b 6d 66 99 47 cd 52 4d 74 f4 3c 1b |....+mf.G.RMt.<.| | |
206 0010: 11 c7 84 85 89 70 7e ef 01 00 00 00 02 00 00 00 |.....p~.........| | |
207 0020: 02 00 00 00 04 00 00 00 |........| | |
208 | |
209 $ hg debugdepth --rev 'all()' --method compare --debug | |
210 depthcache file seems to be corrupted, it will be rebuilt from scratch | |
211 1ea73414a91b 1 | |
212 66f7d451a68b 2 | |
213 fa942426a6fd 2 | |
214 2b6d669947cd 4 | |
215 | |
216 $ "$PYTHON" ../truncate.py .hg/cache/evoext-depthcache-00 -4 | |
217 $ f -H .hg/cache/evoext-depthcache-00 | |
218 .hg/cache/evoext-depthcache-00: | |
219 0000: 00 00 00 03 2b 6d 66 99 47 cd 52 4d 74 f4 3c 1b |....+mf.G.RMt.<.| | |
220 0010: 11 c7 84 85 89 70 7e ef 01 00 00 00 00 00 00 00 |.....p~.........| | |
221 0020: 02 00 00 00 00 00 00 00 02 00 00 00 00 00 00 00 |................| | |
222 0030: 04 00 00 00 |....| | |
223 | |
224 $ hg debugdepth --rev 'all()' --method compare --debug | |
225 depthcache file seems to be corrupted, it will be rebuilt from scratch | |
226 1ea73414a91b 1 | |
227 66f7d451a68b 2 | |
228 fa942426a6fd 2 | |
229 2b6d669947cd 4 | |
230 | |
231 testing firstmergecache | |
232 | |
233 $ f -H .hg/cache/evoext-firstmerge-00 | |
234 .hg/cache/evoext-firstmerge-00: | |
235 0000: 00 00 00 03 2b 6d 66 99 47 cd 52 4d 74 f4 3c 1b |....+mf.G.RMt.<.| | |
236 0010: 11 c7 84 85 89 70 7e ef ff ff ff ff ff ff ff ff |.....p~.........| | |
237 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| | |
238 0030: 03 00 00 00 00 00 00 00 |........| | |
239 | |
240 $ hg debugfirstmergecache --debug | |
241 1ea73414a91b -1 | |
242 66f7d451a68b -1 | |
243 fa942426a6fd -1 | |
244 2b6d669947cd 3 | |
245 | |
246 $ "$PYTHON" ../repack.py .hg/cache/evoext-firstmerge-00 | |
247 $ f -H .hg/cache/evoext-firstmerge-00 | |
248 .hg/cache/evoext-firstmerge-00: | |
249 0000: 00 00 00 03 2b 6d 66 99 47 cd 52 4d 74 f4 3c 1b |....+mf.G.RMt.<.| | |
250 0010: 11 c7 84 85 89 70 7e ef ff ff ff ff ff ff ff ff |.....p~.........| | |
251 0020: ff ff ff ff 03 00 00 00 |........| | |
252 | |
253 $ hg debugfirstmergecache --debug | |
254 firstmergecache file seems to be corrupted, it will be rebuilt from scratch | |
255 1ea73414a91b -1 | |
256 66f7d451a68b -1 | |
257 fa942426a6fd -1 | |
258 2b6d669947cd 3 | |
259 | |
260 $ "$PYTHON" ../truncate.py .hg/cache/evoext-firstmerge-00 -4 | |
261 $ f -H .hg/cache/evoext-firstmerge-00 | |
262 .hg/cache/evoext-firstmerge-00: | |
263 0000: 00 00 00 03 2b 6d 66 99 47 cd 52 4d 74 f4 3c 1b |....+mf.G.RMt.<.| | |
264 0010: 11 c7 84 85 89 70 7e ef ff ff ff ff ff ff ff ff |.....p~.........| | |
265 0020: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................| | |
266 0030: 03 00 00 00 |....| | |
267 | |
268 $ hg debugfirstmergecache --debug | |
269 firstmergecache file seems to be corrupted, it will be rebuilt from scratch | |
270 1ea73414a91b -1 | |
271 66f7d451a68b -1 | |
272 fa942426a6fd -1 | |
273 2b6d669947cd 3 | |
274 | |
275 testing stablesortcache | |
276 | |
277 $ f -H .hg/cache/evoext-stablesortcache-00 | |
278 .hg/cache/evoext-stablesortcache-00: | |
279 0000: 00 00 00 03 2b 6d 66 99 47 cd 52 4d 74 f4 3c 1b |....+mf.G.RMt.<.| | |
280 0010: 11 c7 84 85 89 70 7e ef 00 00 00 20 00 00 00 00 |.....p~.... ....| | |
281 0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| | |
282 0030: 00 00 00 00 01 00 00 00 00 00 00 00 02 00 00 00 |................| | |
283 0040: 00 00 00 00 01 00 00 00 00 00 00 00 02 00 00 00 |................| | |
284 0050: 00 00 00 00 |....| | |
285 | |
286 $ hg debugstablesortcache --debug | |
287 number of revisions: 4 | |
288 number of merge: 1 | |
289 number of jumps: 1 | |
290 average jumps: 1.000 | |
291 median jumps: 1 | |
292 90% jumps: 1 | |
293 99% jumps: 1 | |
294 max jumps: 1 | |
295 jump cache size: 12 bytes | |
296 | |
297 $ "$PYTHON" ../truncate.py .hg/cache/evoext-stablesortcache-00 -4 | |
298 $ f -H .hg/cache/evoext-stablesortcache-00 | |
299 .hg/cache/evoext-stablesortcache-00: | |
300 0000: 00 00 00 03 2b 6d 66 99 47 cd 52 4d 74 f4 3c 1b |....+mf.G.RMt.<.| | |
301 0010: 11 c7 84 85 89 70 7e ef 00 00 00 20 00 00 00 00 |.....p~.... ....| | |
302 0020: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| | |
303 0030: 00 00 00 00 01 00 00 00 00 00 00 00 02 00 00 00 |................| | |
304 0040: 00 00 00 00 01 00 00 00 00 00 00 00 02 00 00 00 |................| | |
305 | |
306 $ hg debugstablesortcache --debug | |
307 number of revisions: 4 | |
308 stablesortcache file seems to be corrupted, it will be rebuilt from scratch | |
309 number of merge: 1 | |
310 number of jumps: 1 | |
311 average jumps: 1.000 | |
312 median jumps: 1 | |
313 90% jumps: 1 | |
314 99% jumps: 1 | |
315 max jumps: 1 | |
316 jump cache size: 12 bytes | |
317 | |
318 $ cd .. |