CronJob: cleanup legacy ScheduledJob vars,docs

Signed-off-by: Zhou Peng <p@ctriple.cn>
This commit is contained in:
Zhou Peng
2020-05-10 00:45:21 +08:00
parent c1fe194e06
commit b33e202397
7 changed files with 208 additions and 209 deletions

View File

@@ -42,7 +42,7 @@ func TestCronJobStrategy(t *testing.T) {
Containers: []api.Container{{Name: "abc", Image: "image", ImagePullPolicy: "IfNotPresent", TerminationMessagePolicy: api.TerminationMessageReadFile}},
},
}
scheduledJob := &batch.CronJob{
cronJob := &batch.CronJob{
ObjectMeta: metav1.ObjectMeta{
Name: "mycronjob",
Namespace: metav1.NamespaceDefault,
@@ -58,11 +58,11 @@ func TestCronJobStrategy(t *testing.T) {
},
}
Strategy.PrepareForCreate(ctx, scheduledJob)
if len(scheduledJob.Status.Active) != 0 {
Strategy.PrepareForCreate(ctx, cronJob)
if len(cronJob.Status.Active) != 0 {
t.Errorf("CronJob does not allow setting status on create")
}
errs := Strategy.Validate(ctx, scheduledJob)
errs := Strategy.Validate(ctx, cronJob)
if len(errs) != 0 {
t.Errorf("Unexpected error validating %v", errs)
}
@@ -78,11 +78,11 @@ func TestCronJobStrategy(t *testing.T) {
}
// ensure we do not change status
Strategy.PrepareForUpdate(ctx, updatedCronJob, scheduledJob)
Strategy.PrepareForUpdate(ctx, updatedCronJob, cronJob)
if updatedCronJob.Status.Active != nil {
t.Errorf("PrepareForUpdate should have preserved prior version status")
}
errs = Strategy.ValidateUpdate(ctx, updatedCronJob, scheduledJob)
errs = Strategy.ValidateUpdate(ctx, updatedCronJob, cronJob)
if len(errs) == 0 {
t.Errorf("Expected a validation error")
}
@@ -165,10 +165,10 @@ func TestCronJobStatusStrategy(t *testing.T) {
StatusStrategy.PrepareForUpdate(ctx, newCronJob, oldCronJob)
if newCronJob.Status.LastScheduleTime == nil {
t.Errorf("CronJob status updates must allow changes to scheduledJob status")
t.Errorf("CronJob status updates must allow changes to cronJob status")
}
if newCronJob.Spec.Schedule != oldSchedule {
t.Errorf("CronJob status updates must now allow changes to scheduledJob spec")
t.Errorf("CronJob status updates must now allow changes to cronJob spec")
}
errs := StatusStrategy.ValidateUpdate(ctx, newCronJob, oldCronJob)
if len(errs) != 0 {