master
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.
13#
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.
17#
18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19# KIND, either express or implied.
20#
21# SPDX-License-Identifier: curl
22#
23###########################################################################
24#
25import logging
26import os
27import platform
28import sys
29from typing import Generator, Union
31import pytest
32from testenv.env import EnvConfig
34sys.path.append(os.path.join(os.path.dirname(__file__), "."))
36from testenv import (
37 Dante,
38 Dnsd,
39 Env,
40 Httpd,
41 Nghttpx,
42 NghttpxFwd,
43 NghttpxQuic,
44 NghttpxTcp,
45 Sshd,
46)
47from testenv.h2o import H2oProxy, H2oServer
49log = logging.getLogger(__name__)
52def pytest_report_header(config):
53 # Env inits its base properties only once, we can report them here
54 env = Env()
55 report = [
56 f"Testing curl {env.curl_version()}",
57 f" platform: {platform.platform()}",
58 f" curl: Version: {env.curl_version_string()}",
59 f" curl: Features: {env.curl_features_string()}",
60 f" curl: Protocols: {env.curl_protocols_string()}",
61 f" httpd: {env.httpd_version()}",
62 f" httpd-proxy: {env.httpd_version()}",
63 ]
64 if env.have_h3():
65 report.extend([f" nghttpx: {env.nghttpx_version()}"])
66 if env.have_h2o():
67 report.extend([f" h2o: {env.h2o_version()}"])
68 if env.has_caddy():
69 report.extend([f" Caddy: {env.caddy_version()}"])
70 if env.has_sshd():
71 report.extend([f" sshd: {env.sshd_version()}"])
72 if env.has_vsftpd():
73 report.extend([f" VsFTPD: {env.vsftpd_version()}"])
74 buildinfo_fn = os.path.join(env.build_dir, "buildinfo.txt")
75 if os.path.exists(buildinfo_fn):
76 with open(buildinfo_fn, "r") as file_in:
77 for line in file_in:
78 line = line.strip()
79 if line and not line.startswith("#"):
80 report.extend([line])
81 return "\n".join(report)
84@pytest.fixture(scope="session")
85def env_config(pytestconfig, testrun_uid, worker_id) -> EnvConfig:
86 return EnvConfig(
87 pytestconfig=pytestconfig, testrun_uid=testrun_uid, worker_id=worker_id
88 )
91@pytest.fixture(scope="session", autouse=True)
92def env(pytestconfig, env_config) -> Env:
93 env = Env(pytestconfig=pytestconfig, env_config=env_config)
94 level = logging.DEBUG if env.verbose > 0 else logging.INFO
95 logging.getLogger("").setLevel(level=level)
96 if not env.curl_has_protocol("http"):
97 pytest.skip("curl built without HTTP support")
98 if not env.curl_has_protocol("https"):
99 pytest.skip("curl built without HTTPS support")
100 if env.setup_incomplete():
101 pytest.skip(env.incomplete_reason())
103 env.setup()
104 return env
107@pytest.fixture(scope='session')
108def danted(env, httpd) -> Generator[Union[Dante, bool], None, None]:
109 if Env.has_danted():
110 danted = Dante(env=env)
111 assert danted.initial_start()
112 yield danted
113 danted.stop()
114 else:
115 yield False
118@pytest.fixture(scope='session', autouse=True)
119def dnsd(env) -> Generator[Dnsd, None, None]:
120 dnsd = Dnsd(env=env)
121 assert dnsd.initial_start()
122 yield dnsd
123 dnsd.stop()
126@pytest.fixture(scope="session")
127def httpd(env) -> Generator[Httpd, None, None]:
128 httpd = Httpd(env=env)
129 if not httpd.exists():
130 pytest.skip(f"httpd not found: {env.httpd}")
131 httpd.clear_logs()
132 assert httpd.initial_start()
133 yield httpd
134 httpd.stop()
137@pytest.fixture(scope="session")
138def nghttpx(env, httpd) -> Generator[Union[Nghttpx, bool], None, None]:
139 nghttpx = NghttpxQuic(env=env)
140 if nghttpx.exists() and nghttpx.supports_h3() and env.have_h3_curl():
141 nghttpx.clear_logs()
142 assert nghttpx.initial_start()
143 yield nghttpx
144 nghttpx.stop()
145 else:
146 yield False
149@pytest.fixture(scope="session")
150def nghttpx_tcp(env, httpd) -> Generator[Union[Nghttpx, bool], None, None]:
151 nghttpx = NghttpxTcp(env=env)
152 if nghttpx.exists():
153 nghttpx.clear_logs()
154 assert nghttpx.initial_start()
155 yield nghttpx
156 nghttpx.stop()
157 else:
158 yield False
161@pytest.fixture(scope="session")
162def nghttpx_fwd(env, httpd) -> Generator[Union[Nghttpx, bool], None, None]:
163 nghttpx = NghttpxFwd(env=env)
164 if nghttpx.exists():
165 nghttpx.clear_logs()
166 assert nghttpx.initial_start()
167 yield nghttpx
168 nghttpx.stop()
169 else:
170 yield False
173@pytest.fixture(scope="session")
174def sshd(env: Env) -> Generator[Union[Sshd, bool], None, None]:
175 if env.has_sshd():
176 sshd = Sshd(env=env)
177 assert sshd.initial_start(), f"{sshd.dump_log()}"
178 yield sshd
179 sshd.stop()
180 else:
181 yield False
184@pytest.fixture(scope="session")
185def configures_httpd(env, httpd) -> Generator[bool, None, None]:
186 # include this fixture as test parameter if the test configures httpd itself
187 yield True
190@pytest.fixture(scope="session")
191def configures_nghttpx(env, httpd) -> Generator[bool, None, None]:
192 # include this fixture as test parameter if the test configures nghttpx itself
193 yield True
196@pytest.fixture(autouse=True, scope="function")
197def server_reset(request, env, httpd, nghttpx):
198 # make sure httpd is in default configuration when a test starts
199 if "configures_httpd" not in request.node._fixtureinfo.argnames:
200 httpd.reset_config()
201 httpd.reload_if_config_changed()
202 if (
203 env.have_h3()
204 and "nghttpx" in request.node._fixtureinfo.argnames
205 and "configures_nghttpx" not in request.node._fixtureinfo.argnames
206 ):
207 nghttpx.reset_config()
208 nghttpx.reload_if_config_changed()
211@pytest.fixture(scope="session")
212def h2o_server(env) -> Generator[Union[H2oServer, bool], None, None]:
213 h2o = H2oServer(env=env)
214 if env.have_h2o():
215 h2o.clear_logs()
216 if not h2o.initial_start():
217 h2o_logs = "\n".join(h2o.dump_logs())
218 pytest.skip(f"h2o server failed to start\n{h2o_logs}")
219 yield h2o
220 h2o.kill()
221 else:
222 yield False
225@pytest.fixture(scope="session")
226def h2o_proxy(env) -> Generator[Union[H2oProxy, bool], None, None]:
227 h2o = H2oProxy(env=env)
228 if env.have_h2o():
229 h2o.clear_logs()
230 if not h2o.initial_start():
231 h2o_logs = "\n".join(h2o.dump_logs())
232 pytest.skip(f"h2o proxy failed to start\n{h2o_logs}")
233 yield h2o
234 h2o.kill()
235 else:
236 yield False
Diagnostics4 git calls · 235 ms
CallStatusSizeTime0235 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=229 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=86Open pack map
fetch2002.1 KiB229 ms
git.upload-pack fetch http.response.status_code=200 git.response.bytes=2182 git.response.cache=MISS git.response.duration_ms=229 git.fetch.wants=ffa2792deede22bb12b886b945ae7fc578656a9b 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=2182 git.pkt.payload.max=2161 git.sideband.band1.bytes=2160 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
- a5e254dd59c21ae0
- Request
- c438da1e…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format