##// END OF EJS Templates
test-transaction-safety: perform the test on a filelog...
marmoute -
r52072:cf23a843 default
parent child Browse files
Show More
@@ -1,287 +1,287 b''
1 Test transaction safety
1 Test transaction safety
2 =======================
2 =======================
3
3
4 #testcases revlogv1 revlogv2 changelogv2
4 #testcases revlogv1 revlogv2 changelogv2
5
5
6 #if revlogv1
6 #if revlogv1
7
7
8 $ cat << EOF >> $HGRCPATH
8 $ cat << EOF >> $HGRCPATH
9 > [experimental]
9 > [experimental]
10 > revlogv2=no
10 > revlogv2=no
11 > EOF
11 > EOF
12
12
13 #endif
13 #endif
14
14
15 #if revlogv2
15 #if revlogv2
16
16
17 $ cat << EOF >> $HGRCPATH
17 $ cat << EOF >> $HGRCPATH
18 > [experimental]
18 > [experimental]
19 > revlogv2=enable-unstable-format-and-corrupt-my-data
19 > revlogv2=enable-unstable-format-and-corrupt-my-data
20 > EOF
20 > EOF
21
21
22 #endif
22 #endif
23
23
24 #if changelogv2
24 #if changelogv2
25
25
26 $ cat << EOF >> $HGRCPATH
26 $ cat << EOF >> $HGRCPATH
27 > [format]
27 > [format]
28 > exp-use-changelog-v2=enable-unstable-format-and-corrupt-my-data
28 > exp-use-changelog-v2=enable-unstable-format-and-corrupt-my-data
29 > EOF
29 > EOF
30
30
31 #endif
31 #endif
32
32
33 This test basic case to make sure external process do not see transaction
33 This test basic case to make sure external process do not see transaction
34 content until it is committed.
34 content until it is committed.
35
35
36 # TODO: also add an external reader accessing revlog files while they are written
36 # TODO: also add an external reader accessing revlog files while they are written
37 # (instead of during transaction finalisation)
37 # (instead of during transaction finalisation)
38
38
39 # TODO: also add stream clone and hardlink clone happening during these transaction.
39 # TODO: also add stream clone and hardlink clone happening during these transaction.
40
40
41 setup
41 setup
42 -----
42 -----
43
43
44 synchronisation+output script using the following schedule:
44 synchronisation+output script using the following schedule:
45
45
46 [A1] "external" is started
46 [A1] "external" is started
47 [A2] "external" waits on EXT_UNLOCK
47 [A2] "external" waits on EXT_UNLOCK
48 [A2] "external" + creates EXT_WAITING unlocks [C1]
48 [A2] "external" + creates EXT_WAITING unlocks [C1]
49 [B1] "hg commit/pull" is started
49 [B1] "hg commit/pull" is started
50 [B2] "hg commit/pull" is ready to be committed
50 [B2] "hg commit/pull" is ready to be committed
51 [B3] "hg commit/pull" spawn "internal" using a pretxnclose hook (need [C4])
51 [B3] "hg commit/pull" spawn "internal" using a pretxnclose hook (need [C4])
52 [C1] "internal" waits on EXT_WAITING (need [A2])
52 [C1] "internal" waits on EXT_WAITING (need [A2])
53 [C2] "internal" creates EXT_UNLOCK unlocks [A2]
53 [C2] "internal" creates EXT_UNLOCK unlocks [A2]
54 [C3] "internal" show the tipmost revision (inside of the transaction)
54 [C3] "internal" show the tipmost revision (inside of the transaction)
55 [C4] "internal" waits on EXT_DONE (need [A4])
55 [C4] "internal" waits on EXT_DONE (need [A4])
56 [A3] "external" show the tipmost revision (outside of the transaction)
56 [A3] "external" show the tipmost revision (outside of the transaction)
57 [A4] "external" creates EXT_DONE unlocks [C4]
57 [A4] "external" creates EXT_DONE unlocks [C4]
58 [C5] "internal" end of execution -> unlock [B3]
58 [C5] "internal" end of execution -> unlock [B3]
59 [B4] "hg commit/pull" transaction is committed on disk
59 [B4] "hg commit/pull" transaction is committed on disk
60
60
61
61
62 $ mkdir sync
62 $ mkdir sync
63 $ mkdir output
63 $ mkdir output
64 $ mkdir script
64 $ mkdir script
65 $ HG_TEST_FILE_EXT_WAITING=$TESTTMP/sync/ext_waiting
65 $ HG_TEST_FILE_EXT_WAITING=$TESTTMP/sync/ext_waiting
66 $ export HG_TEST_FILE_EXT_WAITING
66 $ export HG_TEST_FILE_EXT_WAITING
67 $ HG_TEST_FILE_EXT_UNLOCK=$TESTTMP/sync/ext_unlock
67 $ HG_TEST_FILE_EXT_UNLOCK=$TESTTMP/sync/ext_unlock
68 $ export HG_TEST_FILE_EXT_UNLOCK
68 $ export HG_TEST_FILE_EXT_UNLOCK
69 $ HG_TEST_FILE_EXT_DONE=$TESTTMP/sync/ext_done
69 $ HG_TEST_FILE_EXT_DONE=$TESTTMP/sync/ext_done
70 $ export HG_TEST_FILE_EXT_DONE
70 $ export HG_TEST_FILE_EXT_DONE
71 $ cat << EOF > script/external.sh
71 $ cat << EOF > script/external.sh
72 > #!/bin/sh
72 > #!/bin/sh
73 > "$RUNTESTDIR/testlib/wait-on-file" 5 "$HG_TEST_FILE_EXT_UNLOCK" "$HG_TEST_FILE_EXT_WAITING"
73 > "$RUNTESTDIR/testlib/wait-on-file" 5 "$HG_TEST_FILE_EXT_UNLOCK" "$HG_TEST_FILE_EXT_WAITING"
74 > hg log --rev 'tip' -T 'external: {rev} {desc}\n' > "$TESTTMP/output/external.out"
74 > hg log --rev 'tip' -T 'external: {rev} {desc}\n' > "$TESTTMP/output/external.out"
75 > touch "$HG_TEST_FILE_EXT_DONE"
75 > touch "$HG_TEST_FILE_EXT_DONE"
76 > EOF
76 > EOF
77 $ cat << EOF > script/internal.sh
77 $ cat << EOF > script/internal.sh
78 > #!/bin/sh
78 > #!/bin/sh
79 > "$RUNTESTDIR/testlib/wait-on-file" 5 "$HG_TEST_FILE_EXT_WAITING"
79 > "$RUNTESTDIR/testlib/wait-on-file" 5 "$HG_TEST_FILE_EXT_WAITING"
80 > touch "$HG_TEST_FILE_EXT_UNLOCK"
80 > touch "$HG_TEST_FILE_EXT_UNLOCK"
81 > hg log --rev 'tip' -T 'internal: {rev} {desc}\n' > "$TESTTMP/output/internal.out"
81 > hg log --rev 'tip' -T 'internal: {rev} {desc}\n' > "$TESTTMP/output/internal.out"
82 > "$RUNTESTDIR/testlib/wait-on-file" 5 "$HG_TEST_FILE_EXT_DONE"
82 > "$RUNTESTDIR/testlib/wait-on-file" 5 "$HG_TEST_FILE_EXT_DONE"
83 > EOF
83 > EOF
84
84
85
85
86 Automated commands:
86 Automated commands:
87
87
88 $ make_one_commit() {
88 $ make_one_commit() {
89 > rm -f $TESTTMP/sync/*
89 > rm -f $TESTTMP/sync/*
90 > rm -f $TESTTMP/output/*
90 > rm -f $TESTTMP/output/*
91 > hg log --rev 'tip' -T 'pre-commit: {rev} {desc}\n'
91 > hg log --rev 'tip' -T 'pre-commit: {rev} {desc}\n'
92 > echo x >> a
92 > echo x >> of
93 > sh $TESTTMP/script/external.sh & hg commit -m "$1"
93 > sh $TESTTMP/script/external.sh & hg commit -m "$1"
94 > cat $TESTTMP/output/external.out
94 > cat $TESTTMP/output/external.out
95 > cat $TESTTMP/output/internal.out
95 > cat $TESTTMP/output/internal.out
96 > hg log --rev 'tip' -T 'post-tr: {rev} {desc}\n'
96 > hg log --rev 'tip' -T 'post-tr: {rev} {desc}\n'
97 > }
97 > }
98
98
99
99
100 $ make_one_pull() {
100 $ make_one_pull() {
101 > rm -f $TESTTMP/sync/*
101 > rm -f $TESTTMP/sync/*
102 > rm -f $TESTTMP/output/*
102 > rm -f $TESTTMP/output/*
103 > hg log --rev 'tip' -T 'pre-commit: {rev} {desc}\n'
103 > hg log --rev 'tip' -T 'pre-commit: {rev} {desc}\n'
104 > echo x >> a
104 > echo x >> of
105 > sh $TESTTMP/script/external.sh & hg pull ../other-repo/ --rev "$1" --force --quiet
105 > sh $TESTTMP/script/external.sh & hg pull ../other-repo/ --rev "$1" --force --quiet
106 > cat $TESTTMP/output/external.out
106 > cat $TESTTMP/output/external.out
107 > cat $TESTTMP/output/internal.out
107 > cat $TESTTMP/output/internal.out
108 > hg log --rev 'tip' -T 'post-tr: {rev} {desc}\n'
108 > hg log --rev 'tip' -T 'post-tr: {rev} {desc}\n'
109 > }
109 > }
110
110
111 prepare a large source to which to pull from:
111 prepare a large source to which to pull from:
112
112
113 The source is large to unsure we don't use inline more after the pull
113 The source is large to unsure we don't use inline more after the pull
114
114
115 $ hg init other-repo
115 $ hg init other-repo
116 $ hg -R other-repo debugbuilddag .+500
116 $ hg -R other-repo debugbuilddag .+500 --overwritten-file
117
117
118
118
119 prepare an empty repository where to make test:
119 prepare an empty repository where to make test:
120
120
121 $ hg init repo
121 $ hg init repo
122 $ cd repo
122 $ cd repo
123 $ touch a
123 $ touch of
124 $ hg add a
124 $ hg add of
125
125
126 prepare a small extension to controll inline size
126 prepare a small extension to controll inline size
127
127
128 $ mkdir $TESTTMP/ext
128 $ mkdir $TESTTMP/ext
129 $ cat << EOF > $TESTTMP/ext/small_inline.py
129 $ cat << EOF > $TESTTMP/ext/small_inline.py
130 > from mercurial import revlog
130 > from mercurial import revlog
131 > revlog._maxinline = 64 * 100
131 > revlog._maxinline = 3 * 100
132 > EOF
132 > EOF
133
133
134
134
135
135
136
136
137 $ cat << EOF >> $HGRCPATH
137 $ cat << EOF >> $HGRCPATH
138 > [extensions]
138 > [extensions]
139 > small_inline=$TESTTMP/ext/small_inline.py
139 > small_inline=$TESTTMP/ext/small_inline.py
140 > [hooks]
140 > [hooks]
141 > pretxnclose = sh $TESTTMP/script/internal.sh
141 > pretxnclose = sh $TESTTMP/script/internal.sh
142 > EOF
142 > EOF
143
143
144 check this is true for the initial commit (inline → inline)
144 check this is true for the initial commit (inline → inline)
145 -----------------------------------------------------------
145 -----------------------------------------------------------
146
146
147 the repository should still be inline (for relevant format)
147 the repository should still be inline (for relevant format)
148
148
149 $ make_one_commit first
149 $ make_one_commit first
150 pre-commit: -1
150 pre-commit: -1
151 external: -1
151 external: -1
152 internal: 0 first
152 internal: 0 first
153 post-tr: 0 first
153 post-tr: 0 first
154
154
155 #if revlogv1
155 #if revlogv1
156
156
157 $ hg debugrevlog -c | grep inline
157 $ hg debugrevlog of | grep inline
158 flags : inline
158 flags : inline, generaldelta
159
159
160 #endif
160 #endif
161
161
162 check this is true for extra commit (inline → inline)
162 check this is true for extra commit (inline → inline)
163 -----------------------------------------------------
163 -----------------------------------------------------
164
164
165 the repository should still be inline (for relevant format)
165 the repository should still be inline (for relevant format)
166
166
167 #if revlogv1
167 #if revlogv1
168
168
169 $ hg debugrevlog -c | grep inline
169 $ hg debugrevlog of | grep inline
170 flags : inline
170 flags : inline, generaldelta
171
171
172 #endif
172 #endif
173
173
174 $ make_one_commit second
174 $ make_one_commit second
175 pre-commit: 0 first
175 pre-commit: 0 first
176 external: 0 first
176 external: 0 first
177 internal: 1 second
177 internal: 1 second
178 post-tr: 1 second
178 post-tr: 1 second
179
179
180 #if revlogv1
180 #if revlogv1
181
181
182 $ hg debugrevlog -c | grep inline
182 $ hg debugrevlog of | grep inline
183 flags : inline
183 flags : inline, generaldelta
184
184
185 #endif
185 #endif
186
186
187 check this is true for a small pull (inline → inline)
187 check this is true for a small pull (inline → inline)
188 -----------------------------------------------------
188 -----------------------------------------------------
189
189
190 the repository should still be inline (for relevant format)
190 the repository should still be inline (for relevant format)
191
191
192 #if revlogv1
192 #if revlogv1
193
193
194 $ hg debugrevlog -c | grep inline
194 $ hg debugrevlog of | grep inline
195 flags : inline
195 flags : inline, generaldelta
196
196
197 #endif
197 #endif
198
198
199 $ make_one_pull 3
199 $ make_one_pull 3
200 pre-commit: 1 second
200 pre-commit: 1 second
201 warning: repository is unrelated
201 warning: repository is unrelated
202 external: 1 second
202 external: 1 second
203 internal: 5 r3
203 internal: 5 r3
204 post-tr: 5 r3
204 post-tr: 5 r3
205
205
206 #if revlogv1
206 #if revlogv1
207
207
208 $ hg debugrevlog -c | grep inline
208 $ hg debugrevlog of | grep inline
209 flags : inline
209 flags : inline, generaldelta
210
210
211 #endif
211 #endif
212
212
213 Make a large pull (inline → no-inline)
213 Make a large pull (inline → no-inline)
214 ---------------------------------------
214 ---------------------------------------
215
215
216 the repository should no longer be inline (for relevant format)
216 the repository should no longer be inline (for relevant format)
217
217
218 #if revlogv1
218 #if revlogv1
219
219
220 $ hg debugrevlog -c | grep inline
220 $ hg debugrevlog of | grep inline
221 flags : inline
221 flags : inline, generaldelta
222
222
223 #endif
223 #endif
224
224
225 $ make_one_pull 400
225 $ make_one_pull 400
226 pre-commit: 5 r3
226 pre-commit: 5 r3
227 external: 5 r3
227 external: 5 r3
228 internal: 402 r400
228 internal: 402 r400
229 post-tr: 402 r400
229 post-tr: 402 r400
230
230
231 #if revlogv1
231 #if revlogv1
232
232
233 $ hg debugrevlog -c | grep inline
233 $ hg debugrevlog of | grep inline
234 [1]
234 [1]
235
235
236 #endif
236 #endif
237
237
238 check this is true for extra commit (no-inline → no-inline)
238 check this is true for extra commit (no-inline → no-inline)
239 -----------------------------------------------------------
239 -----------------------------------------------------------
240
240
241 the repository should no longer be inline (for relevant format)
241 the repository should no longer be inline (for relevant format)
242
242
243 #if revlogv1
243 #if revlogv1
244
244
245 $ hg debugrevlog -c | grep inline
245 $ hg debugrevlog of | grep inline
246 [1]
246 [1]
247
247
248 #endif
248 #endif
249
249
250 $ make_one_commit third
250 $ make_one_commit third
251 pre-commit: 402 r400
251 pre-commit: 402 r400
252 external: 402 r400
252 external: 402 r400
253 internal: 403 third
253 internal: 403 third
254 post-tr: 403 third
254 post-tr: 403 third
255
255
256 #if revlogv1
256 #if revlogv1
257
257
258 $ hg debugrevlog -c | grep inline
258 $ hg debugrevlog of | grep inline
259 [1]
259 [1]
260
260
261 #endif
261 #endif
262
262
263
263
264 Make a pull (not-inline → no-inline)
264 Make a pull (not-inline → no-inline)
265 -------------------------------------
265 -------------------------------------
266
266
267 the repository should no longer be inline (for relevant format)
267 the repository should no longer be inline (for relevant format)
268
268
269 #if revlogv1
269 #if revlogv1
270
270
271 $ hg debugrevlog -c | grep inline
271 $ hg debugrevlog of | grep inline
272 [1]
272 [1]
273
273
274 #endif
274 #endif
275
275
276 $ make_one_pull tip
276 $ make_one_pull tip
277 pre-commit: 403 third
277 pre-commit: 403 third
278 external: 403 third
278 external: 403 third
279 internal: 503 r500
279 internal: 503 r500
280 post-tr: 503 r500
280 post-tr: 503 r500
281
281
282 #if revlogv1
282 #if revlogv1
283
283
284 $ hg debugrevlog -c | grep inline
284 $ hg debugrevlog of | grep inline
285 [1]
285 [1]
286
286
287 #endif
287 #endif
General Comments 0
You need to be logged in to leave comments. Login now