Mercurial > hg
annotate tests/test-bookmarks-corner-case.t @ 42324:2338bdea4474 stable
bookmark: also make bookmark cache depends of the changelog
Since the changelog is also used during the parsing of bookmark data, it should
be listed as a file cache dependency. This fix the race condition we just
introduced a test for.
This is a simple fix that might lead bookmark data to be invalidated more often
than necessary. We could have more complicated code to deal with this race in a
more "optimal" way. I feel it would be unsuitable for stable.
In addition, the performance impact of this is probably minimal and I don't
foresee the more advanced fix to actually be necessary.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 20 May 2019 10:08:28 +0200 |
parents | d2c871b78c36 |
children | 055687fe4c47 cd73e51a1f8a |
rev | line source |
---|---|
42322
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
1 ================================ |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
2 Test corner case around bookmark |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
3 ================================ |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
4 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
5 This test file is meant to gather test around bookmark that are specific |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
6 enough to not find a place elsewhere. |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
7 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
8 Test bookmark/changelog race condition |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
9 ====================================== |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
10 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
11 The data from the bookmark file are filtered to only contains bookmark with |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
12 node known to the changelog. If the cache invalidation between these two bits |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
13 goes wrong, bookmark can be dropped. |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
14 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
15 global setup |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
16 ------------ |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
17 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
18 $ cat >> $HGRCPATH << EOF |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
19 > [ui] |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
20 > ssh = "$PYTHON" "$TESTDIR/dummyssh" |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
21 > [server] |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
22 > concurrent-push-mode=check-related |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
23 > EOF |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
24 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
25 Setup |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
26 ----- |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
27 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
28 initial repository setup |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
29 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
30 $ hg init bookrace-server |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
31 $ cd bookrace-server |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
32 $ echo a > a |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
33 $ hg add a |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
34 $ hg commit -m root |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
35 $ echo a >> a |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
36 $ hg bookmark book-A |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
37 $ hg commit -m A0 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
38 $ hg up 'desc(root)' |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
39 1 files updated, 0 files merged, 0 files removed, 0 files unresolved |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
40 (leaving bookmark book-A) |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
41 $ echo b > b |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
42 $ hg add b |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
43 $ hg bookmark book-B |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
44 $ hg commit -m B0 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
45 created new head |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
46 $ hg up null |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
47 0 files updated, 0 files merged, 2 files removed, 0 files unresolved |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
48 (leaving bookmark book-B) |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
49 $ hg phase --public --rev 'all()' |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
50 $ hg log -G |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
51 o changeset: 2:c79985706978 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
52 | bookmark: book-B |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
53 | tag: tip |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
54 | parent: 0:6569b5a81c7e |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
55 | user: test |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
56 | date: Thu Jan 01 00:00:00 1970 +0000 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
57 | summary: B0 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
58 | |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
59 | o changeset: 1:39c28d785860 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
60 |/ bookmark: book-A |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
61 | user: test |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
62 | date: Thu Jan 01 00:00:00 1970 +0000 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
63 | summary: A0 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
64 | |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
65 o changeset: 0:6569b5a81c7e |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
66 user: test |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
67 date: Thu Jan 01 00:00:00 1970 +0000 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
68 summary: root |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
69 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
70 $ hg book |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
71 book-A 1:39c28d785860 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
72 book-B 2:c79985706978 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
73 $ cd .. |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
74 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
75 Add new changeset on each bookmark in distinct clones |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
76 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
77 $ hg clone ssh://user@dummy/bookrace-server client-A |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
78 requesting all changes |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
79 adding changesets |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
80 adding manifests |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
81 adding file changes |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
82 added 3 changesets with 3 changes to 2 files (+1 heads) |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
83 new changesets 6569b5a81c7e:c79985706978 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
84 updating to branch default |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
85 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
86 $ hg -R client-A update book-A |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
87 1 files updated, 0 files merged, 1 files removed, 0 files unresolved |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
88 (activating bookmark book-A) |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
89 $ echo a >> client-A/a |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
90 $ hg -R client-A commit -m A1 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
91 $ hg clone ssh://user@dummy/bookrace-server client-B |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
92 requesting all changes |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
93 adding changesets |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
94 adding manifests |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
95 adding file changes |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
96 added 3 changesets with 3 changes to 2 files (+1 heads) |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
97 new changesets 6569b5a81c7e:c79985706978 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
98 updating to branch default |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
99 2 files updated, 0 files merged, 0 files removed, 0 files unresolved |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
100 $ hg -R client-B update book-B |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
101 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
102 (activating bookmark book-B) |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
103 $ echo b >> client-B/b |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
104 $ hg -R client-B commit -m B1 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
105 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
106 extension to reproduce the race |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
107 ------------------------------- |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
108 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
109 If two process are pushing we want to make sure the following happens: |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
110 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
111 * process A read changelog |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
112 * process B to its full push |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
113 * process A read bookmarks |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
114 * process A proceed with rest of the push |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
115 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
116 We build a server side extension for this purpose |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
117 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
118 $ cat > bookrace.py << EOF |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
119 > import os |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
120 > import time |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
121 > import atexit |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
122 > from mercurial import error, extensions, bookmarks |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
123 > def wrapinit(orig, self, repo): |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
124 > if not os.path.exists('push-A-started'): |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
125 > print('setting raced push up') |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
126 > with open('push-A-started', 'w'): |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
127 > pass |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
128 > clock = 300 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
129 > while not os.path.exists('push-B-done'): |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
130 > clock -= 1 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
131 > if clock <= 0: |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
132 > raise error.Abort("race scenario timed out") |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
133 > time.sleep(0.1) |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
134 > return orig(self, repo) |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
135 > |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
136 > repo.__class__ = racedrepo |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
137 > def uisetup(ui): |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
138 > extensions.wrapfunction(bookmarks.bmstore, '__init__', wrapinit) |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
139 > def e(): |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
140 > with open('push-A-done', 'w'): |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
141 > pass |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
142 > atexit.register(e) |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
143 > EOF |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
144 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
145 Actual test |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
146 ----------- |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
147 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
148 Start the raced push. |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
149 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
150 $ cat >> bookrace-server/.hg/hgrc << EOF |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
151 > [extensions] |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
152 > bookrace=$TESTTMP/bookrace.py |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
153 > EOF |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
154 $ hg push -R client-A -r book-A >push-output.txt 2>&1 & |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
155 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
156 Wait up to 30 seconds for that push to start. |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
157 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
158 $ clock=30 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
159 $ while [ ! -f push-A-started ] && [ $clock -gt 0 ] ; do |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
160 > clock=`expr $clock - 1` |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
161 > sleep 1 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
162 > done |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
163 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
164 Do the other push. |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
165 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
166 $ cat >> bookrace-server/.hg/hgrc << EOF |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
167 > [extensions] |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
168 > bookrace=! |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
169 > EOF |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
170 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
171 $ hg push -R client-B -r book-B |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
172 pushing to ssh://user@dummy/bookrace-server |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
173 searching for changes |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
174 remote: adding changesets |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
175 remote: adding manifests |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
176 remote: adding file changes |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
177 remote: added 1 changesets with 1 changes to 1 files |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
178 updating bookmark book-B |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
179 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
180 Signal the raced put that we are done (it waits up to 30 seconds). |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
181 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
182 $ touch push-B-done |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
183 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
184 Wait for the raced push to finish (with the remaning of the initial 30 seconds). |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
185 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
186 $ while [ ! -f push-A-done ] && [ $clock -gt 0 ] ; do |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
187 > clock=`expr $clock - 1` |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
188 > sleep 1 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
189 > done |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
190 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
191 Check raced push output. |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
192 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
193 $ cat push-output.txt |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
194 pushing to ssh://user@dummy/bookrace-server |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
195 searching for changes |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
196 remote: setting raced push up |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
197 remote: adding changesets |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
198 remote: adding manifests |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
199 remote: adding file changes |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
200 remote: added 1 changesets with 1 changes to 1 files |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
201 updating bookmark book-A |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
202 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
203 Check result of the push. |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
204 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
205 $ hg -R bookrace-server log -G |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
206 o changeset: 4:9ce3b28c16de |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
207 | bookmark: book-A |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
208 | tag: tip |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
209 | parent: 1:39c28d785860 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
210 | user: test |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
211 | date: Thu Jan 01 00:00:00 1970 +0000 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
212 | summary: A1 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
213 | |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
214 | o changeset: 3:f26c3b5167d1 |
42324
2338bdea4474
bookmark: also make bookmark cache depends of the changelog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42322
diff
changeset
|
215 | | bookmark: book-B |
42322
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
216 | | user: test |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
217 | | date: Thu Jan 01 00:00:00 1970 +0000 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
218 | | summary: B1 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
219 | | |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
220 | o changeset: 2:c79985706978 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
221 | | parent: 0:6569b5a81c7e |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
222 | | user: test |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
223 | | date: Thu Jan 01 00:00:00 1970 +0000 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
224 | | summary: B0 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
225 | | |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
226 o | changeset: 1:39c28d785860 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
227 |/ user: test |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
228 | date: Thu Jan 01 00:00:00 1970 +0000 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
229 | summary: A0 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
230 | |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
231 o changeset: 0:6569b5a81c7e |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
232 user: test |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
233 date: Thu Jan 01 00:00:00 1970 +0000 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
234 summary: root |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
235 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
236 $ hg -R bookrace-server book |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
237 book-A 4:9ce3b28c16de |
42324
2338bdea4474
bookmark: also make bookmark cache depends of the changelog
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42322
diff
changeset
|
238 book-B 3:f26c3b5167d1 |