Skip to content
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
24 changes: 24 additions & 0 deletions tests/fixtures/guardrails.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,27 @@ def guardrails_orchestrator_health_route(
}
):
yield guardrails_orchestrator_health_route


@pytest.fixture(scope="class")
def guardrails_orchestrator_gateway_route(
admin_client: DynamicClient,
model_namespace: Namespace,
guardrails_orchestrator: GuardrailsOrchestrator,
) -> Generator[Route, Any, Any]:
guardrails_orchestrator_gateway_route = Route(
name=f"{guardrails_orchestrator.name}-gateway",
namespace=guardrails_orchestrator.namespace,
wait_for_resource=True,
ensure_exists=True,
)
with ResourceEditor(
patches={
guardrails_orchestrator_gateway_route: {
"metadata": {
"annotations": {Annotations.HaproxyRouterOpenshiftIo.TIMEOUT: "10m"},
}
}
}
):
yield guardrails_orchestrator_gateway_route
12 changes: 6 additions & 6 deletions tests/model_explainability/guardrails/test_guardrails.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ def test_guardrails_info_endpoint(self, qwen_isvc, guardrails_orchestrator_healt
assert response_data["services"]["regex"]["status"] == healthy_status

def test_guardrails_builtin_detectors_unsuitable_input(
self, current_client_token, openshift_ca_bundle_file, qwen_isvc, guardrails_orchestrator_route
self, current_client_token, openshift_ca_bundle_file, qwen_isvc, guardrails_orchestrator_gateway_route
):
response = requests.post(
url=f"https://{guardrails_orchestrator_route.host}{PII_ENDPOINT}{OpenAIEnpoints.CHAT_COMPLETIONS}",
url=f"https://{guardrails_orchestrator_gateway_route.host}{PII_ENDPOINT}{OpenAIEnpoints.CHAT_COMPLETIONS}",
headers=get_auth_headers(token=current_client_token),
json=get_chat_detections_payload(
content=PROMPT_WITH_PII,
Expand All @@ -184,10 +184,10 @@ def test_guardrails_builtin_detectors_unsuitable_input(
)

def test_guardrails_builtin_detectors_unsuitable_output(
self, current_client_token, openshift_ca_bundle_file, qwen_isvc, guardrails_orchestrator_route
self, current_client_token, openshift_ca_bundle_file, qwen_isvc, guardrails_orchestrator_gateway_route
):
response = requests.post(
url=f"https://{guardrails_orchestrator_route.host}{PII_ENDPOINT}{OpenAIEnpoints.CHAT_COMPLETIONS}",
url=f"https://{guardrails_orchestrator_gateway_route.host}{PII_ENDPOINT}{OpenAIEnpoints.CHAT_COMPLETIONS}",
headers=get_auth_headers(token=current_client_token),
json=get_chat_detections_payload(
content="Output example email address, nothing else.",
Expand Down Expand Up @@ -216,12 +216,12 @@ def test_guardrails_builtin_detectors_negative_detection(
current_client_token,
openshift_ca_bundle_file,
qwen_isvc,
guardrails_orchestrator_route,
guardrails_orchestrator_gateway_route,
message,
url_path,
):
response = requests.post(
url=f"https://{guardrails_orchestrator_route.host}{url_path}{OpenAIEnpoints.CHAT_COMPLETIONS}",
url=f"https://{guardrails_orchestrator_gateway_route.host}{url_path}{OpenAIEnpoints.CHAT_COMPLETIONS}",
headers=get_auth_headers(token=current_client_token),
json=get_chat_detections_payload(
content=str(message),
Expand Down