Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix metrics tests broken by reformat #241

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions testsuite/openshift/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ 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:
return oc.selector("route", field_selectors={"spec.to.name": service_name}).objects(cls=OpenshiftRoute)

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