From b638b0941617cbe8f0cc0dc4a5e21d768cbbab35 Mon Sep 17 00:00:00 2001 From: Omer Aplatony Date: Mon, 20 Apr 2026 06:14:01 +0000 Subject: [PATCH] fix filename typo and switch to DeferCleanup Signed-off-by: Omer Aplatony --- ...horizontal_pod_autoscaling_external_metrics.go} | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) rename test/e2e/autoscaling/{horizontal_pod_autosclaing_external_metrics.go => horizontal_pod_autoscaling_external_metrics.go} (94%) diff --git a/test/e2e/autoscaling/horizontal_pod_autosclaing_external_metrics.go b/test/e2e/autoscaling/horizontal_pod_autoscaling_external_metrics.go similarity index 94% rename from test/e2e/autoscaling/horizontal_pod_autosclaing_external_metrics.go rename to test/e2e/autoscaling/horizontal_pod_autoscaling_external_metrics.go index bb7188ce769..330b650221c 100644 --- a/test/e2e/autoscaling/horizontal_pod_autosclaing_external_metrics.go +++ b/test/e2e/autoscaling/horizontal_pod_autoscaling_external_metrics.go @@ -47,11 +47,7 @@ var _ = SIGDescribe(feature.HPA, "Horizontal pod autoscaling (external metrics)" ginkgo.BeforeEach(func(ctx context.Context) { ginkgo.By("Setting up the external metrics server") metricsController = e2eautoscaling.RunExternalMetricsServer(ctx, f.ClientSet, f.Namespace.Name, "external-metrics-server", nil) - }) - ginkgo.AfterEach(func(ctx context.Context) { - if metricsController != nil { - e2eautoscaling.CleanupExternalMetricsServer(ctx, f.ClientSet, f.Namespace.Name, "external-metrics-server") - } + ginkgo.DeferCleanup(e2eautoscaling.CleanupExternalMetricsServer, f.ClientSet, f.Namespace.Name, "external-metrics-server") }) ginkgo.It("should scale up and down based on external metric value", func(ctx context.Context) { @@ -76,6 +72,7 @@ var _ = SIGDescribe(feature.HPA, "Horizontal pod autoscaling (external metrics)" } // since queue_messages_ready default is 100 this will cause the HPA to scale out till max replicas hpa := e2eautoscaling.CreateExternalHorizontalPodAutoscalerWithBehavior(ctx, rc, metricName, nil, v2.ValueMetricType, 50, int32(initPods), 3, behavior) + ginkgo.DeferCleanup(e2eautoscaling.DeleteHorizontalPodAutoscaler, rc, hpa.Name) ginkgo.By("Waiting for HPA to scale up to max replicas") rc.WaitForReplicas(ctx, int(hpa.Spec.MaxReplicas), maxResourceConsumerDelay+waitBuffer) @@ -86,7 +83,6 @@ var _ = SIGDescribe(feature.HPA, "Horizontal pod autoscaling (external metrics)" ginkgo.By("Waiting for HPA to scale down to min replicas") rc.WaitForReplicas(ctx, int(*hpa.Spec.MinReplicas), maxResourceConsumerDelay+waitBuffer) - ginkgo.DeferCleanup(e2eautoscaling.DeleteHorizontalPodAutoscaler, rc, hpa.Name) }) }) @@ -106,11 +102,7 @@ var _ = SIGDescribe(feature.HPA, framework.WithFeatureGate(features.HPAScaleToZe ginkgo.BeforeEach(func(ctx context.Context) { ginkgo.By("Setting up the external metrics server") metricsController = e2eautoscaling.RunExternalMetricsServer(ctx, f.ClientSet, f.Namespace.Name, "external-metrics-server", nil) - }) - ginkgo.AfterEach(func(ctx context.Context) { - if metricsController != nil { - e2eautoscaling.CleanupExternalMetricsServer(ctx, f.ClientSet, f.Namespace.Name, "external-metrics-server") - } + ginkgo.DeferCleanup(e2eautoscaling.CleanupExternalMetricsServer, f.ClientSet, f.Namespace.Name, "external-metrics-server") }) ginkgo.It("should scale down to zero and back up based on external metric value", func(ctx context.Context) {