Deflake the PodReplacementPolicyFeatureToggling Job integration test

This commit is contained in:
Michal Wozniak 2025-02-14 12:32:51 +01:00
parent 1d723e3849
commit 5d5ac1696f

View File

@ -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)