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

Added parametrization for limit tests to use both gateway and route as target_ref #287

Merged
merged 1 commit into from
Nov 21, 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
6 changes: 3 additions & 3 deletions testsuite/openshift/objects/rate_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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": {},
},
}
Expand Down
14 changes: 5 additions & 9 deletions testsuite/tests/kuadrant/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down