Skip to content

Commit

Permalink
Fix metrics tests broken by reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
averevki committed Oct 13, 2023
1 parent 1cac07a commit 538e33e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
6 changes: 6 additions & 0 deletions testsuite/openshift/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ def get_route(self, name):
with self.context:
return oc.selector(f"route/{name}").object(cls=OpenshiftRoute)

def get_routes_for_service(self, service_name: str) -> list[OpenshiftRoute]:
"""Returns list of routes for given service"""
with self.context:
routes = oc.selector("route").objects(cls=OpenshiftRoute)
return [r for r in routes if r.model.spec.to.name == service_name]

def do_action(self, verb: str, *args, auto_raise: bool = True, parse_output: bool = False):
"""Run an oc command."""
with self.context:
Expand Down
4 changes: 2 additions & 2 deletions testsuite/tests/kuadrant/authorino/metrics/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ def prometheus(request, openshift):
# find thanos-querier route in the openshift-monitoring project
# this route allows to query metrics
openshift_monitoring = openshift.change_project("openshift-monitoring")
routes = openshift_monitoring.routes.for_service("thanos-querier")
routes = openshift_monitoring.get_routes_for_service("thanos-querier")
if len(routes) > 0:
url = ("https://" if "tls" in routes[0]["spec"] else "http://") + routes[0]["spec"]["host"]
url = ("https://" if "tls" in routes[0].model.spec else "http://") + routes[0].model.spec.host
prometheus = Prometheus(url, openshift.token, openshift.project)
request.addfinalizer(prometheus.close)
return prometheus
Expand Down
20 changes: 6 additions & 14 deletions testsuite/tests/kuadrant/authorino/metrics/test_deep_metrics.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""Tests for the functionality of the deep-evaluator metric samples"""
import pytest

from testsuite.objects import Property, Value


@pytest.fixture(scope="module")
def mockserver_expectation(request, mockserver, module_label):
Expand All @@ -20,20 +22,10 @@ def authorization(authorization, mockserver_expectation):
- http metadata from the mockserver
- non-empty response
"""
authorization.identity.anonymous("anonymous", metrics=True)
authorization.authorization.opa_policy("opa", "allow { true }", metrics=True)
authorization.metadata.http_metadata("http", mockserver_expectation, "GET", metrics=True)
authorization.responses.add(
{
"name": "json",
"json": {
"properties": [
{"name": "auth", "value": "response"},
]
},
},
metrics=True,
)
authorization.identity.add_anonymous("anonymous", metrics=True)
authorization.authorization.add_opa_policy("opa", "allow { true }", metrics=True)
authorization.metadata.add_http("http", mockserver_expectation, "GET", metrics=True)
authorization.responses.add_json("json", [Property("auth", Value("response"))], metrics=True)

return authorization

Expand Down

0 comments on commit 538e33e

Please sign in to comment.