Debian Codegraph @

tests/test-remotefilelog-http.t

raw
1 #require no-windows
2
3 $ . "$TESTDIR/remotefilelog-library.sh"
4
5 $ hg init master
6 $ cd master
7 $ cat >> .hg/hgrc <<EOF
8 > [remotefilelog]
9 > server=True
10 > EOF
11 $ echo x > x
12 $ echo y > y
13 $ hg commit -qAm x
14 $ hg serve -p $HGPORT -d --pid-file=../hg1.pid -E ../error.log -A ../access.log
15
16 Build a query string for later use:
17 $ GET=`hg debugdata -m 0 | "$PYTHON" -c \
18 > 'import sys ; print([("?cmd=x_rfl_getfile&file=%s&node=%s" % tuple(s.split("\0"))) for s in sys.stdin.read().splitlines()][0])'`
19
20 $ cd ..
21 $ cat hg1.pid >> $DAEMON_PIDS
22
23 $ hgcloneshallow http://localhost:$HGPORT/ shallow -q
24 2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob)
25
26 $ grep getfile access.log
27 * "GET /?cmd=batch HTTP/1.1" 200 - x-hgarg-1:cmds=x_rfl_getfile+*node%3D1406e74118627694268417491f018a4a883152f0* (glob)
28
29 Clear filenode cache so we can test fetching with a modified batch size
30 $ rm -r $TESTTMP/hgcache
31 Now do a fetch with a large batch size so we're sure it works
32 $ hgcloneshallow http://localhost:$HGPORT/ shallow-large-batch \
33 > --config remotefilelog.batchsize=1000 -q
34 2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob)
35
36 The 'remotefilelog' capability should *not* be exported over http(s),
37 as the getfile method it offers doesn't work with http.
38 $ get-with-headers.py localhost:$HGPORT '?cmd=capabilities' | grep lookup | identifyrflcaps
39 x_rfl_getfile
40 x_rfl_getflogheads
41
42 $ get-with-headers.py localhost:$HGPORT '?cmd=hello' | grep lookup | identifyrflcaps
43 x_rfl_getfile
44 x_rfl_getflogheads
45
46 $ get-with-headers.py localhost:$HGPORT '?cmd=this-command-does-not-exist' | head -n 1
47 400 method not found
48 $ get-with-headers.py localhost:$HGPORT '?cmd=x_rfl_getfiles' | head -n 1
49 400 method not found
50
51 Verify serving from a shallow clone doesn't allow for remotefile
52 fetches. This also serves to test the error handling for our batchable
53 getfile RPC.
54
55 $ cd shallow
56 $ hg serve -p $HGPORT1 -d --pid-file=../hg2.pid -E ../error2.log
57 $ cd ..
58 $ cat hg2.pid >> $DAEMON_PIDS
59
60 This GET should work, because this server is serving master, which is
61 a full clone.
62
63 $ get-with-headers.py localhost:$HGPORT "$GET"
64 200 Script output follows
65
66 0\x00x\x9c3b\xa8\xe0\x12a{\xee(\x91T6E\xadE\xdcS\x9e\xb1\xcb\xab\xc30\xe8\x03\x03\x91 \xe4\xc6\xfb\x99J,\x17\x0c\x9f-\xcb\xfcR7c\xf3c\x97r\xbb\x10\x06\x00\x96m\x121 (no-eol) (esc)
67
68 This GET should fail using the in-band signalling mechanism, because
69 it's not a full clone. Note that it's also plausible for servers to
70 refuse to serve file contents for other reasons, like the file
71 contents not being visible to the current user.
72
73 $ get-with-headers.py localhost:$HGPORT1 "$GET"
74 200 Script output follows
75
76 1\x00cannot fetch remote files from shallow repo (no-eol) (esc)
77
78 Clones should work with httppostargs turned on
79
80 $ cd master
81 $ hg --config experimental.httppostargs=1 serve -p $HGPORT2 -d --pid-file=../hg3.pid -E ../error3.log
82
83 $ cd ..
84 $ cat hg3.pid >> $DAEMON_PIDS
85
86 Clear filenode cache so we can test fetching with a modified batch size
87 $ rm -r $TESTTMP/hgcache
88
89 $ hgcloneshallow http://localhost:$HGPORT2/ shallow-postargs -q
90 2 files fetched over 1 fetches - (2 misses, 0.00% hit ratio) over *s (glob)
91
92 All error logs should be empty:
93 $ cat error.log
94 $ cat error2.log
95 $ cat error3.log