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