Skip to content

Commit 1010612

Browse files
committed
Issue #139/#151 support openeo.cloud and terrascope in benchmarks
1 parent a59f09e commit 1010612

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

qa/benchmarks/tests/conftest.py

+19-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import logging
22
import os
33
import random
4+
import re
5+
import urllib.parse
46
from typing import Callable
57

68
import openeo
@@ -37,6 +39,7 @@ def pytest_addoption(parser):
3739
help="When provided this url will be used instead of the backend listed in the benchmark json files.",
3840
)
3941

42+
4043
def pytest_ignore_collect(collection_path, config):
4144
"""
4245
Pytest hook to ignore certain directories/files during test collection.
@@ -80,13 +83,25 @@ def _get_client_credentials_env_var(url: str) -> str:
8083
"""
8184
Get client credentials env var name for a given backend URL.
8285
"""
83-
# TODO: parse url to more reliably extract hostname
84-
if url == "openeofed.dataspace.copernicus.eu":
86+
if not re.match(r"https?://", url):
87+
url = f"https://{url}"
88+
parsed = urllib.parse.urlparse(url)
89+
hostname = parsed.hostname
90+
if hostname in {
91+
"openeo.dataspace.copernicus.eu",
92+
"openeofed.dataspace.copernicus.eu",
93+
}:
94+
# TODO: env var could just be OPENEO_AUTH_CLIENT_CREDENTIALS_CDSE
95+
# (which should work on both classic CDSE and CDSEfed)
8596
return "OPENEO_AUTH_CLIENT_CREDENTIALS_CDSEFED"
86-
elif "openeo-staging.dataspace.copernicus.eu" in url:
97+
elif hostname == "openeo-staging.dataspace.copernicus.eu":
8798
return "OPENEO_AUTH_CLIENT_CREDENTIALS_CDSESTAG"
99+
elif hostname == "openeo.cloud":
100+
return "OPENEO_AUTH_CLIENT_CREDENTIALS_EGI"
101+
elif hostname in {"openeo.vito.be", "openeo.terrascope.be"}:
102+
return "OPENEO_AUTH_CLIENT_CREDENTIALS_TERRASCOPE"
88103
else:
89-
raise ValueError(f"Unsupported backend: {url}")
104+
raise ValueError(f"Unsupported backend: {url=} ({hostname=})")
90105

91106

92107
@pytest.fixture

0 commit comments

Comments
 (0)