Artifactspublic-v0

curl

master
ply4 git calls38 ms289 KiB3 cachedprotocol v2
146 lines5.7 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 os
27import shutil
28import subprocess
29from datetime import datetime, timedelta, timezone
30from typing import Dict, Optional
32from . import ExecResult, RunProfile
33from .env import Env
35log = logging.getLogger(__name__)
38class LocalClient:
40 def __init__(self, name: str, env: Env, run_dir: Optional[str] = None,
41 timeout: Optional[float] = None,
42 run_env: Optional[Dict[str, str]] = None):
43 self.name = name
44 self.path = os.path.join(env.build_dir, 'tests/libtest/libtests')
45 self.env = env
46 self._run_env = run_env
47 self._timeout = timeout or env.test_timeout
48 self._curl = os.environ.get('CURL', env.curl)
49 self._run_dir = run_dir or os.path.join(env.gen_dir, name)
50 self._stdoutfile = f'{self._run_dir}/stdout'
51 self._stderrfile = f'{self._run_dir}/stderr'
52 self._rmrf(self._run_dir)
53 self._mkpath(self._run_dir)
55 @property
56 def run_dir(self) -> str:
57 return self._run_dir
59 @property
60 def stderr_file(self) -> str:
61 return self._stderrfile
63 def exists(self) -> bool:
64 return os.path.exists(self.path)
66 def download_file(self, i: int) -> str:
67 return os.path.join(self._run_dir, f'download_{i}.data')
69 def _rmf(self, path):
70 if os.path.exists(path):
71 os.remove(path)
73 def _rmrf(self, path):
74 if os.path.exists(path):
75 shutil.rmtree(path)
77 def _mkpath(self, path):
78 if not os.path.exists(path):
79 os.makedirs(path)
81 def run(self, args, with_profile: bool = False):
82 self._rmf(self._stdoutfile)
83 self._rmf(self._stderrfile)
84 start = datetime.now(timezone.utc)
85 exception = None
86 myargs = [self.path, self.name]
87 myargs.extend(args)
88 run_env = None
89 profile = None
90 if self._run_env:
91 run_env = self._run_env.copy()
92 for key in ['CURL_DEBUG']:
93 if key in os.environ and key not in run_env:
94 run_env[key] = os.environ[key]
95 started_at = datetime.now(timezone.utc)
96 try:
97 with open(self._stdoutfile, 'w') as cout, open(self._stderrfile, 'w') as cerr:
98 if with_profile:
99 end_at = started_at + timedelta(seconds=self._timeout) \
100 if self._timeout else None
101 p = subprocess.Popen(myargs, stderr=cerr, stdout=cout,
102 cwd=self._run_dir, shell=False,
103 env=run_env)
104 profile = RunProfile(p.pid, started_at, self._run_dir)
105 ptimeout = 0.0
106 while True:
107 try:
108 p.wait(timeout=ptimeout)
109 break
110 except subprocess.TimeoutExpired as e:
111 if end_at and datetime.now(timezone.utc) >= end_at:
112 p.kill()
113 raise subprocess.TimeoutExpired(cmd=args, timeout=self._timeout) from e
114 profile.sample()
115 ptimeout = 0.001
116 exitcode = p.returncode
117 profile.finish()
118 log.info(f'done: exit={exitcode}, profile={profile}')
119 else:
120 p = subprocess.run(myargs, stderr=cerr, stdout=cout,
121 cwd=self._run_dir, shell=False,
122 input=None, env=run_env,
123 timeout=self._timeout, check=False)
124 exitcode = p.returncode
125 except subprocess.TimeoutExpired:
126 log.warning(f'Timeout after {self._timeout}s: {args}')
127 exitcode = -1
128 exception = 'TimeoutExpired'
129 with open(self._stdoutfile) as fout, open(self._stderrfile) as ferr:
130 coutput = fout.readlines()
131 cerrput = ferr.readlines()
132 return ExecResult(args=myargs, exit_code=exitcode, exception=exception,
133 stdout=coutput, stderr=cerrput,
134 duration=datetime.now(timezone.utc) - start,
135 profile=profile)
137 def dump_logs(self):
138 lines = []
139 lines.append('>>--stdout ----------------------------------------------\n')
140 with open(self._stdoutfile) as fd:
141 lines.extend(fd.readlines())
142 lines.append('>>--stderr ----------------------------------------------\n')
143 with open(self._stderrfile) as fd:
144 lines.extend(fd.readlines())
145 lines.append('<<-------------------------------------------------------\n')
146 return ''.join(lines)
Diagnostics4 git calls · 38 ms
CallStatusSizeTime038 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=2
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 · hit2 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=33
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=2
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
fetch2001.9 KiB · hit33 ms
git.upload-pack fetch
http.response.status_code=200
git.response.bytes=1914
git.response.cache=HIT
git.response.duration_ms=33
git.fetch.wants=5eef1dead945244b9dfad408194fc6fb85d3bb66
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=1914
git.pkt.payload.max=1893
git.sideband.band1.bytes=1892
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
a5e2bf4ecca289da
Request
d74a1087…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format