annotate tests/test-bookmarks-corner-case.t @ 50888:93cc085653fb

run-tests: detect HGWITHRUSTEXT value Without this, some manual check in tests/test-dirstate.t could get confused by the lack of `rust` in module policy and break the test.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Wed, 30 Aug 2023 12:24:12 +0200
parents e5efbb11e185
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 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 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
19
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
20 $ 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
21 $ 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
22 $ 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
23 $ 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
24 $ 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
25 $ 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
26 $ 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
27 $ 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
28 $ 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
29 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
30 (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
31 $ 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
32 $ 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
33 $ 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
34 $ 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
35 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
36 $ 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
37 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
38 (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
39 $ 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
40 $ 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
41 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
42 | 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
43 | tag: tip
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
44 | 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
45 | user: test
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
46 | 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
47 | summary: B0
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
48 |
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
49 | 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
50 |/ 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
51 | user: test
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
52 | 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
53 | summary: A0
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
54 |
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
55 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
56 user: test
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
57 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
58 summary: root
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
59
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
60 $ hg book
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
61 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
62 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
63 $ cd ..
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 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
66
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
67 $ 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
68 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
69 adding changesets
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
70 adding manifests
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
71 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
72 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
73 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
74 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
75 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
76 $ 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
77 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
78 (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
79 $ 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
80 $ 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
81 $ 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
82 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
83 adding changesets
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
84 adding manifests
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
85 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
86 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
87 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
88 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
89 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
90 $ 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
91 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
92 (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
93 $ 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
94 $ 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
95
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
96 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
97 -------------------------------
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
98
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
99 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
100
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
101 * 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
102 * 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
103 * 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
104 * 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
105
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
106 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
107
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
108 $ cat > bookrace.py << EOF
42389
055687fe4c47 tests: sort some imports that were previously missed
Augie Fackler <augie@google.com>
parents: 42324
diff changeset
109 > 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
110 > import os
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
111 > import time
42666
cfb774aae660 tests: sort imports in test-bookmarks-corner-case.t
Pulkit Goyal <pulkit@yandex-team.ru>
parents: 42624
diff changeset
112 > from mercurial import bookmarks, error, extensions
42507
febf5c8215c1 test: factor out the "wait" logic in bookrace
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42506
diff changeset
113 >
42508
c4d1807b165f test: add some assert in the bookrace extension
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42507
diff changeset
114 > 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
115 > 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
116 > 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
117 > 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
118 > 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
119 > 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
120 > pass
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
121 > clock = 300
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
122 > 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
123 > clock -= 1
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
124 > 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
125 > 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
126 > 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
127 >
42509
95c2f951e502 bookmarks: actually trigger the race deleting bookmark in the test
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42508
diff changeset
128 > 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
129 > 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
130 > @property
95c2f951e502 bookmarks: actually trigger the race deleting bookmark in the test
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42508
diff changeset
131 > 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
132 > 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
133 > 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
134 > 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
135 >
42322
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
136 > def e():
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
137 > 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
138 > pass
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
139 > 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
140 > EOF
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
141
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
142 Actual test
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
143 -----------
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 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
146
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
147 $ 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
148 > [extensions]
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
149 > 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
150 > EOF
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
151 $ 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
152
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
153 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
154
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
155 $ clock=30
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
156 $ 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
157 > 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
158 > sleep 1
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
159 > done
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
160
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
161 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
162
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
163 $ 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
164 > [extensions]
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
165 > bookrace=!
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
166 > EOF
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
167
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
168 $ 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
169 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
170 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
171 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
172 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
173 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
174 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
175 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
176
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
177 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
178
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
179 $ 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
180
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
181 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
182
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
183 $ 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
184 > 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
185 > sleep 1
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
186 > done
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 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
189
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
190 $ 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
191 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
192 searching for changes
42896
7e19b640c53e sshserver: flush stream after command dispatch
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42685
diff changeset
193 remote: setting raced push up
42682
e0cf09bc35ef bookmarks: actual fix for race condition deleting bookmark
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42624
diff changeset
194 remote has heads on branch 'default' that are not known locally: f26c3b5167d1
42322
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
195 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
196 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
197 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
198 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
199 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
200
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
201 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
202
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
203 $ 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
204 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
205 | 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
206 | tag: tip
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
207 | 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
208 | user: test
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
209 | 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
210 | summary: A1
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
211 |
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
212 | o changeset: 3:f26c3b5167d1
42682
e0cf09bc35ef bookmarks: actual fix for race condition deleting bookmark
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42624
diff changeset
213 | | 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
214 | | user: test
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
215 | | 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
216 | | summary: B1
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
217 | |
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
218 | 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
219 | | 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
220 | | user: test
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
221 | | 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
222 | | summary: B0
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
223 | |
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
224 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
225 |/ user: test
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
226 | 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
227 | summary: A0
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
228 |
d2c871b78c36 bookmark: add a test for a race condition on push
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
229 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
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: root
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 $ 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
235 book-A 4:9ce3b28c16de
42682
e0cf09bc35ef bookmarks: actual fix for race condition deleting bookmark
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 42624
diff changeset
236 book-B 3:f26c3b5167d1