From 9d97da13f9499dde36dcd08dc4fc116f9fb9d33f Mon Sep 17 00:00:00 2001 From: bitliu Date: Mon, 17 Nov 2025 10:30:11 +0800 Subject: [PATCH] test: fail e2e tests when accuracy is 0% Add error handling to domain classification, PII detection, and jailbreak detection tests to ensure they fail explicitly when accuracy is 0%. Previously, these tests would return nil (success) even when all test cases failed, which could mask critical issues. Now they return a descriptive error when correctTests == 0, making test failures more visible and actionable. Signed-off-by: bitliu --- e2e/testcases/domain_classify.go | 5 +++++ e2e/testcases/jailbreak_detection.go | 5 +++++ e2e/testcases/pii_detection.go | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/e2e/testcases/domain_classify.go b/e2e/testcases/domain_classify.go index 87eb247fa..1dfaf170c 100644 --- a/e2e/testcases/domain_classify.go +++ b/e2e/testcases/domain_classify.go @@ -92,6 +92,11 @@ func testDomainClassify(ctx context.Context, client *kubernetes.Clientset, opts correctTests, totalTests, accuracy) } + // Return error if accuracy is 0% + if correctTests == 0 { + return fmt.Errorf("domain classification test failed: 0%% accuracy (0/%d correct)", totalTests) + } + return nil } diff --git a/e2e/testcases/jailbreak_detection.go b/e2e/testcases/jailbreak_detection.go index 7620b57e7..9070e851a 100644 --- a/e2e/testcases/jailbreak_detection.go +++ b/e2e/testcases/jailbreak_detection.go @@ -103,6 +103,11 @@ func testJailbreakDetection(ctx context.Context, client *kubernetes.Clientset, o correctTests, totalTests, detectionRate) } + // Return error if detection rate is 0% + if correctTests == 0 { + return fmt.Errorf("jailbreak detection test failed: 0%% accuracy (0/%d correct)", totalTests) + } + return nil } diff --git a/e2e/testcases/pii_detection.go b/e2e/testcases/pii_detection.go index 368480c86..bf56917a7 100644 --- a/e2e/testcases/pii_detection.go +++ b/e2e/testcases/pii_detection.go @@ -103,6 +103,11 @@ func testPIIDetection(ctx context.Context, client *kubernetes.Clientset, opts pk correctTests, totalTests, detectionRate) } + // Return error if detection rate is 0% + if correctTests == 0 { + return fmt.Errorf("PII detection test failed: 0%% accuracy (0/%d correct)", totalTests) + } + return nil }