From 5437f4a78749c9b2c24286f67896a47e87a67f57 Mon Sep 17 00:00:00 2001 From: ShyunnY <1147212064@qq.com> Date: Sun, 28 Apr 2024 20:55:37 +0800 Subject: [PATCH] e2e: fix connectionLimit e2e test Signed-off-by: ShyunnY <1147212064@qq.com> --- test/e2e/tests/connection_limit.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/test/e2e/tests/connection_limit.go b/test/e2e/tests/connection_limit.go index 220be1a5616..d455232a7f7 100644 --- a/test/e2e/tests/connection_limit.go +++ b/test/e2e/tests/connection_limit.go @@ -13,7 +13,6 @@ import ( "net" "net/url" "testing" - "time" "github.com/envoyproxy/gateway/internal/gatewayapi" @@ -49,13 +48,13 @@ var ConnectionLimitTest = suite.ConformanceTest{ } ClientTrafficPolicyMustBeAccepted(t, suite.Client, types.NamespacedName{Name: "connection-limit-ctp", Namespace: ns}, suite.ControllerName, ancestorRef) - // open some connections - for i := 0; i < 10; i++ { - conn, err := net.DialTimeout("tcp", gwAddr, 100*time.Millisecond) - if err == nil { - defer conn.Close() - } else { + // we make the number of connections equal to the number of connectionLimit connections + 1 + for i := 0; i < 6; i++ { + conn, err := net.Dial("tcp", gwAddr) + if err != nil { t.Errorf("failed to open connection: %v", err) + } else { + defer conn.Close() } } @@ -77,10 +76,10 @@ var ConnectionLimitTest = suite.ConformanceTest{ if err != nil { urlError := &url.Error{} if !errors.As(err, &urlError) { - t.Errorf("expected net/url error when connection limit is reached") + t.Errorf("expected neturl error when connection limit reached, but other error occurred: %v", err) } } else { - t.Errorf("expected error when connection limit is reached") + t.Errorf("expected error not occurring when connection limit reached") } })