##// END OF EJS Templates
dirstate: simplify the dirstate's read race testing...
marmoute -
r51135:3ddff85f stable
parent child Browse files
Show More
@@ -1,597 +1,430
1 1 ==============================================================================
2 2 Check potential race conditions between a dirstate's read and other operations
3 3 ==============================================================================
4 4
5 5 #testcases dirstate-v1 dirstate-v2-append dirstate-v2-rewrite
6 6 #testcases pre-all-read pre-some-read
7 7
8 8 Some commands, like `hg status`, do not need to take the wlock but need to
9 9 access dirstate data.
10 10 Other commands might update the dirstate data while this happens.
11 11
12 12 This can create issues if repository data is read in the wrong order, or for
13 13 the dirstate-v2 format where the data is contained in multiple files.
14 14
15 15 This test file is meant to test various cases where such parallel operations
16 16 happen and make sure the reading process behaves fine. We do so with a `hg
17 17 status` command since it is probably the most advanced of such read-only
18 18 command.
19 19
20 20 It bears simililarity with `tests/test-dirstate-status-race.t ` but tests a
21 21 different type of race.
22 22
23 23 Setup
24 24 =====
25 25
26 26 $ cat >> $HGRCPATH << EOF
27 27 > [storage]
28 28 > dirstate-v2.slow-path=allow
29 29 > EOF
30 30
31 31 #if no-dirstate-v1
32 32 $ cat >> $HGRCPATH << EOF
33 33 > [format]
34 34 > use-dirstate-v2=yes
35 35 > EOF
36 36 #else
37 37 $ cat >> $HGRCPATH << EOF
38 38 > [format]
39 39 > use-dirstate-v2=no
40 40 > EOF
41 41 #endif
42 42
43 43 #if dirstate-v2-rewrite
44 44 $ d2args="--config devel.dirstate.v2.data_update_mode=force-new"
45 45 #endif
46 46 #if dirstate-v2-append
47 47 $ d2args="--config devel.dirstate.v2.data_update_mode=force-append"
48 48 #endif
49 49
50 50
51 51 #if dirstate-v1
52 52 $ cfg="devel.sync.dirstate.pre-read-file"
53 53 #else
54 54 #if pre-all-read
55 55 $ cfg="devel.sync.dirstate.pre-read-file"
56 56 #else
57 57 $ cfg="devel.sync.dirstate.post-docket-read-file"
58 58 #endif
59 59 #endif
60 60
61 61 $ directories="dir dir/nested dir2"
62 62 $ first_files="dir/nested/a dir/b dir/c dir/d dir2/e f"
63 63 $ second_files="g dir/nested/h dir/i dir/j dir2/k dir2/l dir/nested/m"
64 64 $ extra_files="dir/n dir/o p q"
65 65
66 66 $ hg init reference-repo
67 67 $ cd reference-repo
68 68 $ mkdir -p dir/nested dir2
69 69 $ touch -t 200001010000 $first_files $directories
70 70 $ hg commit -Aqm "recreate a bunch of files to facilitate dirstate-v2 append"
71 71 $ touch -t 200001010010 $second_files $directories
72 72 $ hg commit -Aqm "more files to have two commit"
73 73 $ hg log -G -v
74 74 @ changeset: 1:9a86dcbfb938
75 75 | tag: tip
76 76 | user: test
77 77 | date: Thu Jan 01 00:00:00 1970 +0000
78 78 | files: dir/i dir/j dir/nested/h dir/nested/m dir2/k dir2/l g
79 79 | description:
80 80 | more files to have two commit
81 81 |
82 82 |
83 83 o changeset: 0:4f23db756b09
84 84 user: test
85 85 date: Thu Jan 01 00:00:00 1970 +0000
86 86 files: dir/b dir/c dir/d dir/nested/a dir2/e f
87 87 description:
88 88 recreate a bunch of files to facilitate dirstate-v2 append
89 89
90 90
91 91 $ hg manifest
92 92 dir/b
93 93 dir/c
94 94 dir/d
95 95 dir/i
96 96 dir/j
97 97 dir/nested/a
98 98 dir/nested/h
99 99 dir/nested/m
100 100 dir2/e
101 101 dir2/k
102 102 dir2/l
103 103 f
104 104 g
105 105
106 106 Add some unknown files and refresh the dirstate
107 107
108 108 $ touch -t 200001010020 $extra_files
109 109 $ hg add dir/o
110 110 $ hg remove dir/nested/m
111 111
112 112 $ hg st --config devel.dirstate.v2.data_update_mode=force-new
113 113 A dir/o
114 114 R dir/nested/m
115 115 ? dir/n
116 116 ? p
117 117 ? q
118 118 $ hg debugstate
119 119 n 644 0 2000-01-01 00:00:00 dir/b
120 120 n 644 0 2000-01-01 00:00:00 dir/c
121 121 n 644 0 2000-01-01 00:00:00 dir/d
122 122 n 644 0 2000-01-01 00:10:00 dir/i
123 123 n 644 0 2000-01-01 00:10:00 dir/j
124 124 n 644 0 2000-01-01 00:00:00 dir/nested/a
125 125 n 644 0 2000-01-01 00:10:00 dir/nested/h
126 126 r ?????????????????????????????????? dir/nested/m (glob)
127 127 a ?????????????????????????????????? dir/o (glob)
128 128 n 644 0 2000-01-01 00:00:00 dir2/e
129 129 n 644 0 2000-01-01 00:10:00 dir2/k
130 130 n 644 0 2000-01-01 00:10:00 dir2/l
131 131 n 644 0 2000-01-01 00:00:00 f
132 132 n 644 0 2000-01-01 00:10:00 g
133 133 $ hg debugstate > ../reference
134 134 $ cd ..
135 135
136 136 Actual Testing
137 137 ==============
138 138
139 139 Race with a `hg add`
140 140 -------------------
141 141
142 142 $ cp -a reference-repo race-with-add
143 143 $ cd race-with-add
144 144
145 145 spin a `hg status` with some caches to update
146 146
147 147 $ hg st >$TESTTMP/status-race-lock.out 2>$TESTTMP/status-race-lock.log \
148 148 > --config rhg.on-unsupported=abort \
149 149 > --config ${cfg}=$TESTTMP/status-race-lock \
150 150 > &
151 151 $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/status-race-lock.waiting
152 152
153 153 Add a file
154 154
155 155 $ hg $d2args add dir/n
156 156 $ touch $TESTTMP/status-race-lock
157 157 $ wait
158 158
159 159 The file should in a "added" state
160 160
161 161 $ hg status
162 162 A dir/n
163 163 A dir/o
164 164 R dir/nested/m
165 165 ? p
166 166 ? q
167 167
168 168 The status process should return a consistent result and not crash.
169 169
170 170 #if dirstate-v1
171 171 $ cat $TESTTMP/status-race-lock.out
172 172 A dir/n
173 173 A dir/o
174 174 R dir/nested/m
175 175 ? p
176 176 ? q
177 $ cat $TESTTMP/status-race-lock.log
178 177 #else
179 #if rhg
180 #if pre-all-read
181 $ cat $TESTTMP/status-race-lock.out
182 A dir/n
183 A dir/o
184 R dir/nested/m
185 ? p
186 ? q
187 $ cat $TESTTMP/status-race-lock.log
188 #else
189 #if dirstate-v2-append
178 #if rhg pre-some-read dirstate-v2-append
190 179 $ cat $TESTTMP/status-race-lock.out
191 180 A dir/o
192 181 R dir/nested/m
193 182 ? dir/n
194 183 ? p
195 184 ? q
196 $ cat $TESTTMP/status-race-lock.log
185 #else
186 #if rust no-rhg dirstate-v2-append
187 $ cat $TESTTMP/status-race-lock.out
188 A dir/o
189 R dir/nested/m
190 ? dir/n
191 ? p
192 ? q
197 193 #else
198 194 $ cat $TESTTMP/status-race-lock.out
199 195 A dir/n
200 196 A dir/o
201 197 R dir/nested/m
202 198 ? p
203 199 ? q
204 $ cat $TESTTMP/status-race-lock.log
205 #endif
206 #endif
207 #else
208 #if rust
209 #if dirstate-v2-rewrite
210 $ cat $TESTTMP/status-race-lock.out
211 A dir/n
212 A dir/o
213 R dir/nested/m
214 ? p
215 ? q
216 $ cat $TESTTMP/status-race-lock.log
217 #else
218 $ cat $TESTTMP/status-race-lock.out
219 A dir/o
220 R dir/nested/m
221 ? dir/n
222 ? p
223 ? q
224 $ cat $TESTTMP/status-race-lock.log
225 #endif
226 #else
227 $ cat $TESTTMP/status-race-lock.out
228 A dir/n
229 A dir/o
230 R dir/nested/m
231 ? p
232 ? q
233 $ cat $TESTTMP/status-race-lock.log
234 200 #endif
235 201 #endif
236 202 #endif
203 $ cat $TESTTMP/status-race-lock.log
237 204
238 205 final cleanup
239 206
240 207 $ rm $TESTTMP/status-race-lock $TESTTMP/status-race-lock.waiting
241 208 $ cd ..
242 209
243 210 Race with a `hg commit`
244 211 -----------------------
245 212
246 213 $ cp -a reference-repo race-with-commit
247 214 $ cd race-with-commit
248 215
249 216 spin a `hg status with some cache to update
250 217
251 218 $ hg st >$TESTTMP/status-race-lock.out 2>$TESTTMP/status-race-lock.log \
252 219 > --config rhg.on-unsupported=abort \
253 220 > --config ${cfg}=$TESTTMP/status-race-lock \
254 221 > &
255 222 $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/status-race-lock.waiting
256 223
257 224 Add a do a commit
258 225
259 226 $ hg status
260 227 A dir/o
261 228 R dir/nested/m
262 229 ? dir/n
263 230 ? p
264 231 ? q
265 232 $ hg $d2args commit -m 'racing commit'
266 233 $ touch $TESTTMP/status-race-lock
267 234 $ wait
268 235
269 236 commit was created, and status is now clean
270 237
271 238 $ hg log -GT '{node|short} {desc}\n'
272 239 @ 02a67a77ee9b racing commit
273 240 |
274 241 o 9a86dcbfb938 more files to have two commit
275 242 |
276 243 o 4f23db756b09 recreate a bunch of files to facilitate dirstate-v2 append
277 244
278 245 $ hg status
279 246 ? dir/n
280 247 ? p
281 248 ? q
282 249
283 250 The status process should return a consistent result and not crash.
284 251
285 #if dirstate-v1
252 #if rust no-rhg dirstate-v2-append
286 253 $ cat $TESTTMP/status-race-lock.out
287 M dir/o (no-rhg !)
288 ? dir/n
289 ? p
290 ? q
291 $ cat $TESTTMP/status-race-lock.log
292 warning: ignoring unknown working parent 02a67a77ee9b! (no-rhg !)
293 #else
294 #if rhg
295 #if pre-all-read
296 $ cat $TESTTMP/status-race-lock.out
254 A dir/o
255 R dir/nested/m
297 256 ? dir/n
298 257 ? p
299 258 ? q
300 259 $ cat $TESTTMP/status-race-lock.log
301 260 #else
302 #if dirstate-v2-append
261 #if rhg pre-some-read dirstate-v2-append
303 262 $ cat $TESTTMP/status-race-lock.out
304 263 A dir/o
305 264 R dir/nested/m
306 265 ? dir/n
307 266 ? p
308 267 ? q
309 268 $ cat $TESTTMP/status-race-lock.log
310 269 #else
311 270 $ cat $TESTTMP/status-race-lock.out
312 ? dir/n
313 ? p
314 ? q
315 $ cat $TESTTMP/status-race-lock.log
316 #endif
317 #endif
318 #else
319 #if rust
320 #if dirstate-v2-rewrite
321 $ cat $TESTTMP/status-race-lock.out
322 M dir/o
271 M dir/o (no-rhg known-bad-output !)
323 272 ? dir/n
324 273 ? p
325 274 ? q
326 275 $ cat $TESTTMP/status-race-lock.log
327 warning: ignoring unknown working parent 02a67a77ee9b!
328 #else
329 $ cat $TESTTMP/status-race-lock.out
330 A dir/o
331 R dir/nested/m
332 ? dir/n
333 ? p
334 ? q
335 $ cat $TESTTMP/status-race-lock.log
336 #endif
337 #else
338 $ cat $TESTTMP/status-race-lock.out
339 M dir/o
340 ? dir/n
341 ? p
342 ? q
343 $ cat $TESTTMP/status-race-lock.log
344 warning: ignoring unknown working parent 02a67a77ee9b!
345 #endif
276 warning: ignoring unknown working parent 02a67a77ee9b! (no-rhg !)
346 277 #endif
347 278 #endif
348 279
349 280 final cleanup
350 281
351 282 $ rm $TESTTMP/status-race-lock $TESTTMP/status-race-lock.waiting
352 283 $ cd ..
353 284
354 285 Race with a `hg update`
355 286 -----------------------
356 287
357 288 $ cp -a reference-repo race-with-update
358 289 $ cd race-with-update
359 290
360 291 spin a `hg status` with some caches to update
361 292
362 293 $ hg st >$TESTTMP/status-race-lock.out 2>$TESTTMP/status-race-lock.log \
363 294 > --config rhg.on-unsupported=abort \
364 295 > --config ${cfg}=$TESTTMP/status-race-lock \
365 296 > &
366 297 $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/status-race-lock.waiting
367 298 do an update
368 299
369 300 $ hg status
370 301 A dir/o
371 302 R dir/nested/m
372 303 ? dir/n
373 304 ? p
374 305 ? q
375 306 $ hg log -GT '{node|short} {desc}\n'
376 307 @ 9a86dcbfb938 more files to have two commit
377 308 |
378 309 o 4f23db756b09 recreate a bunch of files to facilitate dirstate-v2 append
379 310
380 311 $ hg $d2args update --merge ".~1"
381 312 0 files updated, 0 files merged, 6 files removed, 0 files unresolved
382 313 $ touch $TESTTMP/status-race-lock
383 314 $ wait
384 315 #if rhg dirstate-v2-append pre-some-read
385 316 $ hg log -GT '{node|short} {desc}\n'
386 317 @ 9a86dcbfb938 more files to have two commit
387 318 |
388 319 o 4f23db756b09 recreate a bunch of files to facilitate dirstate-v2 append
389 320
390 321 $ hg status
391 322 A dir/o
392 323 R dir/nested/m
393 324 ! dir/i
394 325 ! dir/j
395 326 ! dir/nested/h
396 327 ! dir2/k
397 328 ! dir2/l
398 329 ! g
399 330 ? dir/n
400 331 ? p
401 332 ? q
402 333 #else
403 334 $ hg log -GT '{node|short} {desc}\n'
404 335 o 9a86dcbfb938 more files to have two commit
405 336 |
406 337 @ 4f23db756b09 recreate a bunch of files to facilitate dirstate-v2 append
407 338
408 339 $ hg status
409 340 A dir/o
410 341 ? dir/n
411 342 ? p
412 343 ? q
413 344 #endif
414 345
415 346 The status process should return a consistent result and not crash.
416 347
417 #if dirstate-v1
418 $ cat $TESTTMP/status-race-lock.out
419 A dir/o
420 ? dir/n
421 ? p
422 ? q
423 $ cat $TESTTMP/status-race-lock.log
424 #else
425 #if rhg
426 #if pre-all-read
427 $ cat $TESTTMP/status-race-lock.out
428 A dir/o
429 ? dir/n
430 ? p
431 ? q
432 $ cat $TESTTMP/status-race-lock.log
433 #else
434 #if dirstate-v2-append
348 #if rhg dirstate-v2-append pre-some-read
435 349 $ cat $TESTTMP/status-race-lock.out
436 350 A dir/o
437 351 R dir/nested/m
438 352 ! dir/i
439 353 ! dir/j
440 354 ! dir/nested/h
441 355 ! dir2/k
442 356 ! dir2/l
443 357 ! g
444 358 ? dir/n
445 359 ? p
446 360 ? q
447 $ cat $TESTTMP/status-race-lock.log
448 361 #else
449 $ cat $TESTTMP/status-race-lock.out
450 A dir/o
451 ? dir/n
452 ? p
453 ? q
454 $ cat $TESTTMP/status-race-lock.log
455 #endif
456 #endif
457 #else
458 #if rust
459 #if dirstate-v2-rewrite
460 $ cat $TESTTMP/status-race-lock.out
461 A dir/o
462 ? dir/n
463 ? p
464 ? q
465 $ cat $TESTTMP/status-race-lock.log
466 #else
362 #if rust no-rhg dirstate-v2-append
467 363 $ cat $TESTTMP/status-race-lock.out
468 364 A dir/o
469 365 R dir/nested/m
470 366 ! dir/i
471 367 ! dir/j
472 368 ! dir/nested/h
473 369 ! dir2/k
474 370 ! dir2/l
475 371 ! g
476 372 ? dir/n
477 373 ? p
478 374 ? q
479 $ cat $TESTTMP/status-race-lock.log
480 #endif
481 375 #else
482 376 $ cat $TESTTMP/status-race-lock.out
483 377 A dir/o
484 378 ? dir/n
485 379 ? p
486 380 ? q
487 $ cat $TESTTMP/status-race-lock.log
488 381 #endif
489 382 #endif
490 #endif
383 $ cat $TESTTMP/status-race-lock.log
491 384
492 385 final cleanup
493 386
494 387 $ rm $TESTTMP/status-race-lock $TESTTMP/status-race-lock.waiting
495 388 $ cd ..
496 389
497 390 Race with a cache updating `hg status`
498 391 --------------------------------------
499 392
500 393 It is interesting to race with "read-only" operation (that still update its cache)
501 394
502 395 $ cp -a reference-repo race-with-status
503 396 $ cd race-with-status
504 397
505 398 spin a `hg status` with some caches to update
506 399
507 400 $ hg st >$TESTTMP/status-race-lock.out 2>$TESTTMP/status-race-lock.log \
508 401 > --config rhg.on-unsupported=abort \
509 402 > --config ${cfg}=$TESTTMP/status-race-lock \
510 403 > &
511 404 $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/status-race-lock.waiting
512 405 do an update
513 406
514 407 $ touch -t 200001020006 f
515 408 $ hg $d2args status
516 409 A dir/o
517 410 R dir/nested/m
518 411 ? dir/n
519 412 ? p
520 413 ? q
521 414 $ touch $TESTTMP/status-race-lock
522 415 $ wait
523 416
524 417 The status process should return a consistent result and not crash.
525 418
526 #if dirstate-v1
527 $ cat $TESTTMP/status-race-lock.out
528 A dir/o
529 R dir/nested/m
530 ? dir/n
531 ? p
532 ? q
533 $ cat $TESTTMP/status-race-lock.log
534 #else
535 #if rhg
536 #if pre-all-read
537 $ cat $TESTTMP/status-race-lock.out
538 A dir/o
539 R dir/nested/m
540 ? dir/n
541 ? p
542 ? q
543 $ cat $TESTTMP/status-race-lock.log
544 #else
545 #if dirstate-v2-append
546 $ cat $TESTTMP/status-race-lock.out
547 A dir/o
548 R dir/nested/m
549 ? dir/n
550 ? p
551 ? q
552 $ cat $TESTTMP/status-race-lock.log
553 #else
554 419 $ cat $TESTTMP/status-race-lock.out
555 420 A dir/o
556 421 R dir/nested/m
557 422 ? dir/n
558 423 ? p
559 424 ? q
560 425 $ cat $TESTTMP/status-race-lock.log
561 #endif
562 #endif
563 #else
564 #if rust
565 #if dirstate-v2-rewrite
566 $ cat $TESTTMP/status-race-lock.out
567 A dir/o
568 R dir/nested/m
569 ? dir/n
570 ? p
571 ? q
572 $ cat $TESTTMP/status-race-lock.log
573 #else
574 $ cat $TESTTMP/status-race-lock.out
575 A dir/o
576 R dir/nested/m
577 ? dir/n
578 ? p
579 ? q
580 $ cat $TESTTMP/status-race-lock.log
581 #endif
582 #else
583 $ cat $TESTTMP/status-race-lock.out
584 A dir/o
585 R dir/nested/m
586 ? dir/n
587 ? p
588 ? q
589 $ cat $TESTTMP/status-race-lock.log
590 #endif
591 #endif
592 #endif
593 426
594 427 final cleanup
595 428
596 429 $ rm $TESTTMP/status-race-lock $TESTTMP/status-race-lock.waiting
597 430 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now