Skip to content

Commit

Permalink
Add Kuadrant version to pytest report
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Zgabur <[email protected]>
  • Loading branch information
azgabur committed Aug 14, 2024
1 parent 95adf01 commit 02f333e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
18 changes: 18 additions & 0 deletions testsuite/capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,21 @@ def has_kuadrant():
return False, f"Cluster {cluster.api_url} does not have Kuadrant resource in project {project}"

return True, None


@functools.cache
def kuadrant_version():
"""Returns catalog image tag of deployed Kuadrant if possible."""
clusters = weakget(settings)["control_plane"]["additional_clusters"] % []
clusters.append(settings["cluster"])
versions = ""
for cluster in clusters:
project = cluster.change_project("openshift-marketplace")
if not project.connected:
break
with project.context:
catalog_source = selector("CatalogSource/kuadrant-upstream").object(ignore_not_found=True)
if catalog_source is None:
break
versions += f"Kuadrant image: {catalog_source.as_dict()["spec"]["image"]} on cluster {cluster.api_url}\n"
return versions
7 changes: 6 additions & 1 deletion testsuite/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from dynaconf import ValidationError
from keycloak import KeycloakAuthenticationError

from testsuite.capabilities import has_kuadrant
from testsuite.capabilities import has_kuadrant, kuadrant_version
from testsuite.certificates import CFSSLClient
from testsuite.config import settings
from testsuite.gateway import Exposer, CustomReference
Expand Down Expand Up @@ -71,6 +71,11 @@ def pytest_runtest_makereport(item, call): # pylint: disable=unused-argument
report.extra = extra


def pytest_report_header():
"""Adds Kuadrant version string to pytest header output for every cluster."""
return kuadrant_version()


@pytest.fixture(scope="session")
def skip_or_fail(request):
"""Skips or fails tests depending on --enforce option"""
Expand Down

0 comments on commit 02f333e

Please sign in to comment.