diff --git a/testsuite/prometheus.py b/testsuite/prometheus.py index b9ad602e..eb7d8371 100644 --- a/testsuite/prometheus.py +++ b/testsuite/prometheus.py @@ -45,8 +45,7 @@ def values(self) -> list[float]: class Prometheus: """Interface to the Prometheus client""" - def __init__(self, client: Client, namespace: str = None): - self.namespace = namespace + def __init__(self, client: Client): self.client = ApyProxy(str(client.base_url), session=client).api.v1 def get_active_targets(self) -> dict: @@ -57,10 +56,6 @@ def get_active_targets(self) -> dict: def get_metrics(self, key: str = "", labels: dict[str, str] = None) -> Metrics: """Get metrics by key or labels""" - if self.namespace: - labels = labels or {} - labels.setdefault("namespace", self.namespace) - params = _params(key, labels) response = self.client.query.get(params=params) diff --git a/testsuite/tests/singlecluster/authorino/metrics/conftest.py b/testsuite/tests/singlecluster/authorino/metrics/conftest.py index c506166b..560d5de3 100644 --- a/testsuite/tests/singlecluster/authorino/metrics/conftest.py +++ b/testsuite/tests/singlecluster/authorino/metrics/conftest.py @@ -12,7 +12,7 @@ from testsuite.prometheus import Prometheus -@pytest.fixture(scope="module") +@pytest.fixture(scope="package") def prometheus(cluster): """ Return an instance of Thanos metrics client @@ -31,12 +31,12 @@ def prometheus(cluster): # this route allows to query metrics routes = openshift_monitoring.get_routes_for_service("thanos-querier") - if len(routes) > 0: - url = ("https://" if "tls" in routes[0].model.spec else "http://") + routes[0].model.spec.host - with KuadrantClient(headers={"Authorization": f"Bearer {cluster.token}"}, base_url=url, verify=False) as client: - yield Prometheus(client, cluster.project) + if len(routes) == 0: + pytest.skip("Skipping metrics tests as query route is not properly configured") - pytest.skip("Skipping metrics tests as query route is not properly configured") + url = ("https://" if "tls" in routes[0].model.spec else "http://") + routes[0].model.spec.host + with KuadrantClient(headers={"Authorization": f"Bearer {cluster.token}"}, base_url=url, verify=False) as client: + yield Prometheus(client) @pytest.fixture(scope="module")