##// END OF EJS Templates
test-transaction-safety: relax some of the synchronisation schedule...
marmoute -
r48586:ebfc315c stable
parent child Browse files
Show More
@@ -1,286 +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" show the tipmost revision (inside of the transaction)
53 [C2] "internal" creates EXT_UNLOCK unlocks [A2]
54 [C3] "internal" waits on EXT_DONE (need [A4])
54 [C3] "internal" show the tipmost revision (inside of the transaction)
55 [C3] "internal" + creates EXT_UNLOCK unlocks [A2]
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 [C3]
57 [A4] "external" creates EXT_DONE unlocks [C4]
58 [C4] "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 > 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"
81 > "$RUNTESTDIR/testlib/wait-on-file" 5 "$HG_TEST_FILE_EXT_DONE" "$HG_TEST_FILE_EXT_UNLOCK"
82 > "$RUNTESTDIR/testlib/wait-on-file" 5 "$HG_TEST_FILE_EXT_DONE"
82 > EOF
83 > EOF
83
84
84
85
85 Automated commands:
86 Automated commands:
86
87
87 $ make_one_commit() {
88 $ make_one_commit() {
88 > rm -f $TESTTMP/sync/*
89 > rm -f $TESTTMP/sync/*
89 > rm -f $TESTTMP/output/*
90 > rm -f $TESTTMP/output/*
90 > hg log --rev 'tip' -T 'pre-commit: {rev} {desc}\n'
91 > hg log --rev 'tip' -T 'pre-commit: {rev} {desc}\n'
91 > echo x >> a
92 > echo x >> a
92 > sh $TESTTMP/script/external.sh & hg commit -m "$1"
93 > sh $TESTTMP/script/external.sh & hg commit -m "$1"
93 > cat $TESTTMP/output/external.out
94 > cat $TESTTMP/output/external.out
94 > cat $TESTTMP/output/internal.out
95 > cat $TESTTMP/output/internal.out
95 > hg log --rev 'tip' -T 'post-tr: {rev} {desc}\n'
96 > hg log --rev 'tip' -T 'post-tr: {rev} {desc}\n'
96 > }
97 > }
97
98
98
99
99 $ make_one_pull() {
100 $ make_one_pull() {
100 > rm -f $TESTTMP/sync/*
101 > rm -f $TESTTMP/sync/*
101 > rm -f $TESTTMP/output/*
102 > rm -f $TESTTMP/output/*
102 > hg log --rev 'tip' -T 'pre-commit: {rev} {desc}\n'
103 > hg log --rev 'tip' -T 'pre-commit: {rev} {desc}\n'
103 > echo x >> a
104 > echo x >> a
104 > 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
105 > cat $TESTTMP/output/external.out
106 > cat $TESTTMP/output/external.out
106 > cat $TESTTMP/output/internal.out
107 > cat $TESTTMP/output/internal.out
107 > hg log --rev 'tip' -T 'post-tr: {rev} {desc}\n'
108 > hg log --rev 'tip' -T 'post-tr: {rev} {desc}\n'
108 > }
109 > }
109
110
110 prepare a large source to which to pull from:
111 prepare a large source to which to pull from:
111
112
112 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
113
114
114 $ hg init other-repo
115 $ hg init other-repo
115 $ hg -R other-repo debugbuilddag .+500
116 $ hg -R other-repo debugbuilddag .+500
116
117
117
118
118 prepare an empty repository where to make test:
119 prepare an empty repository where to make test:
119
120
120 $ hg init repo
121 $ hg init repo
121 $ cd repo
122 $ cd repo
122 $ touch a
123 $ touch a
123 $ hg add a
124 $ hg add a
124
125
125 prepare a small extension to controll inline size
126 prepare a small extension to controll inline size
126
127
127 $ mkdir $TESTTMP/ext
128 $ mkdir $TESTTMP/ext
128 $ cat << EOF > $TESTTMP/ext/small_inline.py
129 $ cat << EOF > $TESTTMP/ext/small_inline.py
129 > from mercurial import revlog
130 > from mercurial import revlog
130 > revlog._maxinline = 64 * 100
131 > revlog._maxinline = 64 * 100
131 > EOF
132 > EOF
132
133
133
134
134
135
135
136
136 $ cat << EOF >> $HGRCPATH
137 $ cat << EOF >> $HGRCPATH
137 > [extensions]
138 > [extensions]
138 > small_inline=$TESTTMP/ext/small_inline.py
139 > small_inline=$TESTTMP/ext/small_inline.py
139 > [hooks]
140 > [hooks]
140 > pretxnclose = sh $TESTTMP/script/internal.sh
141 > pretxnclose = sh $TESTTMP/script/internal.sh
141 > EOF
142 > EOF
142
143
143 check this is true for the initial commit (inline → inline)
144 check this is true for the initial commit (inline → inline)
144 -----------------------------------------------------------
145 -----------------------------------------------------------
145
146
146 the repository should still be inline (for relevant format)
147 the repository should still be inline (for relevant format)
147
148
148 $ make_one_commit first
149 $ make_one_commit first
149 pre-commit: -1
150 pre-commit: -1
150 external: -1
151 external: -1
151 internal: 0 first
152 internal: 0 first
152 post-tr: 0 first
153 post-tr: 0 first
153
154
154 #if revlogv1
155 #if revlogv1
155
156
156 $ hg debugrevlog -c | grep inline
157 $ hg debugrevlog -c | grep inline
157 flags : inline
158 flags : inline
158
159
159 #endif
160 #endif
160
161
161 check this is true for extra commit (inline → inline)
162 check this is true for extra commit (inline → inline)
162 -----------------------------------------------------
163 -----------------------------------------------------
163
164
164 the repository should still be inline (for relevant format)
165 the repository should still be inline (for relevant format)
165
166
166 #if revlogv1
167 #if revlogv1
167
168
168 $ hg debugrevlog -c | grep inline
169 $ hg debugrevlog -c | grep inline
169 flags : inline
170 flags : inline
170
171
171 #endif
172 #endif
172
173
173 $ make_one_commit second
174 $ make_one_commit second
174 pre-commit: 0 first
175 pre-commit: 0 first
175 external: 0 first
176 external: 0 first
176 internal: 1 second
177 internal: 1 second
177 post-tr: 1 second
178 post-tr: 1 second
178
179
179 #if revlogv1
180 #if revlogv1
180
181
181 $ hg debugrevlog -c | grep inline
182 $ hg debugrevlog -c | grep inline
182 flags : inline
183 flags : inline
183
184
184 #endif
185 #endif
185
186
186 check this is true for a small pull (inline → inline)
187 check this is true for a small pull (inline → inline)
187 -----------------------------------------------------
188 -----------------------------------------------------
188
189
189 the repository should still be inline (for relevant format)
190 the repository should still be inline (for relevant format)
190
191
191 #if revlogv1
192 #if revlogv1
192
193
193 $ hg debugrevlog -c | grep inline
194 $ hg debugrevlog -c | grep inline
194 flags : inline
195 flags : inline
195
196
196 #endif
197 #endif
197
198
198 $ make_one_pull 3
199 $ make_one_pull 3
199 pre-commit: 1 second
200 pre-commit: 1 second
200 warning: repository is unrelated
201 warning: repository is unrelated
201 external: 1 second
202 external: 1 second
202 internal: 5 r3
203 internal: 5 r3
203 post-tr: 5 r3
204 post-tr: 5 r3
204
205
205 #if revlogv1
206 #if revlogv1
206
207
207 $ hg debugrevlog -c | grep inline
208 $ hg debugrevlog -c | grep inline
208 flags : inline
209 flags : inline
209
210
210 #endif
211 #endif
211
212
212 Make a large pull (inline → no-inline)
213 Make a large pull (inline → no-inline)
213 ---------------------------------------
214 ---------------------------------------
214
215
215 the repository should no longer be inline (for relevant format)
216 the repository should no longer be inline (for relevant format)
216
217
217 #if revlogv1
218 #if revlogv1
218
219
219 $ hg debugrevlog -c | grep inline
220 $ hg debugrevlog -c | grep inline
220 flags : inline
221 flags : inline
221
222
222 #endif
223 #endif
223
224
224 $ make_one_pull 400
225 $ make_one_pull 400
225 pre-commit: 5 r3
226 pre-commit: 5 r3
226 external: 5 r3
227 external: 5 r3
227 internal: 402 r400
228 internal: 402 r400
228 post-tr: 402 r400
229 post-tr: 402 r400
229
230
230 #if revlogv1
231 #if revlogv1
231
232
232 $ hg debugrevlog -c | grep inline
233 $ hg debugrevlog -c | grep inline
233 [1]
234 [1]
234
235
235 #endif
236 #endif
236
237
237 check this is true for extra commit (no-inline → no-inline)
238 check this is true for extra commit (no-inline → no-inline)
238 -----------------------------------------------------------
239 -----------------------------------------------------------
239
240
240 the repository should no longer be inline (for relevant format)
241 the repository should no longer be inline (for relevant format)
241
242
242 #if revlogv1
243 #if revlogv1
243
244
244 $ hg debugrevlog -c | grep inline
245 $ hg debugrevlog -c | grep inline
245 [1]
246 [1]
246
247
247 #endif
248 #endif
248
249
249 $ make_one_commit third
250 $ make_one_commit third
250 pre-commit: 402 r400
251 pre-commit: 402 r400
251 external: 402 r400
252 external: 402 r400
252 internal: 403 third
253 internal: 403 third
253 post-tr: 403 third
254 post-tr: 403 third
254
255
255 #if revlogv1
256 #if revlogv1
256
257
257 $ hg debugrevlog -c | grep inline
258 $ hg debugrevlog -c | grep inline
258 [1]
259 [1]
259
260
260 #endif
261 #endif
261
262
262
263
263 Make a pull (not-inline → no-inline)
264 Make a pull (not-inline → no-inline)
264 -------------------------------------
265 -------------------------------------
265
266
266 the repository should no longer be inline (for relevant format)
267 the repository should no longer be inline (for relevant format)
267
268
268 #if revlogv1
269 #if revlogv1
269
270
270 $ hg debugrevlog -c | grep inline
271 $ hg debugrevlog -c | grep inline
271 [1]
272 [1]
272
273
273 #endif
274 #endif
274
275
275 $ make_one_pull tip
276 $ make_one_pull tip
276 pre-commit: 403 third
277 pre-commit: 403 third
277 external: 403 third
278 external: 403 third
278 internal: 503 r500
279 internal: 503 r500
279 post-tr: 503 r500
280 post-tr: 503 r500
280
281
281 #if revlogv1
282 #if revlogv1
282
283
283 $ hg debugrevlog -c | grep inline
284 $ hg debugrevlog -c | grep inline
284 [1]
285 [1]
285
286
286 #endif
287 #endif
General Comments 0
You need to be logged in to leave comments. Login now