Mercurial > hg
annotate tests/test-dirstate.t @ 35428:71427ff1dff8
workers: handling exceptions in windows workers
This adds handling of exceptions from worker threads and resurfaces them as if the function ran without workers.
If any of the threads throws, the main thread kills all running threads giving them 5 sec to handle the interruption and raises the first exception received.
We don't have to join threads if is_alive() is false
Test Plan:
Ran multiple updates/enable/disable sparse profile and things worked well
Ran test on CentOS- all tests passing on @ passed here
Added a forged exception into the worker code and got it properly resurfaced and the rest of workers killed: P58642088
PS C:\open\<repo>> ..\facebook-hg-rpms\build\hg\hg.exe --config extensions.fsmonitor=! sparse --enable-profile <profile>
updating [==> ] 1300/39166 1m57sException in thread Thread-3:
Traceback (most recent call last):
File "C:\open\facebook-hg-rpms\build\hg\hg-python\lib\threading.py", line 801, in __bootstrap_inner
self.run()
File "C:\open\facebook-hg-rpms\build\hg\mercurial\worker.py", line 244, in run
raise e
Exception: Forged exception
Exception in thread Thread-2:
Traceback (most recent call last):
File "C:\open\facebook-hg-rpms\build\hg\hg-python\lib\threading.py", line 801, in __bootstrap_inner
self.run()
File "C:\open\facebook-hg-rpms\build\hg\mercurial\worker.py", line 244, in run
raise e
Exception: Forged exception
<...>
Traceback (most recent call last):
File "C:\open\facebook-hg-rpms\build\hg\hgexe.py", line 41, in <module>
dispatch.run()
File "C:\open\facebook-hg-rpms\build\hg\mercurial\dispatch.py", line 85, in run
status = (dispatch(req) or 0) & 255
File "C:\open\facebook-hg-rpms\build\hg\mercurial\dispatch.py", line 173, in dispatch
ret = _runcatch(req)
File "C:\open\facebook-hg-rpms\build\hg\mercurial\dispatch.py", line 324, in _runcatch
return _callcatch(ui, _runcatchfunc)
File "C:\open\facebook-hg-rpms\build\hg\mercurial\dispatch.py", line 332, in _callcatch
return scmutil.callcatch(ui, func)
File "C:\open\facebook-hg-rpms\build\hg\mercurial\scmutil.py", line 154, in callcatch
return func()
File "C:\open\facebook-hg-rpms\build\hg\mercurial\dispatch.py", line 314, in _runcatchfunc
return _dispatch(req)
File "C:\open\facebook-hg-rpms\build\hg\mercurial\dispatch.py", line 951, in _dispatch
cmdpats, cmdoptions)
File "C:\open\facebook-hg-rpms\build\hg\hg-python\lib\site-packages\remotefilelog\__init__.py", line 415, in runcommand
return orig(lui, repo, *args, **kwargs)
File "C:\open\facebook-hg-rpms\build\hg\hg-python\lib\site-packages\hgext3rd\undo.py", line 118, in _runcommandwrapper
result = orig(lui, repo, cmd, fullargs, *args)
File "C:\open\facebook-hg-rpms\build\hg\hgext\journal.py", line 84, in runcommand
return orig(lui, repo, cmd, fullargs, *args)
File "C:\open\facebook-hg-rpms\build\hg\hg-python\lib\site-packages\hgext3rd\perftweaks.py", line 268, in _tracksparseprofiles
res = runcommand(lui, repo, *args)
File "C:\open\facebook-hg-rpms\build\hg\hg-python\lib\site-packages\hgext3rd\perftweaks.py", line 256, in _trackdirstatesizes
res = runcommand(lui, repo, *args)
File "C:\open\facebook-hg-rpms\build\hg\hg-python\lib\site-packages\hgext3rd\copytrace.py", line 144, in _runcommand
return orig(lui, repo, cmd, fullargs, ui, *args, **kwargs)
File "C:\open\facebook-hg-rpms\build\hg\hg-python\lib\site-packages\hgext3rd\fbamend\hiddenoverride.py", line 119, in runcommand
result = orig(lui, repo, cmd, fullargs, *args)
File "C:\open\facebook-hg-rpms\build\hg\mercurial\dispatch.py", line 712, in runcommand
ret = _runcommand(ui, options, cmd, d)
File "C:\open\facebook-hg-rpms\build\hg\mercurial\dispatch.py", line 959, in _runcommand
return cmdfunc()
File "C:\open\facebook-hg-rpms\build\hg\mercurial\dispatch.py", line 948, in <lambda>
d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
File "C:\open\facebook-hg-rpms\build\hg\mercurial\util.py", line 1183, in check
return func(*args, **kwargs)
File "C:\open\facebook-hg-rpms\build\hg\hg-python\lib\site-packages\hgext3rd\fbsparse.py", line 860, in sparse
disableprofile=disableprofile, force=force)
File "C:\open\facebook-hg-rpms\build\hg\hg-python\lib\site-packages\hgext3rd\fbsparse.py", line 949, in _config
len, _refresh(ui, repo, oldstatus, oldsparsematch, force))
File "C:\open\facebook-hg-rpms\build\hg\hg-python\lib\site-packages\hgext3rd\fbsparse.py", line 1116, in _refresh
mergemod.applyupdates(repo, typeactions, repo[None], repo['.'], False)
File "C:\open\facebook-hg-rpms\build\hg\hg-python\lib\site-packages\remotefilelog\__init__.py", line 311, in applyupdates
return orig(repo, actions, wctx, mctx, overwrite, labels=labels)
File "C:\open\facebook-hg-rpms\build\hg\mercurial\merge.py", line 1464, in applyupdates
for i, item in prog:
File "C:\open\facebook-hg-rpms\build\hg\mercurial\worker.py", line 286, in _windowsworker
raise t.exception
Exception: Forged exception
PS C:\open\ovrsource>
Differential Revision: https://phab.mercurial-scm.org/D1459
author | Wojciech Lis <wlis@fb.com> |
---|---|
date | Mon, 20 Nov 2017 10:27:41 -0800 |
parents | 4441705b7111 |
children | 87a34c767384 |
rev | line source |
---|---|
11888
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
1 ------ Test dirstate._dirs refcounting |
7096
6dab29f6df37
dirstate._dirs: fix refcounting broken by 7dfac37cfabf
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
diff
changeset
|
2 |
11887
76818b28ce98
tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents:
7096
diff
changeset
|
3 $ hg init t |
76818b28ce98
tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents:
7096
diff
changeset
|
4 $ cd t |
76818b28ce98
tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents:
7096
diff
changeset
|
5 $ mkdir -p a/b/c/d |
76818b28ce98
tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents:
7096
diff
changeset
|
6 $ touch a/b/c/d/x |
76818b28ce98
tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents:
7096
diff
changeset
|
7 $ touch a/b/c/d/y |
76818b28ce98
tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents:
7096
diff
changeset
|
8 $ touch a/b/c/d/z |
76818b28ce98
tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents:
7096
diff
changeset
|
9 $ hg ci -Am m |
76818b28ce98
tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents:
7096
diff
changeset
|
10 adding a/b/c/d/x |
76818b28ce98
tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents:
7096
diff
changeset
|
11 adding a/b/c/d/y |
76818b28ce98
tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents:
7096
diff
changeset
|
12 adding a/b/c/d/z |
76818b28ce98
tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents:
7096
diff
changeset
|
13 $ hg mv a z |
35393
4441705b7111
tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents:
33954
diff
changeset
|
14 moving a/b/c/d/x to z/b/c/d/x |
4441705b7111
tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents:
33954
diff
changeset
|
15 moving a/b/c/d/y to z/b/c/d/y |
4441705b7111
tests: remove (glob) annotations that were only for '\' matches
Matt Harbison <matt_harbison@yahoo.com>
parents:
33954
diff
changeset
|
16 moving a/b/c/d/z to z/b/c/d/z |
17095
45cf6a91a02d
dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents:
15447
diff
changeset
|
17 |
45cf6a91a02d
dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents:
15447
diff
changeset
|
18 Test name collisions |
45cf6a91a02d
dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents:
15447
diff
changeset
|
19 |
45cf6a91a02d
dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents:
15447
diff
changeset
|
20 $ rm z/b/c/d/x |
45cf6a91a02d
dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents:
15447
diff
changeset
|
21 $ mkdir z/b/c/d/x |
45cf6a91a02d
dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents:
15447
diff
changeset
|
22 $ touch z/b/c/d/x/y |
45cf6a91a02d
dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents:
15447
diff
changeset
|
23 $ hg add z/b/c/d/x/y |
45cf6a91a02d
dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents:
15447
diff
changeset
|
24 abort: file 'z/b/c/d/x' in dirstate clashes with 'z/b/c/d/x/y' |
45cf6a91a02d
dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents:
15447
diff
changeset
|
25 [255] |
45cf6a91a02d
dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents:
15447
diff
changeset
|
26 $ rm -rf z/b/c/d |
45cf6a91a02d
dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents:
15447
diff
changeset
|
27 $ touch z/b/c/d |
45cf6a91a02d
dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents:
15447
diff
changeset
|
28 $ hg add z/b/c/d |
45cf6a91a02d
dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents:
15447
diff
changeset
|
29 abort: directory 'z/b/c/d' already in dirstate |
45cf6a91a02d
dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents:
15447
diff
changeset
|
30 [255] |
45cf6a91a02d
dirstate: add dir/file collision test
Joshua Redstone <joshua.redstone@fb.com>
parents:
15447
diff
changeset
|
31 |
11888
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
32 $ cd .. |
11887
76818b28ce98
tests: unify test-dirstatedirs
Adrian Buehlmann <adrian@cadifra.com>
parents:
7096
diff
changeset
|
33 |
12399
4fee1fd3de9a
tests: added a short description to issue numbers
Martin Geisler <mg@aragost.com>
parents:
11888
diff
changeset
|
34 Issue1790: dirstate entry locked into unset if file mtime is set into |
4fee1fd3de9a
tests: added a short description to issue numbers
Martin Geisler <mg@aragost.com>
parents:
11888
diff
changeset
|
35 the future |
11888
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
36 |
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
37 Prepare test repo: |
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
38 |
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
39 $ hg init u |
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
40 $ cd u |
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
41 $ echo a > a |
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
42 $ hg add |
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
43 adding a |
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
44 $ hg ci -m1 |
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
45 |
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
46 Set mtime of a into the future: |
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
47 |
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
48 $ touch -t 202101011200 a |
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
49 |
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
50 Status must not set a's entry to unset (issue1790): |
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
51 |
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
52 $ hg status |
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
53 $ hg debugstate |
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
54 n 644 2 2021-01-01 12:00:00 a |
17733
3c775c5a6c03
dirstate: handle large dates and times with masking (issue2608)
Matt Mackall <mpm@selenic.com>
parents:
17095
diff
changeset
|
55 |
3c775c5a6c03
dirstate: handle large dates and times with masking (issue2608)
Matt Mackall <mpm@selenic.com>
parents:
17095
diff
changeset
|
56 Test modulo storage/comparison of absurd dates: |
11888
2bd699886ffc
tests: combine test-dirstate-future.t
Adrian Buehlmann <adrian@cadifra.com>
parents:
11887
diff
changeset
|
57 |
19092
8c560ad1cdc4
tests: AIX can't handle negative date in test-dirstate.t
Jim Hague <jim.hague@acm.org>
parents:
17737
diff
changeset
|
58 #if no-aix |
17733
3c775c5a6c03
dirstate: handle large dates and times with masking (issue2608)
Matt Mackall <mpm@selenic.com>
parents:
17095
diff
changeset
|
59 $ touch -t 195001011200 a |
3c775c5a6c03
dirstate: handle large dates and times with masking (issue2608)
Matt Mackall <mpm@selenic.com>
parents:
17095
diff
changeset
|
60 $ hg st |
3c775c5a6c03
dirstate: handle large dates and times with masking (issue2608)
Matt Mackall <mpm@selenic.com>
parents:
17095
diff
changeset
|
61 $ hg debugstate |
3c775c5a6c03
dirstate: handle large dates and times with masking (issue2608)
Matt Mackall <mpm@selenic.com>
parents:
17095
diff
changeset
|
62 n 644 2 2018-01-19 15:14:08 a |
19092
8c560ad1cdc4
tests: AIX can't handle negative date in test-dirstate.t
Jim Hague <jim.hague@acm.org>
parents:
17737
diff
changeset
|
63 #endif |
22406
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
64 |
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
65 Verify that exceptions during a dirstate change leave the dirstate |
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
66 coherent (issue4353) |
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
67 |
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
68 $ cat > ../dirstateexception.py <<EOF |
33954
b9765319880e
tests: update test-dirstate to pass our import checker
Augie Fackler <raf@durin42.com>
parents:
26587
diff
changeset
|
69 > from __future__ import absolute_import |
b9765319880e
tests: update test-dirstate to pass our import checker
Augie Fackler <raf@durin42.com>
parents:
26587
diff
changeset
|
70 > from mercurial import ( |
b9765319880e
tests: update test-dirstate to pass our import checker
Augie Fackler <raf@durin42.com>
parents:
26587
diff
changeset
|
71 > error, |
b9765319880e
tests: update test-dirstate to pass our import checker
Augie Fackler <raf@durin42.com>
parents:
26587
diff
changeset
|
72 > extensions, |
b9765319880e
tests: update test-dirstate to pass our import checker
Augie Fackler <raf@durin42.com>
parents:
26587
diff
changeset
|
73 > merge, |
b9765319880e
tests: update test-dirstate to pass our import checker
Augie Fackler <raf@durin42.com>
parents:
26587
diff
changeset
|
74 > ) |
22406
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
75 > |
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
76 > def wraprecordupdates(orig, repo, actions, branchmerge): |
26587
56b2bcea2529
error: get Abort from 'error' instead of 'util'
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22406
diff
changeset
|
77 > raise error.Abort("simulated error while recording dirstateupdates") |
22406
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
78 > |
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
79 > def reposetup(ui, repo): |
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
80 > extensions.wrapfunction(merge, 'recordupdates', wraprecordupdates) |
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
81 > EOF |
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
82 |
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
83 $ hg rm a |
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
84 $ hg commit -m 'rm a' |
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
85 $ echo "[extensions]" >> .hg/hgrc |
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
86 $ echo "dirstateex=../dirstateexception.py" >> .hg/hgrc |
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
87 $ hg up 0 |
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
88 abort: simulated error while recording dirstateupdates |
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
89 [255] |
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
90 $ hg log -r . -T '{rev}\n' |
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
91 1 |
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
92 $ hg status |
2e47e461d2ca
dirstate: add test for exceptions during updates
Durham Goode <durham@fb.com>
parents:
19092
diff
changeset
|
93 ? a |