summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorCristian Ciocaltea <cristian.ciocaltea@collabora.com>2021-11-03 21:52:40 +0200
committerTomeu Vizoso <tomeu.vizoso@collabora.com>2021-11-22 09:32:23 +0100
commit9b8cec06d3c119e2d87a5c086a4aa8e865e103c5 (patch)
treea7b3bd7f1a731a8c5c60ae349a067f7b8767ab32 /framework
parentf7f2a6c2275cae023a27b6cc81be3dda8c99492d (diff)
framework/replay: Add support for download caching proxy
Add a new replay run option '-c' or '--download-caching-proxy-url' that allows to provide caching proxy URL in order to reduce the time required for downloading the trace files. This is used internally as a prefix for the URL specified via '-u' or '--download-url'. E.g.: http://caching-proxy/cache/?uri= Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/piglit/-/merge_requests/599>
Diffstat (limited to 'framework')
-rw-r--r--framework/replay/download_utils.py3
-rw-r--r--framework/replay/options.py7
-rw-r--r--framework/replay/programs/compare.py4
-rw-r--r--framework/replay/programs/download.py2
-rw-r--r--framework/replay/programs/parsers.py9
-rw-r--r--framework/replay/programs/profile.py4
6 files changed, 29 insertions, 0 deletions
diff --git a/framework/replay/download_utils.py b/framework/replay/download_utils.py
index bc0225c6c..44638f2f1 100644
--- a/framework/replay/download_utils.py
+++ b/framework/replay/download_utils.py
@@ -111,6 +111,9 @@ def ensure_file(file_path):
url = OPTIONS.download['url'].geturl()
+ if OPTIONS.download['caching_proxy_url'] is not None:
+ url = OPTIONS.download['caching_proxy_url'].geturl() + url
+
core.check_dir(path.dirname(destination_file_path))
if not OPTIONS.download['force'] and path.exists(destination_file_path):
diff --git a/framework/replay/options.py b/framework/replay/options.py
index 084d46d36..23c22f8c3 100644
--- a/framework/replay/options.py
+++ b/framework/replay/options.py
@@ -61,6 +61,8 @@ class _Options(object): # pylint: disable=too-many-instance-attributes
db_path -- The path to the objects db or where it will be created.
results_path -- The path in which to place the results.
download.url -- The URL from which to download the files.
+ download.caching_proxy_url -- The URL of the caching proxy acting as
+ a prefix for download.url
download.force -- Forces downloading even if the destination file already
exists.
download.minio_host -- Name of MinIO server from which to download traces
@@ -75,6 +77,7 @@ class _Options(object): # pylint: disable=too-many-instance-attributes
self.db_path = None
self.results_path = None
self.download = {'url': None,
+ 'caching_proxy_url': None,
'force': False,
'minio_host': '',
'minio_bucket': '',
@@ -90,6 +93,10 @@ class _Options(object): # pylint: disable=too-many-instance-attributes
"""Safely set the parsed download url."""
self.download['url'] = _safe_urlparse(url)
+ def set_download_caching_proxy_url(self, url):
+ """Safely set the parsed download caching proxy url."""
+ self.download['caching_proxy_url'] = _safe_urlparse(url)
+
def __iter__(self):
for key, values in self.__dict__.items():
if not key.startswith('_'):
diff --git a/framework/replay/programs/compare.py b/framework/replay/programs/compare.py
index c5372f076..6015ddea2 100644
--- a/framework/replay/programs/compare.py
+++ b/framework/replay/programs/compare.py
@@ -37,6 +37,7 @@ __all__ = ['compare']
def _from_yaml(args):
options.OPTIONS.device_name = args.device_name
options.OPTIONS.keep_image = args.keep_image
+ options.OPTIONS.set_download_caching_proxy_url(args.download_caching_proxy_url)
options.OPTIONS.download['force'] = args.force_download
options.OPTIONS.download['minio_host'] = args.download_minio_host
options.OPTIONS.download['minio_bucket'] = args.download_minio_bucket
@@ -52,6 +53,7 @@ def _trace(args):
options.OPTIONS.device_name = args.device_name
options.OPTIONS.keep_image = args.keep_image
options.OPTIONS.set_download_url(args.download_url)
+ options.OPTIONS.set_download_caching_proxy_url(args.download_caching_proxy_url)
options.OPTIONS.download['force'] = args.force_download
options.OPTIONS.download['minio_host'] = args.download_minio_host
options.OPTIONS.download['minio_bucket'] = args.download_minio_bucket
@@ -84,6 +86,7 @@ def compare(input_):
parents=[parsers.DEVICE,
parsers.KEEP_IMAGE,
parsers.DOWNLOAD_URL,
+ parsers.DOWNLOAD_CACHING_PROXY_URL,
parsers.DOWNLOAD_FORCE,
parsers.DOWNLOAD_MINIO_HOST,
parsers.DOWNLOAD_MINIO_BUCKET,
@@ -108,6 +111,7 @@ def compare(input_):
parents=[parsers.DEVICE,
parsers.KEEP_IMAGE,
parsers.YAML,
+ parsers.DOWNLOAD_CACHING_PROXY_URL,
parsers.DOWNLOAD_FORCE,
parsers.DOWNLOAD_MINIO_HOST,
parsers.DOWNLOAD_MINIO_BUCKET,
diff --git a/framework/replay/programs/download.py b/framework/replay/programs/download.py
index a9e84b3bc..0af2f91f6 100644
--- a/framework/replay/programs/download.py
+++ b/framework/replay/programs/download.py
@@ -35,6 +35,7 @@ __all__ = ['download']
def _ensure_file(args):
options.OPTIONS.set_download_url(args.download_url)
+ options.OPTIONS.set_download_caching_proxy_url(args.download_caching_proxy_url)
options.OPTIONS.download['force'] = args.force_download
options.OPTIONS.download['minio_host'] = args.download_minio_host
options.OPTIONS.download['minio_bucket'] = args.download_minio_bucket
@@ -49,6 +50,7 @@ def _ensure_file(args):
def download(input_):
""" Parser for replayer download command """
parser = argparse.ArgumentParser(parents=[parsers.DOWNLOAD_URL,
+ parsers.DOWNLOAD_CACHING_PROXY_URL,
parsers.DOWNLOAD_FORCE,
parsers.DOWNLOAD_MINIO_HOST,
parsers.DOWNLOAD_MINIO_BUCKET,
diff --git a/framework/replay/programs/parsers.py b/framework/replay/programs/parsers.py
index e225e3790..1e44e1b69 100644
--- a/framework/replay/programs/parsers.py
+++ b/framework/replay/programs/parsers.py
@@ -59,6 +59,15 @@ DOWNLOAD_URL.add_argument(
default=None,
help=('the URL from which to download the files'))
+DOWNLOAD_CACHING_PROXY_URL = argparse.ArgumentParser(add_help=False)
+DOWNLOAD_CACHING_PROXY_URL.add_argument(
+ '-c', '--download-caching-proxy-url',
+ dest='download_caching_proxy_url',
+ required=False,
+ default=None,
+ help=('the URL for the caching proxy to be used as a prefix '
+ 'for the URL provided via --download-url'))
+
DOWNLOAD_FORCE = argparse.ArgumentParser(add_help=False)
DOWNLOAD_FORCE.add_argument(
'-w', '--force-download',
diff --git a/framework/replay/programs/profile.py b/framework/replay/programs/profile.py
index 2d5b6e289..97f338c38 100644
--- a/framework/replay/programs/profile.py
+++ b/framework/replay/programs/profile.py
@@ -36,6 +36,7 @@ __all__ = ['profile']
def _from_yaml(args):
options.OPTIONS.device_name = args.device_name
+ options.OPTIONS.set_download_caching_proxy_url(args.download_caching_proxy_url)
options.OPTIONS.download['force'] = args.force_download
options.OPTIONS.download['minio_host'] = args.download_minio_host
options.OPTIONS.download['minio_bucket'] = args.download_minio_bucket
@@ -50,6 +51,7 @@ def _from_yaml(args):
def _trace(args):
options.OPTIONS.device_name = args.device_name
options.OPTIONS.set_download_url(args.download_url)
+ options.OPTIONS.set_download_caching_proxy_url(args.download_caching_proxy_url)
options.OPTIONS.download['force'] = args.force_download
options.OPTIONS.download['minio_host'] = args.download_minio_host
options.OPTIONS.download['minio_bucket'] = args.download_minio_bucket
@@ -81,6 +83,7 @@ def profile(input_):
'trace',
parents=[parsers.DEVICE,
parsers.DOWNLOAD_URL,
+ parsers.DOWNLOAD_CACHING_PROXY_URL,
parsers.DOWNLOAD_FORCE,
parsers.DOWNLOAD_MINIO_HOST,
parsers.DOWNLOAD_MINIO_BUCKET,
@@ -100,6 +103,7 @@ def profile(input_):
'yaml',
parents=[parsers.DEVICE,
parsers.YAML,
+ parsers.DOWNLOAD_CACHING_PROXY_URL,
parsers.DOWNLOAD_FORCE,
parsers.DOWNLOAD_MINIO_HOST,
parsers.DOWNLOAD_MINIO_BUCKET,