##// END OF EJS Templates
merge with stable
Augie Fackler -
r42541:ffab9eed merge default
parent child Browse files
Show More
@@ -0,0 +1,238 b''
1 ================================
2 Test corner case around bookmark
3 ================================
4
5 This test file is meant to gather test around bookmark that are specific
6 enough to not find a place elsewhere.
7
8 Test bookmark/changelog race condition
9 ======================================
10
11 The data from the bookmark file are filtered to only contains bookmark with
12 node known to the changelog. If the cache invalidation between these two bits
13 goes wrong, bookmark can be dropped.
14
15 global setup
16 ------------
17
18 $ cat >> $HGRCPATH << EOF
19 > [ui]
20 > ssh = "$PYTHON" "$TESTDIR/dummyssh"
21 > [server]
22 > concurrent-push-mode=check-related
23 > EOF
24
25 Setup
26 -----
27
28 initial repository setup
29
30 $ hg init bookrace-server
31 $ cd bookrace-server
32 $ echo a > a
33 $ hg add a
34 $ hg commit -m root
35 $ echo a >> a
36 $ hg bookmark book-A
37 $ hg commit -m A0
38 $ hg up 'desc(root)'
39 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
40 (leaving bookmark book-A)
41 $ echo b > b
42 $ hg add b
43 $ hg bookmark book-B
44 $ hg commit -m B0
45 created new head
46 $ hg up null
47 0 files updated, 0 files merged, 2 files removed, 0 files unresolved
48 (leaving bookmark book-B)
49 $ hg phase --public --rev 'all()'
50 $ hg log -G
51 o changeset: 2:c79985706978
52 | bookmark: book-B
53 | tag: tip
54 | parent: 0:6569b5a81c7e
55 | user: test
56 | date: Thu Jan 01 00:00:00 1970 +0000
57 | summary: B0
58 |
59 | o changeset: 1:39c28d785860
60 |/ bookmark: book-A
61 | user: test
62 | date: Thu Jan 01 00:00:00 1970 +0000
63 | summary: A0
64 |
65 o changeset: 0:6569b5a81c7e
66 user: test
67 date: Thu Jan 01 00:00:00 1970 +0000
68 summary: root
69
70 $ hg book
71 book-A 1:39c28d785860
72 book-B 2:c79985706978
73 $ cd ..
74
75 Add new changeset on each bookmark in distinct clones
76
77 $ hg clone ssh://user@dummy/bookrace-server client-A
78 requesting all changes
79 adding changesets
80 adding manifests
81 adding file changes
82 added 3 changesets with 3 changes to 2 files (+1 heads)
83 new changesets 6569b5a81c7e:c79985706978
84 updating to branch default
85 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
86 $ hg -R client-A update book-A
87 1 files updated, 0 files merged, 1 files removed, 0 files unresolved
88 (activating bookmark book-A)
89 $ echo a >> client-A/a
90 $ hg -R client-A commit -m A1
91 $ hg clone ssh://user@dummy/bookrace-server client-B
92 requesting all changes
93 adding changesets
94 adding manifests
95 adding file changes
96 added 3 changesets with 3 changes to 2 files (+1 heads)
97 new changesets 6569b5a81c7e:c79985706978
98 updating to branch default
99 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
100 $ hg -R client-B update book-B
101 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
102 (activating bookmark book-B)
103 $ echo b >> client-B/b
104 $ hg -R client-B commit -m B1
105
106 extension to reproduce the race
107 -------------------------------
108
109 If two process are pushing we want to make sure the following happens:
110
111 * process A read changelog
112 * process B to its full push
113 * process A read bookmarks
114 * process A proceed with rest of the push
115
116 We build a server side extension for this purpose
117
118 $ cat > bookrace.py << EOF
119 > import os
120 > import time
121 > import atexit
122 > from mercurial import error, extensions, bookmarks
123 > def wrapinit(orig, self, repo):
124 > if not os.path.exists('push-A-started'):
125 > print('setting raced push up')
126 > with open('push-A-started', 'w'):
127 > pass
128 > clock = 300
129 > while not os.path.exists('push-B-done'):
130 > clock -= 1
131 > if clock <= 0:
132 > raise error.Abort("race scenario timed out")
133 > time.sleep(0.1)
134 > return orig(self, repo)
135 >
136 > repo.__class__ = racedrepo
137 > def uisetup(ui):
138 > extensions.wrapfunction(bookmarks.bmstore, '__init__', wrapinit)
139 > def e():
140 > with open('push-A-done', 'w'):
141 > pass
142 > atexit.register(e)
143 > EOF
144
145 Actual test
146 -----------
147
148 Start the raced push.
149
150 $ cat >> bookrace-server/.hg/hgrc << EOF
151 > [extensions]
152 > bookrace=$TESTTMP/bookrace.py
153 > EOF
154 $ hg push -R client-A -r book-A >push-output.txt 2>&1 &
155
156 Wait up to 30 seconds for that push to start.
157
158 $ clock=30
159 $ while [ ! -f push-A-started ] && [ $clock -gt 0 ] ; do
160 > clock=`expr $clock - 1`
161 > sleep 1
162 > done
163
164 Do the other push.
165
166 $ cat >> bookrace-server/.hg/hgrc << EOF
167 > [extensions]
168 > bookrace=!
169 > EOF
170
171 $ hg push -R client-B -r book-B
172 pushing to ssh://user@dummy/bookrace-server
173 searching for changes
174 remote: adding changesets
175 remote: adding manifests
176 remote: adding file changes
177 remote: added 1 changesets with 1 changes to 1 files
178 updating bookmark book-B
179
180 Signal the raced put that we are done (it waits up to 30 seconds).
181
182 $ touch push-B-done
183
184 Wait for the raced push to finish (with the remaning of the initial 30 seconds).
185
186 $ while [ ! -f push-A-done ] && [ $clock -gt 0 ] ; do
187 > clock=`expr $clock - 1`
188 > sleep 1
189 > done
190
191 Check raced push output.
192
193 $ cat push-output.txt
194 pushing to ssh://user@dummy/bookrace-server
195 searching for changes
196 remote: setting raced push up
197 remote: adding changesets
198 remote: adding manifests
199 remote: adding file changes
200 remote: added 1 changesets with 1 changes to 1 files
201 updating bookmark book-A
202
203 Check result of the push.
204
205 $ hg -R bookrace-server log -G
206 o changeset: 4:9ce3b28c16de
207 | bookmark: book-A
208 | tag: tip
209 | parent: 1:39c28d785860
210 | user: test
211 | date: Thu Jan 01 00:00:00 1970 +0000
212 | summary: A1
213 |
214 | o changeset: 3:f26c3b5167d1
215 | | bookmark: book-B
216 | | user: test
217 | | date: Thu Jan 01 00:00:00 1970 +0000
218 | | summary: B1
219 | |
220 | o changeset: 2:c79985706978
221 | | parent: 0:6569b5a81c7e
222 | | user: test
223 | | date: Thu Jan 01 00:00:00 1970 +0000
224 | | summary: B0
225 | |
226 o | changeset: 1:39c28d785860
227 |/ user: test
228 | date: Thu Jan 01 00:00:00 1970 +0000
229 | summary: A0
230 |
231 o changeset: 0:6569b5a81c7e
232 user: test
233 date: Thu Jan 01 00:00:00 1970 +0000
234 summary: root
235
236 $ hg -R bookrace-server book
237 book-A 4:9ce3b28c16de
238 book-B 3:f26c3b5167d1
@@ -1226,7 +1226,7 b' class localrepository(object):'
1226 return cls(self, name, visibilityexceptions)
1226 return cls(self, name, visibilityexceptions)
1227
1227
1228 @mixedrepostorecache(('bookmarks', ''), ('bookmarks.current', ''),
1228 @mixedrepostorecache(('bookmarks', ''), ('bookmarks.current', ''),
1229 ('bookmarks', 'store'))
1229 ('bookmarks', 'store'), ('00changelog.i', 'store'))
1230 def _bookmarks(self):
1230 def _bookmarks(self):
1231 return bookmarks.bmstore(self)
1231 return bookmarks.bmstore(self)
1232
1232
@@ -111,6 +111,7 b' checking zlib options'
111 > done
111 > done
112
112
113 $ $RUNTESTDIR/f -s */.hg/store/data/*
113 $ $RUNTESTDIR/f -s */.hg/store/data/*
114 default/.hg/store/data/foo.i: size=64 (pure !)
114 zlib-level-1/.hg/store/data/a.i: size=4146
115 zlib-level-1/.hg/store/data/a.i: size=4146
115 zlib-level-9/.hg/store/data/a.i: size=4138
116 zlib-level-9/.hg/store/data/a.i: size=4138
116 zlib-level-default/.hg/store/data/a.i: size=4138
117 zlib-level-default/.hg/store/data/a.i: size=4138
@@ -138,6 +139,8 b' Test error cases'
138 abort: invalid value for `storage.revlog.zlib.level` config: 42
139 abort: invalid value for `storage.revlog.zlib.level` config: 42
139 [255]
140 [255]
140
141
142 #if zstd
143
141 checking zstd options
144 checking zstd options
142 =====================
145 =====================
143
146
@@ -193,3 +196,4 b' Test error cases'
193 abort: invalid value for `storage.revlog.zstd.level` config: 42
196 abort: invalid value for `storage.revlog.zstd.level` config: 42
194 [255]
197 [255]
195
198
199 #endif
General Comments 0
You need to be logged in to leave comments. Login now