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