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