Mercurial > hg
annotate tests/test-bookmarks-corner-case.t @ 42546:904e0da2e195
merge with stable
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 30 Jun 2019 15:10:56 +0900 |
parents | 84aff7e20c55 2c27b7fadcd3 |
children | 811e502d646d |
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 |
42389
055687fe4c47
tests: sort some imports that were previously missed
Augie Fackler <augie@google.com>
parents:
42324
diff
changeset
|
119 > import atexit |
42322
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
120 > import os |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
121 > import time |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
122 > import atexit |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
123 > from mercurial import error, extensions, bookmarks |
42507
febf5c8215c1
test: factor out the "wait" logic in bookrace
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42506
diff
changeset
|
124 > |
42508
c4d1807b165f
test: add some assert in the bookrace extension
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42507
diff
changeset
|
125 > def wait(repo): |
42322
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
126 > if not os.path.exists('push-A-started'): |
42508
c4d1807b165f
test: add some assert in the bookrace extension
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42507
diff
changeset
|
127 > assert repo._currentlock(repo._lockref) is None |
c4d1807b165f
test: add some assert in the bookrace extension
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42507
diff
changeset
|
128 > assert repo._currentlock(repo._wlockref) is None |
42430
5b217451a2c2
py3: fix test-bookmarks-corner-case.t
Pulkit Goyal <pulkit@yandex-team.ru>
parents:
42389
diff
changeset
|
129 > repo.ui.status(b'setting raced push up\n') |
42322
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
130 > 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
|
131 > pass |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
132 > clock = 300 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
133 > 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
|
134 > clock -= 1 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
135 > 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
|
136 > 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
|
137 > time.sleep(0.1) |
42507
febf5c8215c1
test: factor out the "wait" logic in bookrace
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42506
diff
changeset
|
138 > |
42509
95c2f951e502
bookmarks: actually trigger the race deleting bookmark in the test
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42508
diff
changeset
|
139 > def reposetup(ui, repo): |
95c2f951e502
bookmarks: actually trigger the race deleting bookmark in the test
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42508
diff
changeset
|
140 > class racedrepo(repo.__class__): |
95c2f951e502
bookmarks: actually trigger the race deleting bookmark in the test
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42508
diff
changeset
|
141 > @property |
95c2f951e502
bookmarks: actually trigger the race deleting bookmark in the test
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42508
diff
changeset
|
142 > def _bookmarks(self): |
95c2f951e502
bookmarks: actually trigger the race deleting bookmark in the test
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42508
diff
changeset
|
143 > wait(self) |
95c2f951e502
bookmarks: actually trigger the race deleting bookmark in the test
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42508
diff
changeset
|
144 > return super(racedrepo, self)._bookmarks |
95c2f951e502
bookmarks: actually trigger the race deleting bookmark in the test
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42508
diff
changeset
|
145 > repo.__class__ = racedrepo |
95c2f951e502
bookmarks: actually trigger the race deleting bookmark in the test
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
42508
diff
changeset
|
146 > |
42322
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
147 > def e(): |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
148 > 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
|
149 > pass |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
150 > 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
|
151 > EOF |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
152 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
153 Actual test |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
154 ----------- |
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 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
|
157 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
158 $ 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
|
159 > [extensions] |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
160 > 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
|
161 > EOF |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
162 $ 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
|
163 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
164 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
|
165 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
166 $ clock=30 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
167 $ 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
|
168 > 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
|
169 > sleep 1 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
170 > done |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
171 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
172 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
|
173 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
174 $ 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
|
175 > [extensions] |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
176 > bookrace=! |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
177 > EOF |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
178 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
179 $ 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
|
180 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
|
181 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
|
182 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
|
183 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
|
184 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
|
185 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
|
186 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
|
187 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
188 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
|
189 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
190 $ 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
|
191 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
192 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
|
193 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
194 $ 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
|
195 > 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
|
196 > sleep 1 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
197 > done |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
198 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
199 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
|
200 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
201 $ 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
|
202 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
|
203 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
|
204 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
|
205 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
|
206 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
|
207 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
|
208 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
|
209 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
|
210 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
211 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
|
212 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
213 $ 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
|
214 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
|
215 | 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
|
216 | tag: tip |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
217 | 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
|
218 | user: test |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
219 | 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
|
220 | summary: A1 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
221 | |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
222 | o changeset: 3:f26c3b5167d1 |
42545
2c27b7fadcd3
bookmarks: backout the attempt to fix the delete race
Matt Harbison <matt_harbison@yahoo.com>
parents:
42511
diff
changeset
|
223 | | bookmark: book-B (false !) |
42322
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
224 | | user: test |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
225 | | 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
|
226 | | summary: B1 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
227 | | |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
228 | 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
|
229 | | 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
|
230 | | user: test |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
231 | | 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
|
232 | | summary: B0 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
233 | | |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
234 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
|
235 |/ user: test |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
236 | 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
|
237 | summary: A0 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
238 | |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
239 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
|
240 user: test |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
241 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
|
242 summary: root |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
243 |
d2c871b78c36
bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
244 $ 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
|
245 book-A 4:9ce3b28c16de |
42545
2c27b7fadcd3
bookmarks: backout the attempt to fix the delete race
Matt Harbison <matt_harbison@yahoo.com>
parents:
42511
diff
changeset
|
246 book-B 3:f26c3b5167d1 (false !) |