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