diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index bc537aacb93..b96ac94e19c 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -16,6 +16,7 @@ import ( "k8s.io/apimachinery/pkg/util/sets" "sigs.k8s.io/gateway-api/conformance/utils/flags" "sigs.k8s.io/gateway-api/conformance/utils/suite" + "sigs.k8s.io/gateway-api/conformance/utils/tlog" "sigs.k8s.io/gateway-api/pkg/features" "github.com/envoyproxy/gateway/test/e2e/tests" @@ -28,10 +29,10 @@ func TestE2E(t *testing.T) { c := kubetest.NewClient(t) if flags.RunTest != nil && *flags.RunTest != "" { - t.Logf("Running E2E test %s with %s GatewayClass\n cleanup: %t\n debug: %t", + tlog.Logf(t, "Running E2E test %s with %s GatewayClass\n cleanup: %t\n debug: %t", *flags.RunTest, *flags.GatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug) } else { - t.Logf("Running E2E tests with %s GatewayClass\n cleanup: %t\n debug: %t", + tlog.Logf(t, "Running E2E tests with %s GatewayClass\n cleanup: %t\n debug: %t", *flags.GatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug) } @@ -54,7 +55,7 @@ func TestE2E(t *testing.T) { } cSuite.Setup(t, tests.ConformanceTests) - t.Logf("Running %d E2E tests", len(tests.ConformanceTests)) + tlog.Logf(t, "Running %d E2E tests", len(tests.ConformanceTests)) err = cSuite.Run(t, tests.ConformanceTests) if err != nil { t.Fatalf("Failed to run E2E tests: %v", err) diff --git a/test/e2e/merge_gateways/merge_gateways_test.go b/test/e2e/merge_gateways/merge_gateways_test.go index 568bdf79f3f..0acca7f550b 100644 --- a/test/e2e/merge_gateways/merge_gateways_test.go +++ b/test/e2e/merge_gateways/merge_gateways_test.go @@ -17,6 +17,7 @@ import ( "sigs.k8s.io/gateway-api/conformance/utils/flags" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" + "sigs.k8s.io/gateway-api/conformance/utils/tlog" "sigs.k8s.io/gateway-api/pkg/features" "github.com/envoyproxy/gateway/test/e2e" @@ -30,10 +31,10 @@ func TestMergeGateways(t *testing.T) { c := kubetest.NewClient(t) if flags.RunTest != nil && *flags.RunTest != "" { - t.Logf("Running E2E test %s with %s GatewayClass\n cleanup: %t\n debug: %t", + tlog.Logf(t, "Running E2E test %s with %s GatewayClass\n cleanup: %t\n debug: %t", *flags.RunTest, *flags.GatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug) } else { - t.Logf("Running E2E tests with %s GatewayClass\n cleanup: %t\n debug: %t", + tlog.Logf(t, "Running E2E tests with %s GatewayClass\n cleanup: %t\n debug: %t", *flags.GatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug) } @@ -58,7 +59,7 @@ func TestMergeGateways(t *testing.T) { cSuite.Applier.GatewayClass = *flags.GatewayClassName cSuite.ControllerName = kubernetes.GWCMustHaveAcceptedConditionTrue(t, cSuite.Client, cSuite.TimeoutConfig, cSuite.GatewayClassName) - t.Logf("Running %d MergeGateways tests", len(tests.MergeGatewaysTests)) + tlog.Logf(t, "Running %d MergeGateways tests", len(tests.MergeGatewaysTests)) err = cSuite.Run(t, tests.MergeGatewaysTests) if err != nil { t.Fatalf("Failed to run MergeGateways tests: %v", err) diff --git a/test/e2e/multiple_gc/multiple_gc_test.go b/test/e2e/multiple_gc/multiple_gc_test.go index 5e2709cd4a0..cd482a9e322 100644 --- a/test/e2e/multiple_gc/multiple_gc_test.go +++ b/test/e2e/multiple_gc/multiple_gc_test.go @@ -17,6 +17,7 @@ import ( "sigs.k8s.io/gateway-api/conformance/utils/flags" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" + "sigs.k8s.io/gateway-api/conformance/utils/tlog" "sigs.k8s.io/gateway-api/pkg/features" "github.com/envoyproxy/gateway/test/e2e" @@ -30,10 +31,10 @@ func TestMultipleGC(t *testing.T) { c := kubetest.NewClient(t) if flags.RunTest != nil && *flags.RunTest != "" { - t.Logf("Running E2E test %s with %s GatewayClass\n cleanup: %t\n debug: %t", + tlog.Logf(t, "Running E2E test %s with %s GatewayClass\n cleanup: %t\n debug: %t", *flags.RunTest, *flags.GatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug) } else { - t.Logf("Running E2E tests with %s GatewayClass\n cleanup: %t\n debug: %t", + tlog.Logf(t, "Running E2E tests with %s GatewayClass\n cleanup: %t\n debug: %t", *flags.GatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug) } @@ -61,7 +62,7 @@ func TestMultipleGC(t *testing.T) { internetGatewaySuite.Applier.GatewayClass = internetGatewaySuiteGatewayClassName internetGatewaySuite.ControllerName = kubernetes.GWCMustHaveAcceptedConditionTrue(t, internetGatewaySuite.Client, internetGatewaySuite.TimeoutConfig, internetGatewaySuite.GatewayClassName) - t.Logf("Running %d MultipleGC tests", len(tests.MultipleGCTests[internetGatewaySuiteGatewayClassName])) + tlog.Logf(t, "Running %d MultipleGC tests", len(tests.MultipleGCTests[internetGatewaySuiteGatewayClassName])) err = internetGatewaySuite.Run(t, tests.MultipleGCTests[internetGatewaySuiteGatewayClassName]) if err != nil { @@ -93,7 +94,7 @@ func TestMultipleGC(t *testing.T) { privateGatewaySuite.Applier.GatewayClass = privateGatewaySuiteGatewayClassName privateGatewaySuite.ControllerName = kubernetes.GWCMustHaveAcceptedConditionTrue(t, privateGatewaySuite.Client, privateGatewaySuite.TimeoutConfig, privateGatewaySuite.GatewayClassName) - t.Logf("Running %d MultipleGC tests", len(tests.MultipleGCTests[privateGatewaySuiteGatewayClassName])) + tlog.Logf(t, "Running %d MultipleGC tests", len(tests.MultipleGCTests[privateGatewaySuiteGatewayClassName])) err = privateGatewaySuite.Run(t, tests.MultipleGCTests[privateGatewaySuiteGatewayClassName]) if err != nil { t.Fatalf("Failed to run PrivateGC tests: %v", err) diff --git a/test/e2e/tests/accesslog.go b/test/e2e/tests/accesslog.go index 1fecc669c34..2e1ee205b8c 100644 --- a/test/e2e/tests/accesslog.go +++ b/test/e2e/tests/accesslog.go @@ -18,6 +18,7 @@ import ( httputils "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" + "sigs.k8s.io/gateway-api/conformance/utils/tlog" ) func init() { @@ -159,7 +160,7 @@ var ALSTest = suite.ConformanceTest{ func(ctx context.Context) (bool, error) { curCount, err := ALSLogCount(suite) if err != nil { - t.Logf("failed to get log count from loki: %v", err) + tlog.Logf(t, "failed to get log count from loki: %v", err) return false, nil } preCount = curCount @@ -187,7 +188,7 @@ var ALSTest = suite.ConformanceTest{ func(ctx context.Context) (bool, error) { curCount, err := ALSLogCount(suite) if err != nil { - t.Logf("failed to get log count from loki: %v", err) + tlog.Logf(t, "failed to get log count from loki: %v", err) return false, nil } return preCount < curCount, nil @@ -206,7 +207,7 @@ func runLogTest(t *testing.T, suite *suite.ConformanceTestSuite, gwAddr string, // query log count from loki preCount, err := QueryLogCountFromLoki(t, suite.Client, expectedLabels, expectedMatch) if err != nil { - t.Logf("failed to get log count from loki: %v", err) + tlog.Logf(t, "failed to get log count from loki: %v", err) return false, nil } @@ -217,7 +218,7 @@ func runLogTest(t *testing.T, suite *suite.ConformanceTestSuite, gwAddr string, if err := wait.PollUntilContextTimeout(ctx, 500*time.Millisecond, 15*time.Second, true, func(_ context.Context) (bool, error) { count, err := QueryLogCountFromLoki(t, suite.Client, expectedLabels, expectedMatch) if err != nil { - t.Logf("failed to get log count from loki: %v", err) + tlog.Logf(t, "failed to get log count from loki: %v", err) return false, nil } @@ -226,7 +227,7 @@ func runLogTest(t *testing.T, suite *suite.ConformanceTestSuite, gwAddr string, return true, nil } - t.Logf("preCount=%d, count=%d", preCount, count) + tlog.Logf(t, "preCount=%d, count=%d", preCount, count) return false, nil }); err != nil { return false, nil diff --git a/test/e2e/tests/backend_health_check.go b/test/e2e/tests/backend_health_check.go index f5d56171aaf..4936d372079 100644 --- a/test/e2e/tests/backend_health_check.go +++ b/test/e2e/tests/backend_health_check.go @@ -21,6 +21,7 @@ import ( "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" + "sigs.k8s.io/gateway-api/conformance/utils/tlog" "github.com/envoyproxy/gateway/internal/gatewayapi" "github.com/envoyproxy/gateway/test/utils/prometheus" @@ -77,7 +78,7 @@ var BackendHealthCheckActiveHTTPTest = suite.ConformanceTest{ // wait until Prometheus sync stats return false } - t.Logf("cluster pass health check: success stats query count: %v", v) + tlog.Logf(t, "cluster pass health check: success stats query count: %v", v) if v == 0 { t.Error("success is not the same as expected") @@ -100,7 +101,7 @@ var BackendHealthCheckActiveHTTPTest = suite.ConformanceTest{ // wait until Prometheus sync stats return false } - t.Logf("cluster fail health check: failure stats query count: %v", v) + tlog.Logf(t, "cluster fail health check: failure stats query count: %v", v) if v == 0 { t.Error("failure is not same as expected") diff --git a/test/e2e/tests/client_timeout.go b/test/e2e/tests/client_timeout.go index 7171dda1d32..9a11f7a706a 100644 --- a/test/e2e/tests/client_timeout.go +++ b/test/e2e/tests/client_timeout.go @@ -18,6 +18,7 @@ import ( httputils "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" + "sigs.k8s.io/gateway-api/conformance/utils/tlog" ) func init() { @@ -58,7 +59,7 @@ var ClientTimeoutTest = suite.ConformanceTest{ if http.StatusGatewayTimeout == resp.StatusCode { return true } else { - t.Logf("response status code: %d, (after %v) ", resp.StatusCode, elapsed) + tlog.Logf(t, "response status code: %d, (after %v) ", resp.StatusCode, elapsed) return false } }) diff --git a/test/e2e/tests/connection_limit.go b/test/e2e/tests/connection_limit.go index feea1ca8a88..97594c97774 100644 --- a/test/e2e/tests/connection_limit.go +++ b/test/e2e/tests/connection_limit.go @@ -23,6 +23,7 @@ import ( "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" + "sigs.k8s.io/gateway-api/conformance/utils/tlog" "github.com/envoyproxy/gateway/internal/gatewayapi" "github.com/envoyproxy/gateway/test/utils/prometheus" @@ -63,7 +64,7 @@ var ConnectionLimitTest = suite.ConformanceTest{ func(_ context.Context) (done bool, err error) { _, err = net.DialTimeout("tcp", gwAddr, 100*time.Millisecond) if err != nil { - t.Logf("failed to open connection: %v", err) + tlog.Logf(t, "failed to open connection: %v", err) return false, nil } t.Log("opened connection 1") @@ -75,7 +76,7 @@ var ConnectionLimitTest = suite.ConformanceTest{ // Open the remaining 5 connections for i := 1; i < 6; i++ { conn, err := net.Dial("tcp", gwAddr) - t.Logf("opened connection %d", i+1) + tlog.Logf(t, "opened connection %d", i+1) if err != nil { t.Errorf("failed to open connection: %v", err) } else { @@ -98,7 +99,7 @@ var ConnectionLimitTest = suite.ConformanceTest{ // wait until Prometheus sync stats return false } - t.Logf("connection_limit stats query count: %v", v) + tlog.Logf(t, "connection_limit stats query count: %v", v) // connection interruptions or other connection errors may occur // we just need to determine whether there is a connection limit stats diff --git a/test/e2e/tests/controlplane.go b/test/e2e/tests/controlplane.go index 7149c2546b6..56577c880ac 100644 --- a/test/e2e/tests/controlplane.go +++ b/test/e2e/tests/controlplane.go @@ -17,6 +17,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/wait" "sigs.k8s.io/gateway-api/conformance/utils/suite" + "sigs.k8s.io/gateway-api/conformance/utils/tlog" ) func init() { @@ -64,7 +65,7 @@ var ControlPlaneMetricTest = suite.ConformanceTest{ if err := wait.PollUntilContextTimeout(context.TODO(), time.Second, 2*time.Minute, true, func(_ context.Context) (done bool, err error) { if err := ScrapeMetrics(t, suite.Client, nn, 19001, "/metrics"); err != nil { - t.Logf("failed to get metric: %v", err) + tlog.Logf(t, "failed to get metric: %v", err) return false, nil } return true, nil diff --git a/test/e2e/tests/eg_upgrade.go b/test/e2e/tests/eg_upgrade.go index 672cabcc596..5a394d134f1 100644 --- a/test/e2e/tests/eg_upgrade.go +++ b/test/e2e/tests/eg_upgrade.go @@ -176,7 +176,7 @@ func cleanUpResources(c client.Client, t *testing.T) { } for _, o := range list.Items { - t.Logf("deleting %s: %s/%s", o.GetObjectKind(), o.GetNamespace(), o.GetName()) + tlog.Logf(t, "deleting %s: %s/%s", o.GetObjectKind(), o.GetNamespace(), o.GetName()) if err := c.Delete(context.Background(), &o); err != nil { if !kerrors.IsNotFound(err) { t.Fatalf("error deleting %s: %s/%s : %v", o.GetObjectKind(), o.GetNamespace(), o.GetName(), err) @@ -192,7 +192,7 @@ func cleanUpResources(c client.Client, t *testing.T) { } if len(list.Items) > 0 { - t.Logf("Waiting for deletion of %d %s", len(list.Items), gvk.String()) + tlog.Logf(t, "Waiting for deletion of %d %s", len(list.Items), gvk.String()) return false, nil } diff --git a/test/e2e/tests/load_balancing.go b/test/e2e/tests/load_balancing.go index e08dd975655..6b36bdb77ba 100644 --- a/test/e2e/tests/load_balancing.go +++ b/test/e2e/tests/load_balancing.go @@ -30,6 +30,7 @@ import ( "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/roundtripper" "sigs.k8s.io/gateway-api/conformance/utils/suite" + "sigs.k8s.io/gateway-api/conformance/utils/tlog" "github.com/envoyproxy/gateway/internal/gatewayapi" ) @@ -364,7 +365,7 @@ var ConsistentHashCookieLoadBalancingTest = suite.ConformanceTest{ return true, nil } - t.Logf("Cookie have not been generated yet") + tlog.Logf(t, "Cookie have not been generated yet") return false, nil }) require.NoError(t, waitErr) @@ -387,7 +388,7 @@ func WaitDeployment(t *testing.T, cli client.Client, name types.NamespacedName, return true, nil } - t.Logf("Deployment not yet accepted: %s", name.String()) + tlog.Logf(t, "Deployment not yet accepted: %s", name.String()) return false, nil }) diff --git a/test/e2e/tests/metric.go b/test/e2e/tests/metric.go index fff4809edda..b9814f41e56 100644 --- a/test/e2e/tests/metric.go +++ b/test/e2e/tests/metric.go @@ -18,6 +18,7 @@ import ( httputils "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" + "sigs.k8s.io/gateway-api/conformance/utils/tlog" ) func init() { @@ -54,7 +55,7 @@ var MetricTest = suite.ConformanceTest{ Namespace: "envoy-gateway-system", Name: "same-namespace-gw-metrics", }, 19001, "/stats/prometheus"); err != nil { - t.Logf("failed to get metric: %v", err) + tlog.Logf(t, "failed to get metric: %v", err) return false, nil } return true, nil @@ -88,7 +89,7 @@ var MetricTest = suite.ConformanceTest{ Namespace: "monitoring", Name: "otel-collecot-prometheus", }, 19001, "/metrics"); err != nil { - t.Logf("failed to get metric: %v", err) + tlog.Logf(t, "failed to get metric: %v", err) return false, nil } return true, nil diff --git a/test/e2e/tests/oidc.go b/test/e2e/tests/oidc.go index b7617e8e0d7..0356a149a04 100644 --- a/test/e2e/tests/oidc.go +++ b/test/e2e/tests/oidc.go @@ -25,6 +25,7 @@ import ( gwhttp "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" + "sigs.k8s.io/gateway-api/conformance/utils/tlog" "github.com/envoyproxy/gateway/internal/gatewayapi" ) @@ -80,7 +81,7 @@ var OIDCTest = suite.ConformanceTest{ if err := wait.PollUntilContextTimeout(context.TODO(), time.Second, 5*time.Minute, true, func(_ context.Context) (done bool, err error) { - t.Logf("sending request to %s", testURL) + tlog.Logf(t, "sending request to %s", testURL) // Send a request to the http route with OIDC configured. // It will be redirected to the keycloak login page @@ -90,7 +91,7 @@ var OIDCTest = suite.ConformanceTest{ // Parse the response body to get the URL where the login page would post the user-entered credentials if err := client.ParseLoginForm(res.Body, keyCloakLoginFormID); err != nil { - t.Logf("failed to parse login form: %v", err) + tlog.Logf(t, "failed to parse login form: %v", err) return false, nil } diff --git a/test/e2e/tests/retry.go b/test/e2e/tests/retry.go index 0882c93923f..ca18d09c014 100644 --- a/test/e2e/tests/retry.go +++ b/test/e2e/tests/retry.go @@ -19,6 +19,7 @@ import ( "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" + "sigs.k8s.io/gateway-api/conformance/utils/tlog" "github.com/envoyproxy/gateway/test/utils/prometheus" ) @@ -60,7 +61,7 @@ var RetryTest = suite.ConformanceTest{ if err == nil { before = v } - t.Logf("query count %s before: %v", promQL, before) + tlog.Logf(t, "query count %s before: %v", promQL, before) req := http.MakeRequest(t, &expectedResponse, gwAddr, "HTTP", "http") cReq, cResp, err := suite.RoundTripper.CaptureRoundTrip(req) @@ -81,7 +82,7 @@ var RetryTest = suite.ConformanceTest{ if err != nil { return false } - t.Logf("query count %s after: %v", promQL, v) + tlog.Logf(t, "query count %s after: %v", promQL, v) delta := int64(v - before) // numRetries is 5, so delta mod 5 equals 0 diff --git a/test/e2e/tests/tcp_route.go b/test/e2e/tests/tcp_route.go index 8a703e08b92..71e43f17164 100644 --- a/test/e2e/tests/tcp_route.go +++ b/test/e2e/tests/tcp_route.go @@ -29,6 +29,7 @@ import ( "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" + "sigs.k8s.io/gateway-api/conformance/utils/tlog" ) func init() { @@ -85,7 +86,7 @@ func GatewayAndTCPRoutesMustBeAccepted(t *testing.T, c client.Client, timeoutCon tcpRoute := &gwapiv1a2.TCPRoute{} err := c.Get(context.Background(), routeNNs[0], tcpRoute) if err != nil { - t.Logf("error fetching TCPRoute: %v", err) + tlog.Logf(t, "error fetching TCPRoute: %v", err) } gwAddr, err := WaitForGatewayAddress(t, c, timeoutConfig, gw.NamespacedName, string(*tcpRoute.Spec.ParentRefs[0].SectionName)) @@ -134,7 +135,7 @@ func WaitForGatewayAddress(t *testing.T, client client.Client, timeoutConfig con gw := &gwapiv1.Gateway{} err := client.Get(ctx, gwName, gw) if err != nil { - t.Logf("error fetching Gateway: %v", err) + tlog.Logf(t, "error fetching Gateway: %v", err) return false, fmt.Errorf("error fetching Gateway: %w", err) } diff --git a/test/e2e/tests/tracing.go b/test/e2e/tests/tracing.go index 9d77a5a9111..bd169780121 100644 --- a/test/e2e/tests/tracing.go +++ b/test/e2e/tests/tracing.go @@ -19,6 +19,7 @@ import ( httputils "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" + "sigs.k8s.io/gateway-api/conformance/utils/tlog" "github.com/envoyproxy/gateway/internal/utils/naming" ) @@ -60,7 +61,7 @@ var OpenTelemetryTracingTest = suite.ConformanceTest{ func(ctx context.Context) (bool, error) { count, err := QueryTraceFromTempo(t, suite.Client, tags) if err != nil { - t.Logf("failed to get trace count from tempo: %v", err) + tlog.Logf(t, "failed to get trace count from tempo: %v", err) return false, nil } @@ -109,7 +110,7 @@ var ZipkinTracingTest = suite.ConformanceTest{ func(ctx context.Context) (bool, error) { preCount, err := QueryTraceFromTempo(t, suite.Client, tags) if err != nil { - t.Logf("failed to get trace count from tempo: %v", err) + tlog.Logf(t, "failed to get trace count from tempo: %v", err) return false, nil } @@ -119,7 +120,7 @@ var ZipkinTracingTest = suite.ConformanceTest{ err = wait.PollUntilContextTimeout(context.TODO(), time.Second, 15*time.Second, true, func(ctx context.Context) (done bool, err error) { curCount, err := QueryTraceFromTempo(t, suite.Client, tags) if err != nil { - t.Logf("failed to get curCount count from tempo: %v", err) + tlog.Logf(t, "failed to get curCount count from tempo: %v", err) return false, nil } @@ -130,7 +131,7 @@ var ZipkinTracingTest = suite.ConformanceTest{ return false, nil }) if err != nil { - t.Logf("failed to get current count from tempo: %v", err) + tlog.Logf(t, "failed to get current count from tempo: %v", err) return false, nil } diff --git a/test/e2e/tests/udproute.go b/test/e2e/tests/udproute.go index 34839f91334..4eb160139c1 100644 --- a/test/e2e/tests/udproute.go +++ b/test/e2e/tests/udproute.go @@ -28,6 +28,7 @@ import ( "sigs.k8s.io/gateway-api/conformance/utils/config" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" + "sigs.k8s.io/gateway-api/conformance/utils/tlog" ) func init() { @@ -51,13 +52,13 @@ var UDPRouteTest = suite.ConformanceTest{ if err := wait.PollUntilContextTimeout(context.TODO(), time.Second, time.Minute, true, func(_ context.Context) (done bool, err error) { - t.Logf("performing DNS query %s on %s", domain, gwAddr) + tlog.Logf(t, "performing DNS query %s on %s", domain, gwAddr) r, err := dns.Exchange(msg, gwAddr) if err != nil { - t.Logf("failed to perform a UDP query: %v", err) + tlog.Logf(t, "failed to perform a UDP query: %v", err) return false, nil } - t.Logf("got DNS response: %s", r.String()) + tlog.Logf(t, "got DNS response: %s", r.String()) return true, nil }); err != nil { t.Errorf("failed to perform DNS query: %v", err) @@ -159,31 +160,31 @@ func parentsForRouteMatch(t *testing.T, routeName types.NamespacedName, expected t.Helper() if len(expected) != len(actual) { - t.Logf("Route %s/%s expected %d Parents got %d", routeName.Namespace, routeName.Name, len(expected), len(actual)) + tlog.Logf(t, "Route %s/%s expected %d Parents got %d", routeName.Namespace, routeName.Name, len(expected), len(actual)) return false } for i, expectedParent := range expected { actualParent := actual[i] if actualParent.ControllerName != expectedParent.ControllerName { - t.Logf("Route %s/%s ControllerName doesn't match", routeName.Namespace, routeName.Name) + tlog.Logf(t, "Route %s/%s ControllerName doesn't match", routeName.Namespace, routeName.Name) return false } if !reflect.DeepEqual(actualParent.ParentRef.Group, expectedParent.ParentRef.Group) { - t.Logf("Route %s/%s expected ParentReference.Group to be %v, got %v", routeName.Namespace, routeName.Name, expectedParent.ParentRef.Group, actualParent.ParentRef.Group) + tlog.Logf(t, "Route %s/%s expected ParentReference.Group to be %v, got %v", routeName.Namespace, routeName.Name, expectedParent.ParentRef.Group, actualParent.ParentRef.Group) return false } if !reflect.DeepEqual(actualParent.ParentRef.Kind, expectedParent.ParentRef.Kind) { - t.Logf("Route %s/%s expected ParentReference.Kind to be %v, got %v", routeName.Namespace, routeName.Name, expectedParent.ParentRef.Kind, actualParent.ParentRef.Kind) + tlog.Logf(t, "Route %s/%s expected ParentReference.Kind to be %v, got %v", routeName.Namespace, routeName.Name, expectedParent.ParentRef.Kind, actualParent.ParentRef.Kind) return false } if actualParent.ParentRef.Name != expectedParent.ParentRef.Name { - t.Logf("Route %s/%s ParentReference.Name doesn't match", routeName.Namespace, routeName.Name) + tlog.Logf(t, "Route %s/%s ParentReference.Name doesn't match", routeName.Namespace, routeName.Name) return false } if !reflect.DeepEqual(actualParent.ParentRef.Namespace, expectedParent.ParentRef.Namespace) { if namespaceRequired || actualParent.ParentRef.Namespace != nil { - t.Logf("Route %s/%s expected ParentReference.Namespace to be %v, got %v", routeName.Namespace, routeName.Name, expectedParent.ParentRef.Namespace, actualParent.ParentRef.Namespace) + tlog.Logf(t, "Route %s/%s expected ParentReference.Namespace to be %v, got %v", routeName.Namespace, routeName.Name, expectedParent.ParentRef.Namespace, actualParent.ParentRef.Namespace) return false } } @@ -192,7 +193,7 @@ func parentsForRouteMatch(t *testing.T, routeName types.NamespacedName, expected } } - t.Logf("Route %s/%s Parents matched expectations", routeName.Namespace, routeName.Name) + tlog.Logf(t, "Route %s/%s Parents matched expectations", routeName.Namespace, routeName.Name) return true } @@ -200,7 +201,7 @@ func conditionsMatch(t *testing.T, expected, actual []metav1.Condition) bool { t.Helper() if len(actual) < len(expected) { - t.Logf("Expected more conditions to be present") + tlog.Logf(t, "Expected more conditions to be present") return false } for _, condition := range expected { @@ -209,7 +210,7 @@ func conditionsMatch(t *testing.T, expected, actual []metav1.Condition) bool { } } - t.Logf("Conditions matched expectations") + tlog.Logf(t, "Conditions matched expectations") return true } @@ -227,13 +228,13 @@ func findConditionInList(t *testing.T, conditions []metav1.Condition, condName, if expectedReason == "" || cond.Reason == expectedReason { return true } - t.Logf("%s condition Reason set to %s, expected %s", condName, cond.Reason, expectedReason) + tlog.Logf(t, "%s condition Reason set to %s, expected %s", condName, cond.Reason, expectedReason) } - t.Logf("%s condition set to Status %s with Reason %v, expected Status %s", condName, cond.Status, cond.Reason, expectedStatus) + tlog.Logf(t, "%s condition set to Status %s with Reason %v, expected Status %s", condName, cond.Status, cond.Reason, expectedStatus) } } - t.Logf("%s was not in conditions list [%v]", condName, conditions) + tlog.Logf(t, "%s was not in conditions list [%v]", condName, conditions) return false } diff --git a/test/e2e/tests/utils.go b/test/e2e/tests/utils.go index 9569baaf58c..ab1f315925c 100644 --- a/test/e2e/tests/utils.go +++ b/test/e2e/tests/utils.go @@ -47,7 +47,7 @@ const defaultServiceStartupTimeout = 5 * time.Minute // WaitForPods waits for the pods in the given namespace and with the given selector // to be in the given phase and condition. func WaitForPods(t *testing.T, cl client.Client, namespace string, selectors map[string]string, phase corev1.PodPhase, condition corev1.PodCondition) { - t.Logf("waiting for %s/[%s] to be %v...", namespace, selectors, phase) + tlog.Logf(t, "waiting for %s/[%s] to be %v...", namespace, selectors, phase) require.Eventually(t, func() bool { pods := &corev1.PodList{} @@ -77,7 +77,7 @@ func WaitForPods(t *testing.T, cl client.Client, namespace string, selectors map } } - t.Logf("pod %s/%s status: %v", p.Namespace, p.Name, p.Status) + tlog.Logf(t, "pod %s/%s status: %v", p.Namespace, p.Name, p.Status) return false } @@ -97,11 +97,11 @@ func SecurityPolicyMustBeAccepted(t *testing.T, client client.Client, policyName } if policyAcceptedByAncestor(policy.Status.Ancestors, controllerName, ancestorRef) { - t.Logf("SecurityPolicy has been accepted: %v", policy) + tlog.Logf(t, "SecurityPolicy has been accepted: %v", policy) return true, nil } - t.Logf("SecurityPolicy not yet accepted: %v", policy) + tlog.Logf(t, "SecurityPolicy not yet accepted: %v", policy) return false, nil }) @@ -125,7 +125,7 @@ func SecurityPolicyMustFail( } if policyFailAcceptedByAncestor(policy.Status.Ancestors, controllerName, ancestorRef, message) { - t.Logf("SecurityPolicy has been failed: %v", policy) + tlog.Logf(t, "SecurityPolicy has been failed: %v", policy) return true, nil } @@ -150,7 +150,7 @@ func BackendTrafficPolicyMustBeAccepted(t *testing.T, client client.Client, poli return true, nil } - t.Logf("BackendTrafficPolicy not yet accepted: %v", policy) + tlog.Logf(t, "BackendTrafficPolicy not yet accepted: %v", policy) return false, nil }) @@ -172,7 +172,7 @@ func ClientTrafficPolicyMustBeAccepted(t *testing.T, client client.Client, polic return true, nil } - t.Logf("ClientTrafficPolicy not yet accepted: %v", policy) + tlog.Logf(t, "ClientTrafficPolicy not yet accepted: %v", policy) return false, nil }) @@ -212,7 +212,7 @@ func runLoadAndWait(t *testing.T, timeoutConfig config.TimeoutConfig, done chan res, err := fhttp.RunHTTPTest(&opts) if err != nil { done <- false - t.Logf("failed to create load: %v", err) + tlog.Logf(t, "failed to create load: %v", err) } // collect stats @@ -221,7 +221,7 @@ func runLoadAndWait(t *testing.T, timeoutConfig config.TimeoutConfig, done chan failedReq := totalReq - okReq errorReq := res.ErrorsDurationHistogram.Count timedOut := res.ActualDuration == opts.Duration - t.Logf("Load completed after %s with %d requests, %d success, %d failures and %d errors", res.ActualDuration, totalReq, okReq, failedReq, errorReq) + tlog.Logf(t, "Load completed after %s with %d requests, %d success, %d failures and %d errors", res.ActualDuration, totalReq, okReq, failedReq, errorReq) if okReq == totalReq && errorReq == 0 && !timedOut { done <- true @@ -259,7 +259,7 @@ func EnvoyExtensionPolicyMustFail( } if policyFailAcceptedByAncestor(policy.Status.Ancestors, controllerName, ancestorRef, message) { - t.Logf("EnvoyExtensionPolicy has been failed: %v", policy) + tlog.Logf(t, "EnvoyExtensionPolicy has been failed: %v", policy) return true, nil } @@ -296,11 +296,11 @@ func EnvoyExtensionPolicyMustBeAccepted(t *testing.T, client client.Client, poli } if policyAcceptedByAncestor(policy.Status.Ancestors, controllerName, ancestorRef) { - t.Logf("EnvoyExtensionPolicy has been accepted: %v", policy) + tlog.Logf(t, "EnvoyExtensionPolicy has been accepted: %v", policy) return true, nil } - t.Logf("EnvoyExtensionPolicy not yet accepted: %v", policy) + tlog.Logf(t, "EnvoyExtensionPolicy not yet accepted: %v", policy) return false, nil }) @@ -313,7 +313,7 @@ func ScrapeMetrics(t *testing.T, c client.Client, nn types.NamespacedName, port return err } - t.Logf("scraping metrics from %s", url) + tlog.Logf(t, "scraping metrics from %s", url) metrics, err := RetrieveMetrics(url, time.Second) if err != nil { @@ -464,7 +464,7 @@ func QueryLogCountFromLoki(t *testing.T, c client.Client, keyValues map[string]s if err != nil { return -1, err } - t.Logf("get response from loki, query=%s, status=%s", q, res.Status) + tlog.Logf(t, "get response from loki, query=%s, status=%s", q, res.Status) b, err := io.ReadAll(res.Body) if err != nil { @@ -484,7 +484,7 @@ func QueryLogCountFromLoki(t *testing.T, c client.Client, keyValues map[string]s for _, res := range lokiResponse.Data.Result { total += len(res.Values) } - t.Logf("get response from loki, query=%s, total=%d", q, total) + tlog.Logf(t, "get response from loki, query=%s, total=%d", q, total) return total, nil } @@ -537,7 +537,7 @@ func QueryTraceFromTempo(t *testing.T, c client.Client, tags map[string]string) return -1, err } - t.Logf("send request to %s", tempoURL.String()) + tlog.Logf(t, "send request to %s", tempoURL.String()) res, err := http.DefaultClient.Do(req) if err != nil { return -1, err @@ -553,7 +553,7 @@ func QueryTraceFromTempo(t *testing.T, c client.Client, tags map[string]string) } total := len(tempoResponse.Traces) - t.Logf("get response from tempo, url=%s, response=%v, total=%d", tempoURL.String(), tempoResponse, total) + tlog.Logf(t, "get response from tempo, url=%s, response=%v, total=%d", tempoURL.String(), tempoResponse, total) return total, nil } diff --git a/test/e2e/tests/wasm_oci.go b/test/e2e/tests/wasm_oci.go index 1a41187092b..69c6b0ad6c1 100644 --- a/test/e2e/tests/wasm_oci.go +++ b/test/e2e/tests/wasm_oci.go @@ -37,6 +37,7 @@ import ( "sigs.k8s.io/gateway-api/conformance/utils/http" "sigs.k8s.io/gateway-api/conformance/utils/kubernetes" "sigs.k8s.io/gateway-api/conformance/utils/suite" + "sigs.k8s.io/gateway-api/conformance/utils/tlog" egv1a1 "github.com/envoyproxy/gateway/api/v1alpha1" "github.com/envoyproxy/gateway/internal/gatewayapi" @@ -303,7 +304,7 @@ func pushWasmImageForTest(t *testing.T, suite *suite.ConformanceTestSuite, regis if err == nil { break } - t.Logf("failed to push image: %v", err) + tlog.Logf(t, "failed to push image: %v", err) } if err != nil { t.Fatalf("failed to push image: %v", err) @@ -316,7 +317,7 @@ func pushWasmImageForTest(t *testing.T, suite *suite.ConformanceTestSuite, regis t.Fatalf("failed to get image digest: %v", err) } - t.Logf("pushed image %s with digest: %s", tag, digest.Hex) + tlog.Logf(t, "pushed image %s with digest: %s", tag, digest.Hex) return digest.Hex } diff --git a/test/e2e/upgrade/eg_upgrade_test.go b/test/e2e/upgrade/eg_upgrade_test.go index ab961e3a2f1..d0707352daa 100644 --- a/test/e2e/upgrade/eg_upgrade_test.go +++ b/test/e2e/upgrade/eg_upgrade_test.go @@ -16,6 +16,7 @@ import ( "k8s.io/apimachinery/pkg/util/sets" "sigs.k8s.io/gateway-api/conformance/utils/flags" "sigs.k8s.io/gateway-api/conformance/utils/suite" + "sigs.k8s.io/gateway-api/conformance/utils/tlog" "sigs.k8s.io/gateway-api/pkg/features" "github.com/envoyproxy/gateway/test/e2e" @@ -29,10 +30,10 @@ func TestEGUpgrade(t *testing.T) { c := kubetest.NewClient(t) if flags.RunTest != nil && *flags.RunTest != "" { - t.Logf("Running E2E test %s with %s GatewayClass\n cleanup: %t\n debug: %t", + tlog.Logf(t, "Running E2E test %s with %s GatewayClass\n cleanup: %t\n debug: %t", *flags.RunTest, *flags.GatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug) } else { - t.Logf("Running E2E tests with %s GatewayClass\n cleanup: %t\n debug: %t", + tlog.Logf(t, "Running E2E tests with %s GatewayClass\n cleanup: %t\n debug: %t", *flags.GatewayClassName, *flags.CleanupBaseResources, *flags.ShowDebug) } @@ -57,7 +58,7 @@ func TestEGUpgrade(t *testing.T) { tests.EGUpgradeTest, } - t.Logf("Running %d Upgrade tests", len(tests.UpgradeTests)) + tlog.Logf(t, "Running %d Upgrade tests", len(tests.UpgradeTests)) cSuite.Setup(t, tests.UpgradeTests) err = cSuite.Run(t, tests.UpgradeTests)