Mercurial > hg
comparison tests/test-lfs-serve.t @ 35503:bbcd2e478391
test-lfs: add tests covering http exchanges
This tries to test every combination of having the extension enabled/disabled
on each side, and then push/pull/clone/identify lfs and non-lfs content. SSH is
ignored here, because there's enough going on as it is.
The root issue here is again that requirements are not exchanged and preserved
on push/pull/clone. Doing so should eliminate the cryptic error messages when
using `hg serve`. The 500 server error is triggered by "ValueError: no common
changegroup version", because the extension forces changegroup3. Or, if
changegroup3 is enabled manually, it is triggered by "abort: missing processor
for flag '0x2000'!".
Sadly, run-tests.py doesn't support conditionalizing the exit code like it does
lines of output. Therefore, a couple of tests blot out the exit code by
appending "|| true", since these failures will go away shortly anyway.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Sat, 23 Dec 2017 15:07:24 -0500 |
parents | |
children | 6bb940de4c4c |
comparison
equal
deleted
inserted
replaced
35502:67611e06ff08 | 35503:bbcd2e478391 |
---|---|
1 #testcases lfsremote-on lfsremote-off | |
2 #require serve | |
3 | |
4 This test splits `hg serve` with and without using the extension into separate | |
5 tests cases. The tests are broken down as follows, where "LFS"/"No-LFS" | |
6 indicates whether or not there are commits that use an LFS file, and "D"/"E" | |
7 indicates whether or not the extension is loaded. The "X" cases are not tested | |
8 individually, because the lfs requirement causes the process to bail early if | |
9 the extension is disabled. | |
10 | |
11 . Server | |
12 . | |
13 . No-LFS LFS | |
14 . +----------------------------+ | |
15 . | || D | E | D | E | | |
16 . |---++=======================| | |
17 . C | D || N/A | #1 | X | #4 | | |
18 . l No +---++-----------------------| | |
19 . i LFS | E || #2 | #2 | X | #5 | | |
20 . e +---++-----------------------| | |
21 . n | D || X | X | X | X | | |
22 . t LFS |---++-----------------------| | |
23 . | E || #3 | #3 | X | #6 | | |
24 . |---++-----------------------+ | |
25 | |
26 $ hg init server | |
27 $ SERVER_REQUIRES="$TESTTMP/server/.hg/requires" | |
28 | |
29 Skip the experimental.changegroup3=True config. Failure to agree on this comes | |
30 first, and causes a "ValueError: no common changegroup version" or "abort: | |
31 HTTP Error 500: Internal Server Error", if the extension is only loaded on one | |
32 side. If that *is* enabled, the subsequent failure is "abort: missing processor | |
33 for flag '0x2000'!" if the extension is only loaded on one side (possibly also | |
34 masked by the Internal Server Error message). | |
35 $ cat >> $HGRCPATH <<EOF | |
36 > [lfs] | |
37 > url=file:$TESTTMP/dummy-remote/ | |
38 > threshold=10 | |
39 > [web] | |
40 > allow_push=* | |
41 > push_ssl=False | |
42 > EOF | |
43 | |
44 #if lfsremote-on | |
45 $ hg --config extensions.lfs= -R server \ | |
46 > serve -p $HGPORT -d --pid-file=hg.pid --errorlog=$TESTTMP/errors.log | |
47 #else | |
48 $ hg --config extensions.lfs=! -R server \ | |
49 > serve -p $HGPORT -d --pid-file=hg.pid --errorlog=$TESTTMP/errors.log | |
50 #endif | |
51 | |
52 $ cat hg.pid >> $DAEMON_PIDS | |
53 $ hg clone -q http://localhost:$HGPORT client | |
54 $ grep 'lfs' client/.hg/requires $SERVER_REQUIRES | |
55 [1] | |
56 | |
57 -------------------------------------------------------------------------------- | |
58 Case #1: client with non-lfs content and the extension disabled; server with | |
59 non-lfs content, and the extension enabled. | |
60 | |
61 $ cd client | |
62 $ echo 'non-lfs' > nonlfs.txt | |
63 $ hg ci -Aqm 'non-lfs' | |
64 $ grep 'lfs' .hg/requires $SERVER_REQUIRES | |
65 [1] | |
66 | |
67 #if lfsremote-on | |
68 | |
69 $ hg push -q | |
70 $ grep 'lfs' .hg/requires $SERVER_REQUIRES | |
71 [1] | |
72 | |
73 TODO: fail more gracefully, or don't mandate changegroup3 for non-lfs repos. | |
74 | |
75 $ hg clone -q http://localhost:$HGPORT $TESTTMP/client1_clone | |
76 abort: HTTP Error 500: Internal Server Error | |
77 [255] | |
78 $ grep 'lfs' $TESTTMP/client1_clone/.hg/requires $SERVER_REQUIRES | |
79 grep: $TESTTMP/client1_clone/.hg/requires: $ENOENT$ | |
80 [2] | |
81 | |
82 TODO: fail more gracefully, or don't mandate changegroup3 for non-lfs repos. | |
83 | |
84 $ hg init $TESTTMP/client1_pull | |
85 $ hg -R $TESTTMP/client1_pull pull -q http://localhost:$HGPORT | |
86 abort: HTTP Error 500: Internal Server Error | |
87 [255] | |
88 $ grep 'lfs' $TESTTMP/client1_pull/.hg/requires $SERVER_REQUIRES | |
89 [1] | |
90 | |
91 $ hg identify http://localhost:$HGPORT | |
92 d437e1d24fbd | |
93 | |
94 #endif | |
95 | |
96 -------------------------------------------------------------------------------- | |
97 Case #2: client with non-lfs content and the extension enabled; server with | |
98 non-lfs content, and the extension state controlled by #testcases. | |
99 | |
100 $ cat >> $HGRCPATH <<EOF | |
101 > [extensions] | |
102 > lfs = | |
103 > EOF | |
104 $ echo 'non-lfs' > nonlfs2.txt | |
105 $ hg ci -Aqm 'non-lfs file with lfs client' | |
106 | |
107 TODO: fail more gracefully here | |
108 $ hg push -q 2>&1 | grep '^[A-Z]' || true | |
109 Traceback (most recent call last): (lfsremote-off !) | |
110 ValueError: no common changegroup version (lfsremote-off !) | |
111 $ grep 'lfs' .hg/requires $SERVER_REQUIRES | |
112 [1] | |
113 | |
114 $ hg clone -q http://localhost:$HGPORT $TESTTMP/client2_clone | |
115 $ grep 'lfs' $TESTTMP/client2_clone/.hg/requires $SERVER_REQUIRES | |
116 [1] | |
117 | |
118 $ hg init $TESTTMP/client2_pull | |
119 $ hg -R $TESTTMP/client2_pull pull -q http://localhost:$HGPORT | |
120 $ grep 'lfs' $TESTTMP/client2_pull/.hg/requires $SERVER_REQUIRES | |
121 [1] | |
122 | |
123 XXX: The difference here is the push failed above when the extension isn't | |
124 enabled on the server. The extension shouldn't need to mess with changegroup | |
125 versions if there is no lfs content. But the requirement needs to be | |
126 consistently added before that can be ratcheted back. | |
127 $ hg identify http://localhost:$HGPORT | |
128 1477875038c6 (lfsremote-on !) | |
129 000000000000 (lfsremote-off !) | |
130 | |
131 -------------------------------------------------------------------------------- | |
132 Case #3: client with lfs content and the extension enabled; server with | |
133 non-lfs content, and the extension state controlled by #testcases. | |
134 | |
135 TODO: add the 'lfs' requirement on the server for each test in lfsremote-on | |
136 $ echo 'this is a big lfs file' > lfs.bin | |
137 $ hg ci -Aqm 'lfs' | |
138 $ grep 'lfs' .hg/requires $SERVER_REQUIRES | |
139 .hg/requires:lfs | |
140 | |
141 TODO: fail more gracefully here | |
142 $ hg push -q 2>&1 | grep '^[A-Z]' || true | |
143 Traceback (most recent call last): (lfsremote-off !) | |
144 ValueError: no common changegroup version (lfsremote-off !) | |
145 $ grep 'lfs' .hg/requires $SERVER_REQUIRES | |
146 .hg/requires:lfs | |
147 | |
148 $ hg clone -q http://localhost:$HGPORT $TESTTMP/client3_clone | |
149 $ grep 'lfs' $TESTTMP/client3_clone/.hg/requires $SERVER_REQUIRES | |
150 [1] | |
151 | |
152 $ hg init $TESTTMP/client3_pull | |
153 $ hg -R $TESTTMP/client3_pull pull -q http://localhost:$HGPORT | |
154 $ grep 'lfs' $TESTTMP/client3_pull/.hg/requires $SERVER_REQUIRES | |
155 [1] | |
156 | |
157 XXX: The difference here is the push failed above when the extension isn't | |
158 enabled on the server. The extension shouldn't need to mess with changegroup | |
159 versions if there is no lfs content. But the requirement needs to be | |
160 consistently added before that can be ratcheted back. | |
161 $ hg identify http://localhost:$HGPORT | |
162 8374dc4052cb (lfsremote-on !) | |
163 000000000000 (lfsremote-off !) | |
164 | |
165 Don't bother testing the lfsremote-off cases- the server won't be able | |
166 to launch if there's lfs content and the extension is disabled. | |
167 | |
168 #if lfsremote-on | |
169 | |
170 -------------------------------------------------------------------------------- | |
171 Case #4: client with non-lfs content and the extension disabled; server with | |
172 lfs content, and the extension enabled. | |
173 | |
174 $ cat >> $HGRCPATH <<EOF | |
175 > [extensions] | |
176 > lfs = ! | |
177 > EOF | |
178 | |
179 $ hg init $TESTTMP/client4 | |
180 $ cd $TESTTMP/client4 | |
181 $ cat >> .hg/hgrc <<EOF | |
182 > [paths] | |
183 > default = http://localhost:$HGPORT | |
184 > EOF | |
185 $ echo 'non-lfs' > nonlfs2.txt | |
186 $ hg ci -Aqm 'non-lfs' | |
187 $ grep 'lfs' .hg/requires $SERVER_REQUIRES | |
188 [1] | |
189 | |
190 $ hg push -q --force | |
191 warning: repository is unrelated | |
192 $ grep 'lfs' .hg/requires $SERVER_REQUIRES | |
193 [1] | |
194 | |
195 TODO: fail more gracefully. | |
196 | |
197 $ hg clone -q http://localhost:$HGPORT $TESTTMP/client4_clone | |
198 abort: HTTP Error 500: Internal Server Error | |
199 [255] | |
200 $ grep 'lfs' $TESTTMP/client4_clone/.hg/requires $SERVER_REQUIRES | |
201 grep: $TESTTMP/client4_clone/.hg/requires: $ENOENT$ | |
202 [2] | |
203 | |
204 TODO: fail more gracefully. | |
205 | |
206 $ hg init $TESTTMP/client4_pull | |
207 $ hg -R $TESTTMP/client4_pull pull -q http://localhost:$HGPORT | |
208 abort: HTTP Error 500: Internal Server Error | |
209 [255] | |
210 $ grep 'lfs' $TESTTMP/client4_pull/.hg/requires $SERVER_REQUIRES | |
211 [1] | |
212 | |
213 $ hg identify http://localhost:$HGPORT | |
214 03b080fa9d93 | |
215 | |
216 -------------------------------------------------------------------------------- | |
217 Case #5: client with non-lfs content and the extension enabled; server with | |
218 lfs content, and the extension enabled. | |
219 | |
220 $ cat >> $HGRCPATH <<EOF | |
221 > [extensions] | |
222 > lfs = | |
223 > EOF | |
224 $ echo 'non-lfs' > nonlfs3.txt | |
225 $ hg ci -Aqm 'non-lfs file with lfs client' | |
226 | |
227 $ hg push -q | |
228 $ grep 'lfs' .hg/requires $SERVER_REQUIRES | |
229 [1] | |
230 | |
231 $ hg clone -q http://localhost:$HGPORT $TESTTMP/client5_clone | |
232 $ grep 'lfs' $TESTTMP/client5_clone/.hg/requires $SERVER_REQUIRES | |
233 [1] | |
234 | |
235 $ hg init $TESTTMP/client5_pull | |
236 $ hg -R $TESTTMP/client5_pull pull -q http://localhost:$HGPORT | |
237 $ grep 'lfs' $TESTTMP/client5_pull/.hg/requires $SERVER_REQUIRES | |
238 [1] | |
239 | |
240 $ hg identify http://localhost:$HGPORT | |
241 c729025cc5e3 | |
242 | |
243 -------------------------------------------------------------------------------- | |
244 Case #6: client with lfs content and the extension enabled; server with | |
245 lfs content, and the extension enabled. | |
246 | |
247 TODO: add the 'lfs' requirement on the server for each test | |
248 | |
249 $ echo 'this is another lfs file' > lfs2.txt | |
250 $ hg ci -Aqm 'lfs file with lfs client' | |
251 | |
252 $ hg push -q | |
253 $ grep 'lfs' .hg/requires $SERVER_REQUIRES | |
254 .hg/requires:lfs | |
255 | |
256 $ hg clone -q http://localhost:$HGPORT $TESTTMP/client6_clone | |
257 $ grep 'lfs' $TESTTMP/client6_clone/.hg/requires $SERVER_REQUIRES | |
258 [1] | |
259 | |
260 $ hg init $TESTTMP/client6_pull | |
261 $ hg -R $TESTTMP/client6_pull pull -q http://localhost:$HGPORT | |
262 $ grep 'lfs' $TESTTMP/client6_pull/.hg/requires $SERVER_REQUIRES | |
263 [1] | |
264 | |
265 $ hg identify http://localhost:$HGPORT | |
266 d3b84d50eacb | |
267 | |
268 -------------------------------------------------------------------------------- | |
269 Misc: process dies early if a requirement exists and the extension is disabled | |
270 | |
271 $ hg --config extensions.lfs=! summary | |
272 abort: repository requires features unknown to this Mercurial: lfs! | |
273 (see https://mercurial-scm.org/wiki/MissingRequirement for more information) | |
274 [255] | |
275 | |
276 #endif | |
277 | |
278 $ $PYTHON $TESTDIR/killdaemons.py $DAEMON_PIDS | |
279 | |
280 #if lfsremote-on | |
281 $ cat $TESTTMP/errors.log | grep '^[A-Z]' | |
282 Traceback (most recent call last): | |
283 ValueError: no common changegroup version | |
284 Traceback (most recent call last): | |
285 ValueError: no common changegroup version | |
286 Traceback (most recent call last): | |
287 ValueError: no common changegroup version | |
288 Traceback (most recent call last): | |
289 ValueError: no common changegroup version | |
290 #else | |
291 $ cat $TESTTMP/errors.log | |
292 #endif |