Debian Codegraph @

tests/test-largefiles-wireproto.t

raw
1 This file contains testcases that tend to be related to the wire protocol part
2 of largefiles.
3
4 $ USERCACHE="$TESTTMP/cache"; export USERCACHE
5 $ mkdir "${USERCACHE}"
6 $ cat >> $HGRCPATH <<EOF
7 > [extensions]
8 > largefiles=
9 > purge=
10 > rebase=
11 > transplant=
12 > [phases]
13 > publish=False
14 > [largefiles]
15 > minsize=2
16 > patterns=glob:**.dat
17 > usercache=${USERCACHE}
18 > [web]
19 > allow-archive = zip
20 > [hooks]
21 > precommit=sh -c "echo \\"Invoking status precommit hook\\"; hg status"
22 > EOF
23
24
25 #if serve
26 vanilla clients not locked out from largefiles servers on vanilla repos
27 $ mkdir r1
28 $ cd r1
29 $ hg init
30 $ echo c1 > f1
31 $ hg add f1
32 $ hg commit -m "m1"
33 Invoking status precommit hook
34 A f1
35 $ cd ..
36 $ hg serve -R r1 -d -p $HGPORT --pid-file hg.pid
37 $ cat hg.pid >> $DAEMON_PIDS
38 $ hg --config extensions.largefiles=! clone http://localhost:$HGPORT r2
39 requesting all changes
40 adding changesets
41 adding manifests
42 adding file changes
43 added 1 changesets with 1 changes to 1 files
44 new changesets b6eb3a2e2efe (1 drafts)
45 updating to branch default
46 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
47
48 largefiles clients still work with vanilla servers
49 $ hg serve --config extensions.largefiles=! -R r1 -d -p $HGPORT1 --pid-file hg.pid
50 $ cat hg.pid >> $DAEMON_PIDS
51 $ hg clone http://localhost:$HGPORT1 r3
52 requesting all changes
53 adding changesets
54 adding manifests
55 adding file changes
56 added 1 changesets with 1 changes to 1 files
57 new changesets b6eb3a2e2efe (1 drafts)
58 updating to branch default
59 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
60 #endif
61
62 vanilla clients locked out from largefiles http repos
63 $ mkdir r4
64 $ cd r4
65 $ hg init
66 $ echo c1 > f1
67 $ hg add --large f1
68 $ hg commit -m "m1"
69 Invoking status precommit hook
70 A f1
71 $ cd ..
72
73 largefiles can be pushed locally (issue3583)
74 $ hg init dest
75 $ cd r4
76 $ hg outgoing ../dest
77 comparing with ../dest
78 searching for changes
79 changeset: 0:639881c12b4c
80 tag: tip
81 user: test
82 date: Thu Jan 01 00:00:00 1970 +0000
83 summary: m1
84
85 $ hg push ../dest
86 pushing to ../dest
87 searching for changes
88 adding changesets
89 adding manifests
90 adding file changes
91 added 1 changesets with 1 changes to 1 files
92
93 exit code with nothing outgoing (issue3611)
94 $ hg outgoing ../dest
95 comparing with ../dest
96 searching for changes
97 no changes found
98 [1]
99 $ cd ..
100
101 #if serve
102 $ hg serve -R r4 -d -p $HGPORT2 --pid-file hg.pid
103 $ cat hg.pid >> $DAEMON_PIDS
104 $ hg --config extensions.largefiles=! clone http://localhost:$HGPORT2 r5
105 abort: remote error:
106
107 This repository uses the largefiles extension.
108
109 Please enable it in your Mercurial config file.
110 [100]
111
112 used all HGPORTs, kill all daemons
113 $ killdaemons.py
114 #endif
115
116 vanilla clients locked out from largefiles ssh repos
117 $ hg --config extensions.largefiles=! clone ssh://user@dummy/r4 r5
118 remote:
119 remote: This repository uses the largefiles extension.
120 remote:
121 remote: Please enable it in your Mercurial config file.
122 remote:
123 remote: -
124 abort: remote error
125 (check previous remote output)
126 [100]
127
128 #if serve
129
130 largefiles clients refuse to push largefiles repos to vanilla servers
131 $ mkdir r6
132 $ cd r6
133 $ hg init
134 $ echo c1 > f1
135 $ hg add f1
136 $ hg commit -m "m1"
137 Invoking status precommit hook
138 A f1
139 $ cat >> .hg/hgrc <<!
140 > [web]
141 > push_ssl = false
142 > allow_push = *
143 > !
144 $ cd ..
145 $ hg clone r6 r7
146 updating to branch default
147 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
148 $ cd r7
149 $ echo c2 > f2
150 $ hg add --large f2
151 $ hg commit -m "m2"
152 Invoking status precommit hook
153 A f2
154 $ hg verify --large -q
155 $ hg serve --config extensions.largefiles=! -R ../r6 -d -p $HGPORT --pid-file ../hg.pid
156 $ cat ../hg.pid >> $DAEMON_PIDS
157 $ hg push http://localhost:$HGPORT
158 pushing to http://localhost:$HGPORT/
159 searching for changes
160 abort: http://localhost:$HGPORT/ does not appear to be a largefile store
161 [255]
162 $ cd ..
163
164 putlfile errors are shown (issue3123)
165 Corrupt the cached largefile in r7 and move it out of the servers usercache
166 $ mv r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8 .
167 $ echo 'client side corruption' > r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8
168 $ rm "$USERCACHE/4cdac4d8b084d0b599525cf732437fb337d422a8"
169 $ hg init empty
170 $ hg serve -R empty -d -p $HGPORT1 --pid-file hg.pid \
171 > --config 'web.allow_push=*' --config web.push_ssl=False
172 $ cat hg.pid >> $DAEMON_PIDS
173 $ hg push -R r7 http://localhost:$HGPORT1
174 pushing to http://localhost:$HGPORT1/
175 searching for changes
176 remote: largefiles: failed to put 4cdac4d8b084d0b599525cf732437fb337d422a8 into store: largefile contents do not match hash
177 abort: remotestore: could not put $TESTTMP/r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8 to remote store http://localhost:$HGPORT1/
178 [255]
179 $ mv 4cdac4d8b084d0b599525cf732437fb337d422a8 r7/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8
180 Push of file that exists on server but is corrupted - magic healing would be nice ... but too magic
181 $ echo "server side corruption" > empty/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8
182 $ hg push -R r7 http://localhost:$HGPORT1
183 pushing to http://localhost:$HGPORT1/
184 searching for changes
185 remote: adding changesets
186 remote: adding manifests
187 remote: adding file changes
188 remote: added 2 changesets with 2 changes to 2 files
189 $ cat empty/.hg/largefiles/4cdac4d8b084d0b599525cf732437fb337d422a8
190 server side corruption
191 $ rm -rf empty
192
193 Push a largefiles repository to a served empty repository
194 $ hg init r8
195 $ echo c3 > r8/f1
196 $ hg add --large r8/f1 -R r8
197 $ hg commit -m "m1" -R r8
198 Invoking status precommit hook
199 A f1
200 $ hg init empty
201 $ hg serve -R empty -d -p $HGPORT2 --pid-file hg.pid \
202 > --config 'web.allow_push=*' --config web.push_ssl=False
203 $ cat hg.pid >> $DAEMON_PIDS
204 $ rm "${USERCACHE}"/*
205 $ hg push -R r8 http://localhost:$HGPORT2/#default
206 pushing to http://localhost:$HGPORT2/
207 searching for changes
208 remote: adding changesets
209 remote: adding manifests
210 remote: adding file changes
211 remote: added 1 changesets with 1 changes to 1 files
212 $ [ -f "${USERCACHE}"/02a439e5c31c526465ab1a0ca1f431f76b827b90 ]
213 $ [ -f empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 ]
214
215 Clone over http, no largefiles pulled on clone.
216
217 $ hg clone http://localhost:$HGPORT2/#default http-clone -U
218 adding changesets
219 adding manifests
220 adding file changes
221 added 1 changesets with 1 changes to 1 files
222 new changesets cf03e5bb9936 (1 drafts)
223
224 Archive contains largefiles
225 >>> import os
226 >>> from mercurial import urllibcompat
227 >>> u = 'http://localhost:%s/archive/default.zip' % os.environ['HGPORT2']
228 >>> with open('archive.zip', 'wb') as f:
229 ... f.write(urllibcompat.urlreq.urlopen(u).read()) and None
230 $ unzip -t archive.zip
231 Archive: archive.zip
232 testing: empty-default/.hg_archival.txt*OK (glob)
233 testing: empty-default/f1*OK (glob)
234 No errors detected in compressed data of archive.zip.
235
236 test 'verify' with remotestore:
237
238 $ rm "${USERCACHE}"/02a439e5c31c526465ab1a0ca1f431f76b827b90
239 $ mv empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 .
240 $ hg -R http-clone verify --large --lfa
241 checking changesets
242 checking manifests
243 crosschecking files in changesets and manifests
244 checking files
245 checking dirstate
246 checked 1 changesets with 1 changes to 1 files
247 searching 1 changesets for largefiles
248 changeset 0:cf03e5bb9936: f1 missing
249 verified existence of 1 revisions of 1 largefiles
250 [1]
251 $ mv 02a439e5c31c526465ab1a0ca1f431f76b827b90 empty/.hg/largefiles/
252 $ hg -R http-clone -q verify --large --lfa
253
254 largefiles pulled on update - a largefile missing on the server:
255 $ mv empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 .
256 $ hg -R http-clone up --config largefiles.usercache=http-clone-usercache
257 getting changed largefiles
258 f1: largefile 02a439e5c31c526465ab1a0ca1f431f76b827b90 not available from http://localhost:$HGPORT2/
259 0 largefiles updated, 0 removed
260 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
261 $ hg -R http-clone st
262 ! f1
263 $ hg -R http-clone up -Cqr null
264
265 largefiles pulled on update - a largefile corrupted on the server:
266 $ echo corruption > empty/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90
267 $ hg -R http-clone up --config largefiles.usercache=http-clone-usercache
268 getting changed largefiles
269 f1: data corruption (expected 02a439e5c31c526465ab1a0ca1f431f76b827b90, got 6a7bb2556144babe3899b25e5428123735bb1e27)
270 0 largefiles updated, 0 removed
271 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
272 $ hg -R http-clone st
273 ! f1
274 $ [ ! -f http-clone/.hg/largefiles/02a439e5c31c526465ab1a0ca1f431f76b827b90 ]
275 $ [ ! -f http-clone/f1 ]
276 $ [ ! -f http-clone-usercache ]
277 $ hg -R http-clone verify --large --lfc -q
278 $ hg -R http-clone up -Cqr null
279
280 largefiles pulled on update - no server side problems:
281 $ mv 02a439e5c31c526465ab1a0ca1f431f76b827b90 empty/.hg/largefiles/
282 $ hg -R http-clone --debug up --config largefiles.usercache=http-clone-usercache --config progress.debug=true
283 resolving manifests
284 branchmerge: False, force: False, partial: False
285 ancestor: 000000000000, local: 000000000000+, remote: cf03e5bb9936
286 .hglf/f1: remote created -> g
287 getting .hglf/f1
288 updating: .hglf/f1 1/1 files (100.00%)
289 getting changed largefiles
290 using http://localhost:$HGPORT2/
291 sending capabilities command
292 sending statlfile command
293 getting largefiles: 0/1 files (0.00%)
294 getting f1:02a439e5c31c526465ab1a0ca1f431f76b827b90
295 sending getlfile command
296 found 02a439e5c31c526465ab1a0ca1f431f76b827b90 in store
297 1 largefiles updated, 0 removed
298 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
299
300 $ ls http-clone-usercache/*
301 http-clone-usercache/02a439e5c31c526465ab1a0ca1f431f76b827b90
302
303 $ rm -rf empty http-clone*
304
305 used all HGPORTs, kill all daemons
306 $ killdaemons.py
307
308 largefiles should batch verify remote calls
309
310 $ hg init batchverifymain
311 $ cd batchverifymain
312 $ echo "aaa" >> a
313 $ hg add --large a
314 $ hg commit -m "a"
315 Invoking status precommit hook
316 A a
317 $ echo "bbb" >> b
318 $ hg add --large b
319 $ hg commit -m "b"
320 Invoking status precommit hook
321 A b
322 $ cd ..
323 $ hg serve -R batchverifymain -d -p $HGPORT --pid-file hg.pid \
324 > -A access.log
325 $ cat hg.pid >> $DAEMON_PIDS
326 $ hg clone --noupdate http://localhost:$HGPORT batchverifyclone
327 requesting all changes
328 adding changesets
329 adding manifests
330 adding file changes
331 added 2 changesets with 2 changes to 2 files
332 new changesets 567253b0f523:04d19c27a332 (2 drafts)
333 $ hg -R batchverifyclone verify --large --lfa -q
334 $ tail -1 access.log
335 $LOCALIP - - [$LOGDATE$] "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=statlfile+sha%3D972a1a11f19934401291cc99117ec614933374ce%3Bstatlfile+sha%3Dc801c9cfe94400963fcb683246217d5db77f9a9a x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
336 $ hg -R batchverifyclone update
337 getting changed largefiles
338 2 largefiles updated, 0 removed
339 2 files updated, 0 files merged, 0 files removed, 0 files unresolved
340
341 Clear log file before next test
342
343 $ printf "" > access.log
344
345 Verify should check file on remote server only when file is not
346 available locally.
347
348 $ echo "ccc" >> batchverifymain/c
349 $ hg -R batchverifymain status
350 ? c
351 $ hg -R batchverifymain add --large batchverifymain/c
352 $ hg -R batchverifymain commit -m "c"
353 Invoking status precommit hook
354 A c
355 $ hg -R batchverifyclone pull
356 pulling from http://localhost:$HGPORT/
357 searching for changes
358 adding changesets
359 adding manifests
360 adding file changes
361 added 1 changesets with 1 changes to 1 files
362 new changesets 6bba8cb6935d (1 drafts)
363 (run 'hg update' to get a working copy)
364 $ hg -R batchverifyclone verify --lfa -q
365 $ tail -1 access.log
366 $LOCALIP - - [$LOGDATE$] "GET /?cmd=statlfile HTTP/1.1" 200 - x-hgarg-1:sha=c8559c3c9cfb42131794b7d8009230403b9b454c x-hgproto-1:0.1 0.2 comp=$USUAL_COMPRESSIONS$ partial-pull (glob)
367
368 $ killdaemons.py
369
370 largefiles should not ask for password again after successful authorization
371
372 $ hg init credentialmain
373 $ cd credentialmain
374 $ echo "aaa" >> a
375 $ hg add --large a
376 $ hg commit -m "a"
377 Invoking status precommit hook
378 A a
379
380 Before running server clear the user cache to force clone to download
381 a large file from the server rather than to get it from the cache
382
383 $ rm "${USERCACHE}"/*
384
385 $ cd ..
386
387 $ hg serve --config extensions.x=$TESTDIR/httpserverauth.py -R credentialmain \
388 > -d -p $HGPORT --pid-file hg.pid -A access.log
389 $ cat hg.pid >> $DAEMON_PIDS
390 $ cat << EOF > get_pass.py
391 > from mercurial import util
392 > def newgetpass():
393 > return "pass"
394 > util.get_password = newgetpass
395 > EOF
396 $ hg clone --config ui.interactive=true --config extensions.getpass=get_pass.py \
397 > http://user@localhost:$HGPORT credentialclone
398 http authorization required for http://localhost:$HGPORT/
399 realm: mercurial
400 user: user
401 password: requesting all changes
402 adding changesets
403 adding manifests
404 adding file changes
405 added 1 changesets with 1 changes to 1 files
406 new changesets 567253b0f523 (1 drafts)
407 updating to branch default
408 getting changed largefiles
409 1 largefiles updated, 0 removed
410 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
411
412 $ killdaemons.py
413 $ rm hg.pid access.log
414
415 #endif