mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-14 06:15:45 +00:00
Add unit test for Job Controller for panic when PodFailurePolicy is used on 1.28
This commit is contained in:
parent
0c645922ed
commit
34bc590418
@ -256,6 +256,7 @@ func TestControllerSyncJob(t *testing.T) {
|
||||
wasSuspended bool
|
||||
suspend bool
|
||||
podReplacementPolicy *batch.PodReplacementPolicy
|
||||
podFailurePolicy *batch.PodFailurePolicy
|
||||
initialStatus *jobInitialStatus
|
||||
backoffRecord *backoffRecord
|
||||
controllerTime *time.Time
|
||||
@ -293,6 +294,7 @@ func TestControllerSyncJob(t *testing.T) {
|
||||
// features
|
||||
podIndexLabelDisabled bool
|
||||
jobPodReplacementPolicy bool
|
||||
jobPodFailurePolicy bool
|
||||
}{
|
||||
"job start": {
|
||||
parallelism: 2,
|
||||
@ -407,6 +409,22 @@ func TestControllerSyncJob(t *testing.T) {
|
||||
expectedDeletions: 1,
|
||||
expectedPodPatches: 1,
|
||||
},
|
||||
"more terminating pods than parallelism; PodFailurePolicy used": {
|
||||
// Repro for https://github.com/kubernetes/kubernetes/issues/122235
|
||||
parallelism: 1,
|
||||
completions: 1,
|
||||
backoffLimit: 6,
|
||||
activePods: 2,
|
||||
failedPods: 0,
|
||||
terminatingPods: 4,
|
||||
jobPodFailurePolicy: true,
|
||||
podFailurePolicy: &batch.PodFailurePolicy{},
|
||||
expectedTerminating: nil,
|
||||
expectedReady: ptr.To[int32](0),
|
||||
expectedActive: 1,
|
||||
expectedDeletions: 1,
|
||||
expectedPodPatches: 1,
|
||||
},
|
||||
"too few active pods and active back-off": {
|
||||
parallelism: 1,
|
||||
completions: 1,
|
||||
@ -935,6 +953,7 @@ func TestControllerSyncJob(t *testing.T) {
|
||||
logger, _ := ktesting.NewTestContext(t)
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.PodIndexLabel, !tc.podIndexLabelDisabled)()
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodReplacementPolicy, tc.jobPodReplacementPolicy)()
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodFailurePolicy, tc.jobPodFailurePolicy)()
|
||||
// job manager setup
|
||||
clientSet := clientset.NewForConfigOrDie(&restclient.Config{Host: "", ContentConfig: restclient.ContentConfig{GroupVersion: &schema.GroupVersion{Group: "", Version: "v1"}}})
|
||||
|
||||
@ -957,6 +976,9 @@ func TestControllerSyncJob(t *testing.T) {
|
||||
if tc.jobPodReplacementPolicy {
|
||||
job.Spec.PodReplacementPolicy = tc.podReplacementPolicy
|
||||
}
|
||||
if tc.jobPodFailurePolicy {
|
||||
job.Spec.PodFailurePolicy = tc.podFailurePolicy
|
||||
}
|
||||
if tc.initialStatus != nil {
|
||||
startTime := metav1.Now()
|
||||
job.Status.StartTime = &startTime
|
||||
|
Loading…
Reference in New Issue
Block a user