annotate tests/test-wireproto-command-pushkey.t @ 39483:1fc39367eafd

httppeer: calculate total expected bytes correctly User-facing error messages that handled httplib.IncompleteRead errors in Mercurial used to look like this: abort: HTTP request error (incomplete response; expected 3 bytes got 1) But the errors that are being handled underneath the UI look like this: IncompleteRead(1 bytes read, 3 more expected) I.e. the error actually counts total number of expected bytes minus bytes already received. Before, users could see weird messages like "expected 10 bytes got 10", while in reality httplib expected 10 _more_ bytes (20 in total).
author Anton Shestakov <av6@dwimlabs.net>
date Sat, 08 Sep 2018 23:57:07 +0800
parents 36f487a332ad
children 07b58266bce3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
37537
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
1 $ . $TESTDIR/wireprotohelpers.sh
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
2
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
3 $ hg init server
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
4 $ enablehttpv2 server
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
5 $ cd server
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
6 $ cat >> .hg/hgrc << EOF
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
7 > [web]
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
8 > push_ssl = false
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
9 > allow-push = *
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
10 > EOF
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
11 $ hg debugdrawdag << EOF
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
12 > C D
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
13 > |/
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
14 > B
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
15 > |
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
16 > A
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
17 > EOF
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
18
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
19 $ hg serve -p $HGPORT -d --pid-file hg.pid -E error.log
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
20 $ cat hg.pid > $DAEMON_PIDS
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
21
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
22 pushkey for a bookmark works
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
23
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
24 $ sendhttpv2peer << EOF
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
25 > command pushkey
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
26 > namespace bookmarks
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
27 > key @
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
28 > old
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
29 > new 426bada5c67598ca65036d57d9e4b64b0c1ce7a0
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
30 > EOF
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
31 creating http peer for wire protocol version 2
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
32 sending pushkey command
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
33 s> *\r\n (glob)
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
34 s> Accept-Encoding: identity\r\n
37725
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
35 s> accept: application/mercurial-exp-framing-0005\r\n
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
36 s> content-type: application/mercurial-exp-framing-0005\r\n
37537
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
37 s> content-length: 105\r\n
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
38 s> host: $LOCALIP:$HGPORT\r\n (glob)
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
39 s> user-agent: Mercurial debugwireproto\r\n
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
40 s> \r\n
39446
36f487a332ad wireprotoframing: use our CBOR module
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39378
diff changeset
41 s> a\x00\x00\x01\x00\x01\x01\x11\xa2Dargs\xa4CkeyA@InamespaceIbookmarksCnewX(426bada5c67598ca65036d57d9e4b64b0c1ce7a0Cold@DnameGpushkey
37537
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
42 s> makefile('rb', None)
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
43 s> HTTP/1.1 200 OK\r\n
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
44 s> Server: testing stub value\r\n
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
45 s> Date: $HTTP_DATE$\r\n
37725
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
46 s> Content-Type: application/mercurial-exp-framing-0005\r\n
37537
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
47 s> Transfer-Encoding: chunked\r\n
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
48 s> \r\n
37725
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
49 s> 14\r\n
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
50 s> \x0c\x00\x00\x01\x00\x02\x012
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
51 s> \xa1FstatusBok\xf5
37537
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
52 s> \r\n
37725
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
53 received frame(size=12; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
37537
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
54 s> 0\r\n
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
55 s> \r\n
37721
f7673845b167 wireprotov2: decode responses to their expected types
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37719
diff changeset
56 response: True
37537
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
57
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
58 $ sendhttpv2peer << EOF
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
59 > command listkeys
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
60 > namespace bookmarks
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
61 > EOF
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
62 creating http peer for wire protocol version 2
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
63 sending listkeys command
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
64 s> POST /api/exp-http-v2-0001/ro/listkeys HTTP/1.1\r\n
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
65 s> Accept-Encoding: identity\r\n
37725
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
66 s> accept: application/mercurial-exp-framing-0005\r\n
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
67 s> content-type: application/mercurial-exp-framing-0005\r\n
37537
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
68 s> content-length: 49\r\n
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
69 s> host: $LOCALIP:$HGPORT\r\n (glob)
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
70 s> user-agent: Mercurial debugwireproto\r\n
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
71 s> \r\n
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
72 s> )\x00\x00\x01\x00\x01\x01\x11\xa2Dargs\xa1InamespaceIbookmarksDnameHlistkeys
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
73 s> makefile('rb', None)
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
74 s> HTTP/1.1 200 OK\r\n
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
75 s> Server: testing stub value\r\n
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
76 s> Date: $HTTP_DATE$\r\n
37725
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
77 s> Content-Type: application/mercurial-exp-framing-0005\r\n
37537
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
78 s> Transfer-Encoding: chunked\r\n
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
79 s> \r\n
37725
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
80 s> 40\r\n
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
81 s> 8\x00\x00\x01\x00\x02\x012
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
82 s> \xa1FstatusBok\xa1A@X(426bada5c67598ca65036d57d9e4b64b0c1ce7a0
37537
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
83 s> \r\n
37725
3ea8323d6f95 wireprotov2: change command response protocol to include a leading map
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37724
diff changeset
84 received frame(size=56; request=1; stream=2; streamflags=stream-begin; type=command-response; flags=eos)
37537
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
85 s> 0\r\n
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
86 s> \r\n
39378
0f549da54379 stringutil: teach pprint() to indent
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
87 response: {
0f549da54379 stringutil: teach pprint() to indent
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
88 b'@': b'426bada5c67598ca65036d57d9e4b64b0c1ce7a0'
0f549da54379 stringutil: teach pprint() to indent
Gregory Szorc <gregory.szorc@gmail.com>
parents: 37725
diff changeset
89 }
37537
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
90
be5d4749edc0 wireproto: port pushkey command to wire protocol version 2
Gregory Szorc <gregory.szorc@gmail.com>
parents:
diff changeset
91 $ cat error.log