##// END OF EJS Templates
revlog: update the split + transaction test...
marmoute -
r51237:e2ba2234 stable
parent child Browse files
Show More
@@ -1,22 +1,62 b''
1 Test correctness of revlog inline -> non-inline transition
1 Test correctness of revlog inline -> non-inline transition
2 ----------------------------------------------------------
2 ----------------------------------------------------------
3
3
4 Helper extension to intercept renames.
4 Helper extension to intercept renames and kill process
5
5
6 $ cat > $TESTTMP/intercept_rename.py << EOF
6 $ cat > $TESTTMP/intercept_before_rename.py << EOF
7 > import os
7 > import os
8 > import sys
8 > import signal
9 > from mercurial import extensions, util
9 > from mercurial import extensions, util
10 >
10 >
11 > def extsetup(ui):
11 > def extsetup(ui):
12 > def close(orig, *args, **kwargs):
12 > def close(orig, *args, **kwargs):
13 > path = util.normpath(args[0]._atomictempfile__name)
13 > path = util.normpath(args[0]._atomictempfile__name)
14 > if path.endswith(b'/.hg/store/data/file.i'):
14 > if path.endswith(b'/.hg/store/data/file.i'):
15 > os._exit(80)
15 > os.kill(os.getpid(), signal.SIGKILL)
16 > return orig(*args, **kwargs)
16 > return orig(*args, **kwargs)
17 > extensions.wrapfunction(util.atomictempfile, 'close', close)
17 > extensions.wrapfunction(util.atomictempfile, 'close', close)
18 > EOF
18 > EOF
19
19
20 $ cat > $TESTTMP/killme.py << EOF
21 > import os
22 > import signal
23 >
24 > def killme(ui, repo, hooktype, **kwargs):
25 > os.kill(os.getpid(), signal.SIGKILL)
26 > EOF
27
28 setup a repository for tests
29 ----------------------------
30
31 $ cat >> $HGRCPATH << EOF
32 > [format]
33 > revlog-compression=none
34 > EOF
35
36 $ hg init troffset-computation
37 $ cd troffset-computation
38 $ printf '%20d' '1' > file
39 $ hg commit -Aqma
40 $ printf '%1024d' '1' > file
41 $ hg commit -Aqmb
42 $ printf '%20d' '1' > file
43 $ hg commit -Aqmc
44 $ dd if=/dev/zero of=file bs=1k count=128 > /dev/null 2>&1
45 $ hg commit -AqmD
46
47 Reference size:
48 $ f -s file
49 file: size=131072
50 $ f -s .hg/store/data/file*
51 .hg/store/data/file.d: size=132139
52 .hg/store/data/file.i: size=256
53
54 $ cd ..
55
56
57 Test a hard crash after the file was split but before the transaction was committed
58 ===================================================================================
59
20 Test offset computation to correctly factor in the index entries themselves.
60 Test offset computation to correctly factor in the index entries themselves.
21 Also test that the new data size has the correct size if the transaction is aborted
61 Also test that the new data size has the correct size if the transaction is aborted
22 after the index has been replaced.
62 after the index has been replaced.
@@ -28,30 +68,19 b' and will transition to non-inline storag'
28 If the transaction adding c, D is rolled back, then we don't undo the revlog split,
68 If the transaction adding c, D is rolled back, then we don't undo the revlog split,
29 but truncate the index and the data to remove both c and D.
69 but truncate the index and the data to remove both c and D.
30
70
31 $ hg init troffset-computation --config format.revlog-compression=none
32 $ cd troffset-computation
33 $ printf '%20d' '1' > file
34 $ hg commit -Aqma
35 $ printf '%1024d' '1' > file
36 $ hg commit -Aqmb
37 $ printf '%20d' '1' > file
38 $ hg commit -Aqmc
39 $ dd if=/dev/zero of=file bs=1k count=128 > /dev/null 2>&1
40 $ hg commit -AqmD
41
71
42 $ cd ..
72 $ hg clone --quiet --rev 1 troffset-computation troffset-computation-copy
43
44 $ hg clone -r 1 troffset-computation troffset-computation-copy --config format.revlog-compression=none -q
45 $ cd troffset-computation-copy
73 $ cd troffset-computation-copy
46
74
47 Reference size:
75 Reference size:
48
76 $ f -s file
77 file: size=1024
49 $ f -s .hg/store/data/file*
78 $ f -s .hg/store/data/file*
50 .hg/store/data/file.i: size=1174
79 .hg/store/data/file.i: size=1174
51
80
52 $ cat > .hg/hgrc <<EOF
81 $ cat > .hg/hgrc <<EOF
53 > [hooks]
82 > [hooks]
54 > pretxnchangegroup = python:$TESTDIR/helper-killhook.py:killme
83 > pretxnchangegroup = python:$TESTTMP/killme.py:killme
55 > EOF
84 > EOF
56 #if chg
85 #if chg
57 $ hg pull ../troffset-computation
86 $ hg pull ../troffset-computation
@@ -60,14 +89,24 b' Reference size:'
60 #else
89 #else
61 $ hg pull ../troffset-computation
90 $ hg pull ../troffset-computation
62 pulling from ../troffset-computation
91 pulling from ../troffset-computation
63 [80]
92 Killed
93 [137]
64 #endif
94 #endif
95
96
97 The revlog have been split on disk
98
99 $ f -s .hg/store/data/file*
100 .hg/store/data/file.d: size=132139
101 .hg/store/data/file.i: size=256
102
65 $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file | tail -1
103 $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file | tail -1
66 data/file.i 128
104 data/file.i 128
67
105
68 The first file.i entry should match the "Reference size" above.
106 The first file.i entry should match the "Reference size" above.
69 The first file.d entry is the temporary record during the split,
107 The first file.d entry is the temporary record during the split,
70 the second entry after the split happened. The sum of the second file.d
108
109 The second entry after the split happened. The sum of the second file.d
71 and the second file.i entry should match the first file.i entry.
110 and the second file.i entry should match the first file.i entry.
72
111
73 $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file
112 $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file
@@ -98,18 +137,27 b' and the second file.i entry should match'
98 $ hg verify -q
137 $ hg verify -q
99 $ cd ..
138 $ cd ..
100
139
140 Test a hard crash right before the index is move into place
141 ===========================================================
101
142
102 Now retry the procedure but intercept the rename of the index and check that
143 Now retry the procedure but intercept the rename of the index and check that
103 the journal does not contain the new index size. This demonstrates the edge case
144 the journal does not contain the new index size. This demonstrates the edge case
104 where the data file is left as garbage.
145 where the data file is left as garbage.
105
146
106 $ hg clone -r 1 troffset-computation troffset-computation-copy2 --config format.revlog-compression=none -q
147 $ hg clone --quiet --rev 1 troffset-computation troffset-computation-copy2
107 $ cd troffset-computation-copy2
148 $ cd troffset-computation-copy2
149
150 Reference size:
151 $ f -s file
152 file: size=1024
153 $ f -s .hg/store/data/file*
154 .hg/store/data/file.i: size=1174
155
108 $ cat > .hg/hgrc <<EOF
156 $ cat > .hg/hgrc <<EOF
109 > [extensions]
157 > [extensions]
110 > intercept_rename = $TESTTMP/intercept_rename.py
158 > intercept_rename = $TESTTMP/intercept_before_rename.py
111 > [hooks]
159 > [hooks]
112 > pretxnchangegroup = python:$TESTDIR/helper-killhook.py:killme
160 > pretxnchangegroup = python:$TESTTMP/killme.py:killme
113 > EOF
161 > EOF
114 #if chg
162 #if chg
115 $ hg pull ../troffset-computation
163 $ hg pull ../troffset-computation
@@ -118,8 +166,16 b' where the data file is left as garbage.'
118 #else
166 #else
119 $ hg pull ../troffset-computation
167 $ hg pull ../troffset-computation
120 pulling from ../troffset-computation
168 pulling from ../troffset-computation
121 [80]
169 Killed
170 [137]
122 #endif
171 #endif
172
173 The data file is created, but the revlog is still inline
174
175 $ f -s .hg/store/data/file*
176 .hg/store/data/file.d: size=132139
177 .hg/store/data/file.i: size=132395
178
123 $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file
179 $ cat .hg/store/journal | tr -s '\000' ' ' | grep data/file
124 data/file.i 1174
180 data/file.i 1174
125 data/file.d 0
181 data/file.d 0
@@ -141,10 +197,13 b' where the data file is left as garbage.'
141 $ hg verify -q
197 $ hg verify -q
142 $ cd ..
198 $ cd ..
143
199
200 Have the transaction rollback itself without any hard crash
201 ===========================================================
202
144
203
145 Repeat the original test but let hg rollback the transaction.
204 Repeat the original test but let hg rollback the transaction.
146
205
147 $ hg clone -r 1 troffset-computation troffset-computation-copy-rb --config format.revlog-compression=none -q
206 $ hg clone --quiet --rev 1 troffset-computation troffset-computation-copy-rb
148 $ cd troffset-computation-copy-rb
207 $ cd troffset-computation-copy-rb
149 $ cat > .hg/hgrc <<EOF
208 $ cat > .hg/hgrc <<EOF
150 > [hooks]
209 > [hooks]
@@ -160,9 +219,13 b' Repeat the original test but let hg roll'
160 rollback completed
219 rollback completed
161 abort: pretxnchangegroup hook exited with status 1
220 abort: pretxnchangegroup hook exited with status 1
162 [40]
221 [40]
222
223 File are still split on disk, with the expected size.
224
163 $ f -s .hg/store/data/file*
225 $ f -s .hg/store/data/file*
164 .hg/store/data/file.d: size=1046
226 .hg/store/data/file.d: size=1046
165 .hg/store/data/file.i: size=128
227 .hg/store/data/file.i: size=128
228
166 $ hg tip
229 $ hg tip
167 changeset: 1:cfa8d6e60429
230 changeset: 1:cfa8d6e60429
168 tag: tip
231 tag: tip
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now