Skip to content

Commit 3e8bee1

Browse files
feat(disk_perf): add support of uri for previous csv file
Signed-off-by: Mathieu Labourier <[email protected]>
1 parent 385f290 commit 3e8bee1

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

tests/storage/benchmarks/conftest.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import logging
2+
import os
13
import pytest
24
import tempfile
3-
import os
4-
import logging
5+
import urllib.request
6+
from urllib.parse import urlparse
7+
from uuid import uuid4
8+
59

610
from lib.commands import SSHCommandFailed
711
from .helpers import load_results_from_csv
@@ -92,13 +96,18 @@ def pytest_addoption(parser):
9296
"--prev-csv",
9397
action="store",
9498
default=None,
95-
help="Path to previous CSV results file for comparison",
99+
help="Path/URI to previous CSV results file for comparison",
96100
)
97101

98102
@pytest.fixture(scope="session")
99-
def prev_results(request):
100-
csv_path = request.config.getoption("--prev-csv")
101-
results = {}
102-
if csv_path and os.path.exists(csv_path):
103-
load_results_from_csv(csv_path)
104-
return results
103+
def prev_results(pytestconfig):
104+
csv_uri = pytestconfig.getoption("--prev-csv")
105+
if not csv_uri:
106+
return {}
107+
csv_path = csv_uri
108+
if urlparse(csv_uri).scheme != "":
109+
csv_path = f"{uuid4()}.csv"
110+
urllib.request.urlretrieve(csv_uri, csv_path)
111+
if not os.path.exists(csv_path):
112+
raise FileNotFoundError(csv_path)
113+
return load_results_from_csv(csv_path)

0 commit comments

Comments
 (0)