From b04f082ac79d1cb105c83a3d506c4e5133dee322 Mon Sep 17 00:00:00 2001 From: Viktor Voytovych Date: Tue, 3 Nov 2026 17:25:40 +0200 Subject: [PATCH] test: Give the internal error test a tracker key of its own The HTTPProxy programming tracker is the process's own. TestHTTPProxyReconcile programs proxy test/test on test-cluster, and the tracker then skips that key's next unprogrammed generation, so this test's pending entry was never written. It passed in the default order only because TestHTTPProxyFleetCollector runs between the two, and its collector prunes the same tracker. Under -shuffle it failed. The test now reads a cluster name no other test uses. --- internal/controller/httpproxy_metrics_test.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/controller/httpproxy_metrics_test.go b/internal/controller/httpproxy_metrics_test.go index cb45d101..29daf43c 100644 --- a/internal/controller/httpproxy_metrics_test.go +++ b/internal/controller/httpproxy_metrics_test.go @@ -483,11 +483,15 @@ func TestHTTPProxyReconcileInternalErrorGetsStableFixedMessage(t *testing.T) { }, } + // The programming tracker is the process's own, and other tests program + // this proxy on test-cluster. Whether their entry is still there depends + // on the order the tests run in, so this test reads a key of its own. + const cluster = "internal-error-cluster" before := testutil.ToFloat64(httpProxyReconcileErrorsTotal.WithLabelValues("httproute", "forbidden")) _, err := reconciler.Reconcile(context.Background(), mcreconcile.Request{ Request: reconcile.Request{NamespacedName: client.ObjectKeyFromObject(httpProxy)}, - ClusterName: "test-cluster", + ClusterName: cluster, }) require.Error(t, err) @@ -506,7 +510,7 @@ func TestHTTPProxyReconcileInternalErrorGetsStableFixedMessage(t *testing.T) { _, err = reconciler.Reconcile(context.Background(), mcreconcile.Request{ Request: reconcile.Request{NamespacedName: client.ObjectKeyFromObject(httpProxy)}, - ClusterName: "test-cluster", + ClusterName: cluster, }) require.Error(t, err) var retried networkingv1alpha.HTTPProxy @@ -514,7 +518,7 @@ func TestHTTPProxyReconcileInternalErrorGetsStableFixedMessage(t *testing.T) { assert.Equal(t, updated.ResourceVersion, retried.ResourceVersion, "a retry with the same failure must not rewrite status") httpProxyProgramming.mu.Lock() - _, pending := httpProxyProgramming.pending[httpProxyKey{cluster: "test-cluster", NamespacedName: client.ObjectKeyFromObject(httpProxy)}] + _, pending := httpProxyProgramming.pending[httpProxyKey{cluster: cluster, NamespacedName: client.ObjectKeyFromObject(httpProxy)}] httpProxyProgramming.mu.Unlock() assert.True(t, pending, "an unprogrammed generation is tracked for latency") }