From 5d5ac1696f9e37df7d8695b8986d8579c657c7a8 Mon Sep 17 00:00:00 2001 From: Michal Wozniak Date: Fri, 14 Feb 2025 12:32:51 +0100 Subject: [PATCH] Deflake the PodReplacementPolicyFeatureToggling Job integration test --- test/integration/job/job_test.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/integration/job/job_test.go b/test/integration/job/job_test.go index efe03e0fdd6..e2f776668e0 100644 --- a/test/integration/job/job_test.go +++ b/test/integration/job/job_test.go @@ -3117,9 +3117,15 @@ func TestJobPodReplacementPolicyFeatureToggling(t *testing.T) { Ready: ptr.To[int32](0), Active: int(podCount), }) - // Disable the controller and turn feature on again. - featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodReplacementPolicy, true) cancel() + // Disable the controller and turn feature on again. + // However, before we re-enabling the feature gate we wait a little (1s to + // wait for the syncJob re-queue after update + 100ms for the syncJob + // execution itself) to make sure there is no pending syncJob which could + // panic if the trackTerminating returned false at the start of the sync, + // but onlyReplaceFailedPods returned true during that sync. + time.Sleep(time.Second + sleepDurationForControllerLatency) + featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodReplacementPolicy, true) ctx, cancel = startJobControllerAndWaitForCaches(t, restConfig) waitForPodsToBeActive(ctx, t, jobClient, 2, jobObj) deletePods(ctx, t, clientSet, jobObj.Namespace)