Mercurial > hg
comparison tests/test-remotefilelog-http.t @ 40495:3a333a582d7b
remotefilelog: import pruned-down remotefilelog extension from hg-experimental
This is remotefilelog as of my recent patches for compatibility with
current tip of hg, minus support for old versions of Mercurial and
some FB-specific features like their treemanifest extension and
fetching linkrev data from a patched phabricator. The file extutil.py
moved from hgext3rd to remotefilelog.
This is not yet ready to be landed, consider it a preview for
now. Planned changes include:
* replace lz4 with zstd
* rename some capabilities, requirements and wireproto commands to mark
them as experimental
* consolidate bits of shallowutil with related functions (eg readfile)
I'm certainly open to other (small) changes, but my rough mission is
to land this largely as-is so we can use it as a model of the
functionality we need going forward for lazy-fetching of file contents
from a server.
# no-check-commit because of a few foo_bar functions
Differential Revision: https://phab.mercurial-scm.org/D4782
author | Augie Fackler <augie@google.com> |
---|---|
date | Thu, 27 Sep 2018 13:03:19 -0400 |
parents | |
children | e2a1584e9e3f |
comparison
equal
deleted
inserted
replaced
40494:9aeb9e2d28a7 | 40495:3a333a582d7b |
---|---|
1 $ PYTHONPATH=$TESTDIR/..:$PYTHONPATH | |
2 $ export PYTHONPATH | |
3 | |
4 $ . "$TESTDIR/remotefilelog-library.sh" | |
5 | |
6 $ hginit master | |
7 $ cd master | |
8 $ cat >> .hg/hgrc <<EOF | |
9 > [remotefilelog] | |
10 > server=True | |
11 > EOF | |
12 $ echo x > x | |
13 $ echo y > y | |
14 $ hg commit -qAm x | |
15 $ hg serve -p $HGPORT -d --pid-file=../hg1.pid -E ../error.log -A ../access.log | |
16 | |
17 Build a query string for later use: | |
18 $ GET=`hg debugdata -m 0 | $PYTHON -c \ | |
19 > 'import sys ; print [("?cmd=getfile&file=%s&node=%s" % tuple(s.split("\0"))) for s in sys.stdin.read().splitlines()][0]'` | |
20 | |
21 $ cd .. | |
22 $ cat hg1.pid >> $DAEMON_PIDS | |
23 | |
24 $ hgcloneshallow http://localhost:$HGPORT/ shallow -q | |
25 2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob) | |
26 | |
27 $ grep getfile access.log | |
28 * "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=getfile+*node%3D1406e74118627694268417491f018a4a883152f0* (glob) | |
29 | |
30 Clear filenode cache so we can test fetching with a modified batch size | |
31 $ rm -r $TESTTMP/hgcache | |
32 Now do a fetch with a large batch size so we're sure it works | |
33 $ hgcloneshallow http://localhost:$HGPORT/ shallow-large-batch \ | |
34 > --config remotefilelog.batchsize=1000 -q | |
35 2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob) | |
36 | |
37 The 'remotefilelog' capability should *not* be exported over http(s), | |
38 as the getfile method it offers doesn't work with http. | |
39 $ get-with-headers.py localhost:$HGPORT '?cmd=capabilities' | grep lookup | identifyrflcaps | |
40 getfile | |
41 getflogheads | |
42 | |
43 $ get-with-headers.py localhost:$HGPORT '?cmd=hello' | grep lookup | identifyrflcaps | |
44 getfile | |
45 getflogheads | |
46 | |
47 $ get-with-headers.py localhost:$HGPORT '?cmd=this-command-does-not-exist' | head -n 1 | |
48 400 no such method: this-command-does-not-exist | |
49 $ get-with-headers.py localhost:$HGPORT '?cmd=getfiles' | head -n 1 | |
50 400 no such method: getfiles | |
51 | |
52 Verify serving from a shallow clone doesn't allow for remotefile | |
53 fetches. This also serves to test the error handling for our batchable | |
54 getfile RPC. | |
55 | |
56 $ cd shallow | |
57 $ hg serve -p $HGPORT1 -d --pid-file=../hg2.pid -E ../error2.log | |
58 $ cd .. | |
59 $ cat hg2.pid >> $DAEMON_PIDS | |
60 | |
61 This GET should work, because this server is serving master, which is | |
62 a full clone. | |
63 | |
64 $ get-with-headers.py localhost:$HGPORT "$GET" | |
65 200 Script output follows | |
66 | |
67 0\x00U\x00\x00\x00\xff (esc) | |
68 2\x00x (esc) | |
69 \x14\x06\xe7A\x18bv\x94&\x84\x17I\x1f\x01\x8aJ\x881R\xf0\x00\x01\x00\x14\xf0\x06T\xd8\xef\x99"\x04\xd01\xe6\xa6i\xf4~\x98\xb3\xe3Dw>T\x00 (no-eol) (esc) | |
70 | |
71 This GET should fail using the in-band signalling mechanism, because | |
72 it's not a full clone. Note that it's also plausible for servers to | |
73 refuse to serve file contents for other reasons, like the file | |
74 contents not being visible to the current user. | |
75 | |
76 $ get-with-headers.py localhost:$HGPORT1 "$GET" | |
77 200 Script output follows | |
78 | |
79 1\x00cannot fetch remote files from shallow repo (no-eol) (esc) | |
80 | |
81 Clones should work with httppostargs turned on | |
82 | |
83 $ cd master | |
84 $ hg --config experimental.httppostargs=1 serve -p $HGPORT2 -d --pid-file=../hg3.pid -E ../error3.log | |
85 | |
86 $ cd .. | |
87 $ cat hg3.pid >> $DAEMON_PIDS | |
88 | |
89 Clear filenode cache so we can test fetching with a modified batch size | |
90 $ rm -r $TESTTMP/hgcache | |
91 | |
92 $ hgcloneshallow http://localhost:$HGPORT2/ shallow-postargs -q | |
93 2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob) | |
94 | |
95 All error logs should be empty: | |
96 $ cat error.log | |
97 $ cat error2.log | |
98 $ cat error3.log |