mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-17 15:50:10 +00:00
cleanup: add new test cases for failed pod replacement policy instead of editing existing ones
This commit is contained in:
parent
f2b723a130
commit
bcf1c113f4
@ -1681,25 +1681,29 @@ func TestJobPodReplacementPolicy(t *testing.T) {
|
|||||||
}
|
}
|
||||||
cases := map[string]struct {
|
cases := map[string]struct {
|
||||||
podReplacementPolicyEnabled bool
|
podReplacementPolicyEnabled bool
|
||||||
failPodsInsteadOfDeletion bool
|
deletePods bool
|
||||||
|
failPods bool
|
||||||
wantTerminating *int32
|
wantTerminating *int32
|
||||||
wantFailed int
|
wantFailed int
|
||||||
wantActive int
|
wantActive int
|
||||||
jobSpec *batchv1.JobSpec
|
jobSpec *batchv1.JobSpec
|
||||||
}{
|
}{
|
||||||
"feature flag off, delete pods and verify no terminating status": {
|
"feature flag off, delete pods and verify no terminating status": {
|
||||||
|
deletePods: true,
|
||||||
jobSpec: jobSpecIndexedDefault,
|
jobSpec: jobSpecIndexedDefault,
|
||||||
wantActive: int(podCount),
|
wantActive: int(podCount),
|
||||||
wantFailed: int(podCount),
|
wantFailed: int(podCount),
|
||||||
},
|
},
|
||||||
"feature flag true, delete pods and verify terminating status": {
|
"feature flag true, delete pods and verify terminating status": {
|
||||||
podReplacementPolicyEnabled: true,
|
podReplacementPolicyEnabled: true,
|
||||||
|
deletePods: true,
|
||||||
jobSpec: jobSpecIndexedDefault,
|
jobSpec: jobSpecIndexedDefault,
|
||||||
wantTerminating: pointer.Int32(podCount),
|
wantTerminating: pointer.Int32(podCount),
|
||||||
wantFailed: int(podCount),
|
wantFailed: int(podCount),
|
||||||
},
|
},
|
||||||
"feature flag true, delete pods, verify terminating status and recreate upon terminating": {
|
"feature flag true, delete pods, verify terminating status and recreate upon terminating": {
|
||||||
podReplacementPolicyEnabled: true,
|
podReplacementPolicyEnabled: true,
|
||||||
|
deletePods: true,
|
||||||
jobSpec: &batchv1.JobSpec{
|
jobSpec: &batchv1.JobSpec{
|
||||||
Parallelism: pointer.Int32Ptr(podCount),
|
Parallelism: pointer.Int32Ptr(podCount),
|
||||||
Completions: pointer.Int32Ptr(podCount),
|
Completions: pointer.Int32Ptr(podCount),
|
||||||
@ -1711,32 +1715,29 @@ func TestJobPodReplacementPolicy(t *testing.T) {
|
|||||||
},
|
},
|
||||||
"feature flag true, delete pods, verify terminating status and recreate once failed": {
|
"feature flag true, delete pods, verify terminating status and recreate once failed": {
|
||||||
podReplacementPolicyEnabled: true,
|
podReplacementPolicyEnabled: true,
|
||||||
|
deletePods: true,
|
||||||
jobSpec: &batchv1.JobSpec{
|
jobSpec: &batchv1.JobSpec{
|
||||||
Parallelism: pointer.Int32Ptr(podCount),
|
Parallelism: pointer.Int32Ptr(podCount),
|
||||||
Completions: pointer.Int32Ptr(podCount),
|
Completions: pointer.Int32Ptr(podCount),
|
||||||
CompletionMode: &nonIndexedCompletion,
|
CompletionMode: &nonIndexedCompletion,
|
||||||
PodReplacementPolicy: podReplacementPolicy(batchv1.Failed),
|
PodReplacementPolicy: podReplacementPolicy(batchv1.Failed),
|
||||||
},
|
},
|
||||||
failPodsInsteadOfDeletion: true,
|
wantTerminating: pointer.Int32(podCount),
|
||||||
wantActive: int(podCount),
|
|
||||||
wantFailed: int(podCount),
|
|
||||||
wantTerminating: pointer.Int32(0),
|
|
||||||
},
|
},
|
||||||
"feature flag true with NonIndexedJob, delete pods, verify terminating status and recreate once failed": {
|
"feature flag true with NonIndexedJob, delete pods, verify terminating status and recreate once failed": {
|
||||||
podReplacementPolicyEnabled: true,
|
podReplacementPolicyEnabled: true,
|
||||||
|
deletePods: true,
|
||||||
jobSpec: &batchv1.JobSpec{
|
jobSpec: &batchv1.JobSpec{
|
||||||
Parallelism: pointer.Int32Ptr(podCount),
|
Parallelism: pointer.Int32Ptr(podCount),
|
||||||
Completions: pointer.Int32Ptr(podCount),
|
Completions: pointer.Int32Ptr(podCount),
|
||||||
CompletionMode: &nonIndexedCompletion,
|
CompletionMode: &nonIndexedCompletion,
|
||||||
PodReplacementPolicy: podReplacementPolicy(batchv1.Failed),
|
PodReplacementPolicy: podReplacementPolicy(batchv1.Failed),
|
||||||
},
|
},
|
||||||
failPodsInsteadOfDeletion: true,
|
wantTerminating: pointer.Int32(podCount),
|
||||||
wantActive: int(podCount),
|
|
||||||
wantFailed: int(podCount),
|
|
||||||
wantTerminating: pointer.Int32(0),
|
|
||||||
},
|
},
|
||||||
"feature flag false, podFailurePolicy enabled, delete pods, verify terminating status and recreate once failed": {
|
"feature flag false, podFailurePolicy enabled, delete pods, verify terminating status and recreate once failed": {
|
||||||
podReplacementPolicyEnabled: false,
|
podReplacementPolicyEnabled: false,
|
||||||
|
deletePods: true,
|
||||||
jobSpec: &batchv1.JobSpec{
|
jobSpec: &batchv1.JobSpec{
|
||||||
Parallelism: pointer.Int32Ptr(podCount),
|
Parallelism: pointer.Int32Ptr(podCount),
|
||||||
Completions: pointer.Int32Ptr(podCount),
|
Completions: pointer.Int32Ptr(podCount),
|
||||||
@ -1756,6 +1757,32 @@ func TestJobPodReplacementPolicy(t *testing.T) {
|
|||||||
},
|
},
|
||||||
wantActive: int(podCount),
|
wantActive: int(podCount),
|
||||||
},
|
},
|
||||||
|
"feature flag true, delete pods, verify active and failed status and recreate once failed": {
|
||||||
|
podReplacementPolicyEnabled: true,
|
||||||
|
failPods: true,
|
||||||
|
jobSpec: &batchv1.JobSpec{
|
||||||
|
Parallelism: pointer.Int32Ptr(podCount),
|
||||||
|
Completions: pointer.Int32Ptr(podCount),
|
||||||
|
CompletionMode: &nonIndexedCompletion,
|
||||||
|
PodReplacementPolicy: podReplacementPolicy(batchv1.Failed),
|
||||||
|
},
|
||||||
|
wantActive: int(podCount),
|
||||||
|
wantFailed: int(podCount),
|
||||||
|
wantTerminating: pointer.Int32(0),
|
||||||
|
},
|
||||||
|
"feature flag true with NonIndexedJob, delete pods, verify active and failed status and recreate once failed": {
|
||||||
|
podReplacementPolicyEnabled: true,
|
||||||
|
failPods: true,
|
||||||
|
jobSpec: &batchv1.JobSpec{
|
||||||
|
Parallelism: pointer.Int32Ptr(podCount),
|
||||||
|
Completions: pointer.Int32Ptr(podCount),
|
||||||
|
CompletionMode: &nonIndexedCompletion,
|
||||||
|
PodReplacementPolicy: podReplacementPolicy(batchv1.Failed),
|
||||||
|
},
|
||||||
|
wantActive: int(podCount),
|
||||||
|
wantFailed: int(podCount),
|
||||||
|
wantTerminating: pointer.Int32(0),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for name, tc := range cases {
|
for name, tc := range cases {
|
||||||
tc := tc
|
tc := tc
|
||||||
@ -1791,13 +1818,14 @@ func TestJobPodReplacementPolicy(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Error waiting for Job pods to become active: %v", err)
|
t.Fatalf("Error waiting for Job pods to become active: %v", err)
|
||||||
}
|
}
|
||||||
if tc.failPodsInsteadOfDeletion {
|
if tc.deletePods {
|
||||||
|
addFinalizerAndDeletePods(ctx, t, clientSet, ns.Name)
|
||||||
|
}
|
||||||
|
if tc.failPods {
|
||||||
err, _ = setJobPodsPhase(ctx, clientSet, jobObj, v1.PodFailed, int(podCount))
|
err, _ = setJobPodsPhase(ctx, clientSet, jobObj, v1.PodFailed, int(podCount))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("Failed setting phase %s on Job Pods: %v", v1.PodFailed, err)
|
t.Fatalf("Failed setting phase %s on Job Pods: %v", v1.PodFailed, err)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
addFinalizerAndDeletePods(ctx, t, clientSet, ns.Name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
validateJobsPodsStatusOnly(ctx, t, clientSet, jobObj, podsByStatus{
|
validateJobsPodsStatusOnly(ctx, t, clientSet, jobObj, podsByStatus{
|
||||||
|
Loading…
Reference in New Issue
Block a user