Artifactspublic-v0

curl

master
ply4 git calls351 ms290 KiB2 cachedprotocol v2
302 lines15 KiBRaw
1#***************************************************************************
2# _ _ ____ _
3# Project ___| | | | _ \| |
4# / __| | | | |_) | |
5# | (__| |_| | _ <| |___
6# \___|\___/|_| \_\_____|
7#
8# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9#
10# This software is licensed as described in the file COPYING, which
11# you should have received as part of this distribution. The terms
12# are also available at https://curl.se/docs/copyright.html.
14# You may opt to use, copy, modify, merge, publish, distribute and/or sell
15# copies of the Software, and permit persons to whom the Software is
16# furnished to do so, under the terms of the COPYING file.
18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19# KIND, either express or implied.
21# SPDX-License-Identifier: curl
23###########################################################################
25import logging
26import re
27import socket
28import threading
30import pytest
31from testenv import CurlClient, Env
33log = logging.getLogger(__name__)
36class TestEyeballs:
38 # download using only HTTP/3 on working server
39 @pytest.mark.skipif(condition=not Env.have_h3(), reason="missing HTTP/3 support")
40 def test_06_01_h3_only(self, env: Env, httpd, nghttpx):
41 curl = CurlClient(env=env)
42 urln = f'https://{env.authority_for(env.domain1, "h3")}/data.json'
43 r = curl.http_download(urls=[urln], extra_args=['--http3-only'])
44 r.check_response(count=1, http_status=200)
45 assert r.stats[0]['http_version'] == '3'
47 # download using only HTTP/3 on missing server
48 @pytest.mark.skipif(condition=not Env.have_h3(), reason="missing HTTP/3 support")
49 def test_06_02_h3_only(self, env: Env, httpd, nghttpx):
50 curl = CurlClient(env=env)
51 urln = f'https://{env.domain1}:{env.https_only_tcp_port}/data.json'
52 r = curl.http_download(urls=[urln], extra_args=['--http3-only'])
53 r.check_response(exitcode=7, http_status=None)
55 # download using HTTP/3 on missing server with fallback on h2
56 @pytest.mark.skipif(condition=not Env.have_h3(), reason="missing HTTP/3 support")
57 def test_06_03_h3_fallback_h2(self, env: Env, httpd, nghttpx):
58 curl = CurlClient(env=env)
59 urln = f'https://{env.domain1}:{env.https_only_tcp_port}/data.json'
60 r = curl.http_download(urls=[urln], extra_args=['--http3'])
61 r.check_response(count=1, http_status=200)
62 assert r.stats[0]['http_version'] == '2'
64 # download using HTTP/3 on missing server with fallback on http/1.1
65 @pytest.mark.skipif(condition=not Env.have_h3(), reason="missing HTTP/3 support")
66 def test_06_04_h3_fallback_h1(self, env: Env, httpd, nghttpx):
67 curl = CurlClient(env=env)
68 urln = f'https://{env.domain2}:{env.https_only_tcp_port}/data.json'
69 r = curl.http_download(urls=[urln], extra_args=['--http3'])
70 r.check_response(count=1, http_status=200)
71 assert r.stats[0]['http_version'] == '1.1'
73 # download using HTTP/3 on a server that silently drops UDP: fallback on
74 # h2 at the soft timeout, since QUIC never sees any data
75 @pytest.mark.skipif(condition=not Env.have_h3(), reason="missing HTTP/3 support")
76 @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings")
77 def test_06_05_h3_silent_fallback_h2(self, env: Env, httpd, nghttpx):
78 curl = CurlClient(env=env)
79 urln = f'https://{env.domain1}:{env.https_only_tcp_port}/data.json'
80 # take the UDP port without reading it, so that packets are not refused
81 with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock:
82 sock.bind(('127.0.0.1', env.https_only_tcp_port))
83 r = curl.http_download(urls=[urln], extra_args=[
84 '--http3', '--happy-eyeballs-timeout-ms', '200',
85 '--trace-config', 'https-connect'
86 ])
87 r.check_response(count=1, http_status=200)
88 assert r.stats[0]['http_version'] == '2'
89 soft_timeouts = [line for line in r.trace_lines
90 if re.match(r'.*h3 has not seen any data after 100ms', line)]
91 assert len(soft_timeouts) == 1, f'{r.dump_logs()}'
93 # download using HTTP/3 on a server that answers UDP with junk: QUIC has
94 # seen data, fallback on h2 at the hard timeout
95 @pytest.mark.skipif(condition=not Env.have_h3(), reason="missing HTTP/3 support")
96 @pytest.mark.skipif(condition=not Env.curl_uses_lib('ngtcp2'), reason="requires ngtcp2 packet handling")
97 @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings")
98 def test_06_06_h3_stalled_fallback_h2(self, env: Env, httpd, nghttpx):
99 curl = CurlClient(env=env)
100 urln = f'https://{env.domain1}:{env.https_only_tcp_port}/data.json'
101 with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock:
102 sock.bind(('127.0.0.1', env.https_only_tcp_port))
103 sock.settimeout(0.1)
104 done = threading.Event()
106 def answer_junk():
107 while not done.is_set():
108 try:
109 _, addr = sock.recvfrom(65536)
110 sock.sendto(b'\0', addr)
111 except socket.timeout:
112 # Ignore socket recvfrom timeouts
113 pass
115 t = threading.Thread(target=answer_junk)
116 t.start()
117 try:
118 r = curl.http_download(urls=[urln], extra_args=[
119 '--http3', '--happy-eyeballs-timeout-ms', '200',
120 '--trace-config', 'https-connect,timer'
121 ])
122 finally:
123 done.set()
124 t.join()
125 r.check_response(count=1, http_status=200)
126 assert r.stats[0]['http_version'] == '2'
127 hard_timeouts = [line for line in r.trace_lines
128 if re.match(r'.*h3 inconclusive after 200', line)]
129 assert len(hard_timeouts) == 1, f'{r.dump_logs()}'
130 # the timer is set again for the hard timeout, QUIC does not wake us
131 # up before its retransmission after about one second
132 he_timers_set = [line for line in r.trace_lines
133 if re.match(r'.*\[TIMER] \[ALPN_EYEBALLS] set for', line)]
134 assert len(he_timers_set) >= 2, f'{r.dump_logs()}'
135 assert r.stats[0]['time_connect'] < 0.8, f'{r.stats[0]}'
137 # make a successful https: transfer and observer the timer stats
138 def test_06_10_stats_success(self, env: Env, httpd, nghttpx):
139 curl = CurlClient(env=env)
140 urln = f'https://{env.authority_for(env.domain1, "h2")}/data.json'
141 r = curl.http_download(urls=[urln])
142 r.check_response(count=1, http_status=200)
143 assert r.stats[0]['time_connect'] > 0.0
144 assert r.stats[0]['time_appconnect'] > 0.0
146 # make https: to a hostname that tcp connects, but will not verify
147 def test_06_11_stats_fail_verify(self, env: Env, httpd, nghttpx):
148 curl = CurlClient(env=env)
149 urln = f'https://not-valid.com:{env.https_port}/data.json'
150 r = curl.http_download(urls=[urln], extra_args=[
151 '--resolve', f'not-valid.com:{env.https_port}:127.0.0.1'
152 ])
153 r.check_response(count=1, http_status=0, exitcode=False)
154 assert r.stats[0]['time_connect'] > 0.0 # was tcp connected
155 assert r.stats[0]['time_appconnect'] == 0 # but not SSL verified
157 # make https: to an invalid address
158 def test_06_12_stats_fail_tcp(self, env: Env, httpd, nghttpx):
159 curl = CurlClient(env=env)
160 urln = 'https://not-valid.com:1/data.json'
161 r = curl.http_download(urls=[urln], extra_args=[
162 '--resolve', f'not-valid.com:{1}:127.0.0.1'
163 ])
164 r.check_response(count=1, http_status=None, exitcode=False)
165 assert r.stats[0]['time_connect'] == 0 # no one should have listened
166 assert r.stats[0]['time_appconnect'] == 0 # did not happen either
168 # check timers when trying 3 unresponsive addresses
169 @pytest.mark.skipif(condition=not Env.curl_has_feature('IPv6'),
170 reason='curl lacks IPv6 support')
171 @pytest.mark.skipif(condition=not Env.curl_has_feature('AsynchDNS'),
172 reason='curl lacks async DNS support')
173 @pytest.mark.skipif(condition=not Env.curl_is_verbose(), reason="needs curl verbose strings")
174 def test_06_13_timers(self, env: Env):
175 curl = CurlClient(env=env)
176 # IPv6 0100::/64 is supposed to go into the void (rfc6666), but in
177 # some implementations, this is broken. Try to detect this
178 r = curl.http_download(urls=['https://xxx.invalid/'], extra_args=[
179 '--resolve', 'xxx.invalid:443:0100::1',
180 '--connect-timeout', '0.5',
181 ])
182 # this should error with CURLE_OPERATION_TIMEDOUT
183 if r.exit_code != 28:
184 pytest.skip('system does not blackhole 0100::/64')
186 r = curl.http_download(urls=['https://xxx.invalid/'], extra_args=[
187 '--resolve', 'xxx.invalid:443:0100::1,0100::2,0100::3',
188 '--connect-timeout', '1',
189 '--happy-eyeballs-timeout-ms', '123',
190 '--trace-config', 'timer,happy-eyeballs,tcp'
191 ])
192 r.check_response(count=1, http_status=None, exitcode=False)
193 assert r.stats[0]['time_connect'] == 0 # no one connected
194 # check that we indeed started attempts on all 3 addresses
195 tcp_attempts = [line for line in r.trace_lines
196 if re.match(r'.*Trying \[100::[123]]:443', line)]
197 assert len(tcp_attempts) == 3, f'fond: {"".join(tcp_attempts)}\n{r.dump_logs()}'
198 # if the 0100::/64 really goes into the void, we should see 2 HAPPY_EYEBALLS
199 # timeouts being set here
200 failed_attempts = [line for line in r.trace_lines
201 if re.match(r'.*checked connect attempts: 0 ongoing', line)]
202 if failed_attempts:
203 # github CI fails right away with "Network is unreachable", slackers...
204 assert len(failed_attempts) == 3, f'found: {"".join(failed_attempts)}\n{r.dump_logs()}'
205 else:
206 # no immediately failed attempts, as should be
207 he_timers_set = [line for line in r.trace_lines
208 if re.match(r'.*\[TIMER] \[HAPPY_EYEBALLS] set for', line)]
209 assert len(he_timers_set) >= 2, f'found: {"".join(he_timers_set)}\n{r.dump_logs()}'
211 # download using HTTP/3 on missing server with alt-svc pointing there
212 @pytest.mark.skipif(condition=not Env.have_h3(), reason="missing HTTP/3 support")
213 def test_06_20_h2_altsvc_h3_fallback(self, env: Env, httpd, nghttpx):
214 curl = CurlClient(env=env)
215 urln = f'https://{env.domain1}:{env.https_only_tcp_port}/data.json'
216 altsvc_file = curl.mk_altsvc_file('test_06',
217 'h2', env.domain1, env.https_only_tcp_port,
218 'h3', env.domain1, env.https_only_tcp_port)
219 r = curl.http_download(urls=[urln], extra_args=[
220 '--alt-svc', altsvc_file
221 ])
222 # Should try a QUIC connection that fails and fallback to h2
223 r.check_exit_code(0)
224 r.check_response(count=1, http_status=200)
225 assert r.stats[0]['http_version'] == '2'
227 @pytest.mark.skipif(condition=not Env.have_h3(), reason="h3 not supported")
228 def test_06_21_as_follow_h3h1(self, env: Env, httpd, configures_httpd, nghttpx):
229 # With '--http3` an Alt-Svc redirection from h3 to h1 is allowed
230 # write an alt-svc file the advises h1 instead of h3
231 curl = CurlClient(env=env)
232 asfile = curl.mk_altsvc_file('test_12',
233 'h3', env.domain1, env.https_only_tcp_port,
234 'http/1.1', env.domain1, env.https_only_tcp_port)
235 urln = f'https://{env.domain1}:{env.https_only_tcp_port}/data.json'
236 r = curl.http_download(urls=[urln], with_stats=True, extra_args=[
237 '--alt-svc', f'{asfile}', '--http3'
238 ])
239 r.check_response(count=1, http_status=200)
240 # We expect the connection to use HTTP/1.1
241 assert r.total_connects == 1, f'{r.dump_logs()}'
242 assert r.stats[0]['http_version'] == '1.1', f'{r}'
244 @pytest.mark.skipif(condition=not Env.have_h3(), reason="h3 not supported")
245 def test_06_22_as_ignore_h3h1(self, env: Env, httpd, configures_httpd, nghttpx):
246 # With '--http3-only` an Alt-Svc redirection from h3 to h1 is ignored
247 # write an alt-svc file the advises h1 instead of h3
248 curl = CurlClient(env=env)
249 asfile = curl.mk_altsvc_file('test_12',
250 'h3', env.domain1, env.https_port,
251 'http/1.1', env.domain1, env.https_port)
252 urln = f'https://{env.authority_for(env.domain1, "h3")}/data.json'
253 r = curl.http_download(urls=[urln], with_stats=True, extra_args=[
254 '--alt-svc', f'{asfile}', '--http3-only'
255 ])
256 r.check_response(count=1, http_status=200)
257 # We expect the connection to be stay on h3, since we used --http3-only
258 assert r.total_connects == 1
259 assert r.stats[0]['http_version'] == '3', f'{r.stats}'
261 @pytest.mark.skipif(condition=not Env.have_h3(), reason="h3 not supported")
262 def test_06_23_as_ignore_h2h3(self, env: Env, httpd, configures_httpd, nghttpx):
263 # With '--http2` an Alt-Svc redirection from h2 to h3 is ignored
264 # write an alt-svc file that advises h3 instead of h2
265 curl = CurlClient(env=env)
266 asfile = curl.mk_altsvc_file('test_12',
267 'h2', env.domain1, env.https_port,
268 'h3', env.domain1, env.h3_port)
269 urln = f'https://{env.authority_for(env.domain1, "h2")}/data.json'
270 r = curl.http_download(urls=[urln], with_stats=True, extra_args=[
271 '--alt-svc', f'{asfile}', '--http2'
272 ])
273 r.check_response(count=1, http_status=200)
274 assert r.stats[0]['http_version'] == '2', f'{r.stats}'
276 # download using HTTP/3 on available server with alt-svc to h2, use h2
277 @pytest.mark.skipif(condition=not Env.have_h3(), reason="missing HTTP/3 support")
278 def test_06_24_h3_altsvc_h2_used(self, env: Env, httpd, nghttpx):
279 curl = CurlClient(env=env)
280 urln = f'https://{env.domain1}:{env.https_only_tcp_port}/data.json'
281 altsvc_file = curl.mk_altsvc_file('test_12',
282 'h3', env.domain1, env.https_only_tcp_port,
283 'h2', env.domain1, env.https_only_tcp_port)
284 r = curl.http_download(urls=[urln], extra_args=[
285 '--http3', '--alt-svc', altsvc_file
286 ])
287 r.check_exit_code(0)
288 r.check_response(count=1, http_status=200)
289 assert r.stats[0]['http_version'] == '2'
291 # h3 download using --connect-to IPv6 address
292 @pytest.mark.skipif(condition=not Env.have_h3(), reason="missing HTTP/3 support")
293 @pytest.mark.skipif(condition=not Env.curl_has_feature('IPv6'), reason="no IPv6")
294 def test_06_25_h3_connect_to(self, env: Env, httpd, nghttpx):
295 curl = CurlClient(env=env, force_resolv=False)
296 urln = f'https://{env.authority_for(env.domain1, "h3")}/data.json'
297 r = curl.http_download(urls=[urln], extra_args=[
298 '--http3-only', '--connect-to',
299 f'{env.authority_for(env.domain1, "h3")}:[::1]:{env.https_port}'
300 ])
301 r.check_response(count=1, http_status=200)
302 assert r.stats[0]['http_version'] == '3'
Diagnostics4 git calls · 351 ms
CallStatusSizeTime0351 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200149 B · hit3 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=3
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=149
git.pkt.payload.max=78
git.ls_refs.count=2
git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=345
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=10
git.pkt.data=8
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=293470
git.pkt.payload.max=65516
git.sideband.band1.bytes=293354
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=87
git.pack.bytes=293354
git.pack.ofs_delta=0
git.pack.ref_delta=1
git.pack.chain.max=1
git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0
git.pack.full=86
Open pack map
fetch2003.5 KiB345 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=3622
git.response.cache=MISS
git.response.duration_ms=345
git.fetch.wants=116ba3355d9f0e81d9733eb6e58c746f40e74015
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=3622
git.pkt.payload.max=3601
git.sideband.band1.bytes=3600
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
Ref
refs/heads/master
Commit
31c911efe5652725e930f4d2e60c9060e5f6646d
cf-ray
a5e300878826f3c9
Request
ce8addea…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format