annotate tests/test-pull-pull-corruption.t @ 37048:fc5e261915b9

wireproto: require POST for all HTTPv2 requests Wire protocol version 1 transfers argument data via request headers by default. This has historically caused problems because servers institute limits on the length of individual HTTP headers as well as the total size of all request headers. Mercurial servers can advertise the maximum length of an individual header. But there's no guarantee any intermediate HTTP agents will accept headers up to that length. In the existing wire protocol, server operators typically also key off the HTTP request method to implement authentication. For example, GET requests translate to read-only requests and can be allowed. But read-write commands must use POST and require authentication. This has typically worked because the only wire protocol commands that use POST modify the repo (e.g. the "unbundle" command). There is an experimental feature to enable clients to transmit argument data via POST request bodies. This is technically a better and more robust solution. But we can't enable it by default because of servers assuming POST means write access. In version 2 of the wire protocol, the permissions of a request are encoded in the URL. And with it being a new protocol in a new URL space, we're not constrained by backwards compatibility requirements. This commit adopts the technically superior mechanism of using HTTP request bodies to send argument data by requiring POST for all commands. Strictly speaking, it may be possible to send request bodies on GET requests. But my experience is that not all HTTP stacks support this. POST pretty much always works. Using POST for read-only operations does sacrifice some RESTful design purity. But this API cares about practicality, not about being in Roy T. Fielding's REST ivory tower. There's a chance we may relax this restriction in the future. But for now, I want to see how far we can get with a POST only API. Differential Revision: https://phab.mercurial-scm.org/D2837
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 13 Mar 2018 11:57:43 -0700
parents eb586ed5d8ce
children f1186c292d03
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12481
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
1 Corrupt an hg repo with two pulls.
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
2 create one repo with a long history
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
3
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
4 $ hg init source1
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
5 $ cd source1
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
6 $ touch foo
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
7 $ hg add foo
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
8 $ for i in 1 2 3 4 5 6 7 8 9 10; do
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
9 > echo $i >> foo
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
10 > hg ci -m $i
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
11 > done
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
12 $ cd ..
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
13
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
14 create one repo with a shorter history
1785
81ca1a9bd061 Added test cases for repo corruption fixed in 2e0a288ca93e (issue132)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
15
12481
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
16 $ hg clone -r 0 source1 source2
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
17 adding changesets
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
18 adding manifests
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
19 adding file changes
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
20 added 1 changesets with 1 changes to 1 files
34661
eb586ed5d8ce transaction-summary: show the range of new revisions upon pull/unbundle (BC)
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 16913
diff changeset
21 new changesets 495a0ec48aaf
12481
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
22 updating to branch default
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
23 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
24 $ cd source2
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
25 $ echo a >> foo
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
26 $ hg ci -m a
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
27 $ cd ..
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
28
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
29 create a third repo to pull both other repos into it
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
30
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
31 $ hg init corrupted
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
32 $ cd corrupted
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
33
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
34 use a hook to make the second pull start while the first one is still running
1785
81ca1a9bd061 Added test cases for repo corruption fixed in 2e0a288ca93e (issue132)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
35
12481
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
36 $ echo '[hooks]' >> .hg/hgrc
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
37 $ echo 'prechangegroup = sleep 5' >> .hg/hgrc
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
38
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
39 start a pull...
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
40
16481
37e0872b5ced tests: remove race in test-pull-pull-corruption.t
Mads Kiilerich <mads@kiilerich.com>
parents: 13439
diff changeset
41 $ hg pull ../source1 > pull.out 2>&1 &
12481
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
42
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
43 ... and start another pull before the first one has finished
1785
81ca1a9bd061 Added test cases for repo corruption fixed in 2e0a288ca93e (issue132)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
44
12481
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
45 $ sleep 1
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
46 $ hg pull ../source2 2>/dev/null
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
47 pulling from ../source2
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
48 searching for changes
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
49 adding changesets
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
50 adding manifests
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
51 adding file changes
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
52 added 1 changesets with 1 changes to 1 files (+1 heads)
34661
eb586ed5d8ce transaction-summary: show the range of new revisions upon pull/unbundle (BC)
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 16913
diff changeset
53 new changesets ca3c05af513e
12481
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
54 (run 'hg heads' to see heads, 'hg merge' to merge)
16481
37e0872b5ced tests: remove race in test-pull-pull-corruption.t
Mads Kiilerich <mads@kiilerich.com>
parents: 13439
diff changeset
55 $ cat pull.out
37e0872b5ced tests: remove race in test-pull-pull-corruption.t
Mads Kiilerich <mads@kiilerich.com>
parents: 13439
diff changeset
56 pulling from ../source1
37e0872b5ced tests: remove race in test-pull-pull-corruption.t
Mads Kiilerich <mads@kiilerich.com>
parents: 13439
diff changeset
57 requesting all changes
37e0872b5ced tests: remove race in test-pull-pull-corruption.t
Mads Kiilerich <mads@kiilerich.com>
parents: 13439
diff changeset
58 adding changesets
37e0872b5ced tests: remove race in test-pull-pull-corruption.t
Mads Kiilerich <mads@kiilerich.com>
parents: 13439
diff changeset
59 adding manifests
37e0872b5ced tests: remove race in test-pull-pull-corruption.t
Mads Kiilerich <mads@kiilerich.com>
parents: 13439
diff changeset
60 adding file changes
37e0872b5ced tests: remove race in test-pull-pull-corruption.t
Mads Kiilerich <mads@kiilerich.com>
parents: 13439
diff changeset
61 added 10 changesets with 10 changes to 1 files
34661
eb586ed5d8ce transaction-summary: show the range of new revisions upon pull/unbundle (BC)
Denis Laxalde <denis.laxalde@logilab.fr>
parents: 16913
diff changeset
62 new changesets 495a0ec48aaf:1e7b6c812ca8
16481
37e0872b5ced tests: remove race in test-pull-pull-corruption.t
Mads Kiilerich <mads@kiilerich.com>
parents: 13439
diff changeset
63 (run 'hg update' to get a working copy)
1785
81ca1a9bd061 Added test cases for repo corruption fixed in 2e0a288ca93e (issue132)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
64
12481
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
65 see the result
1785
81ca1a9bd061 Added test cases for repo corruption fixed in 2e0a288ca93e (issue132)
Thomas Arendsen Hein <thomas@intevation.de>
parents:
diff changeset
66
12481
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
67 $ wait
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
68 $ hg verify
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
69 checking changesets
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
70 checking manifests
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
71 crosschecking files in changesets and manifests
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
72 checking files
70ef9b470efe tests: unify test-pull-pull-corruption
Matt Mackall <mpm@selenic.com>
parents: 1785
diff changeset
73 1 files, 11 changesets, 11 total revisions
16913
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 16481
diff changeset
74
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 16481
diff changeset
75 $ cd ..