From dd456fe41e6d4a1e7ffb2c72c0f94229b20251ab Mon Sep 17 00:00:00 2001 From: Jakub Smolar Date: Thu, 16 Nov 2023 17:28:53 +0100 Subject: [PATCH] Added parametrization for limit tests to use both gateway and route as target_ref --- testsuite/openshift/objects/rate_limit.py | 6 +++--- testsuite/tests/kuadrant/conftest.py | 14 +++++--------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/testsuite/openshift/objects/rate_limit.py b/testsuite/openshift/objects/rate_limit.py index 959adfeb..24674850 100644 --- a/testsuite/openshift/objects/rate_limit.py +++ b/testsuite/openshift/objects/rate_limit.py @@ -21,17 +21,17 @@ class Limit: class RateLimitPolicy(OpenShiftObject): - """RateLimitPolicy (or RLP for short) object, used for applying rate limiting rules to an Gateway/HTTPRoute""" + """RateLimitPolicy (or RLP for short) object, used for applying rate limiting rules to a Gateway/HTTPRoute""" @classmethod - def create_instance(cls, openshift: OpenShiftClient, name, route: Referencable, labels: dict[str, str] = None): + def create_instance(cls, openshift: OpenShiftClient, name, target: Referencable, labels: dict[str, str] = None): """Creates new instance of RateLimitPolicy""" model = { "apiVersion": "kuadrant.io/v1beta2", "kind": "RateLimitPolicy", "metadata": {"name": name, "labels": labels}, "spec": { - "targetRef": route.reference, + "targetRef": target.reference, "limits": {}, }, } diff --git a/testsuite/tests/kuadrant/conftest.py b/testsuite/tests/kuadrant/conftest.py index 8163bd12..0eb5622b 100644 --- a/testsuite/tests/kuadrant/conftest.py +++ b/testsuite/tests/kuadrant/conftest.py @@ -45,17 +45,13 @@ def authorization(authorino, kuadrant, oidc_provider, route, authorization_name, return None -@pytest.fixture(scope="module") -def rate_limit_name(blame): - """Name of the rate limit""" - return blame("limit") - - -@pytest.fixture(scope="module") -def rate_limit(kuadrant, openshift, rate_limit_name, route, module_label): +@pytest.fixture(scope="module", params=["route", "gateway"]) +def rate_limit(kuadrant, openshift, blame, request, module_label): """Rate limit""" if kuadrant: - return RateLimitPolicy.create_instance(openshift, rate_limit_name, route, labels={"testRun": module_label}) + return RateLimitPolicy.create_instance( + openshift, blame("limit"), request.getfixturevalue(request.param), labels={"testRun": module_label} + ) return None