Skip to content

Commit

Permalink
Fixed isScheduleEmpty function for flyte schedules (flyteorg#385)
Browse files Browse the repository at this point in the history
Signed-off-by: Prafulla Mahindrakar <[email protected]>
  • Loading branch information
pmahindrakar-oss authored Apr 5, 2022
1 parent 3204f7c commit 96d7276
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/manager/impl/launch_plan_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ func isScheduleEmpty(launchPlanSpec admin.LaunchPlanSpec) bool {
if schedule == nil {
return true
}
if schedule.GetCronSchedule() != nil && len(schedule.GetCronSchedule().Schedule) != 0 {
return false
}
if len(schedule.GetKickoffTimeInputArg()) != 0 {
return false
}
Expand Down
64 changes: 64 additions & 0 deletions pkg/manager/impl/launch_plan_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1346,3 +1346,67 @@ func TestLaunchPlanManager_ListActiveLaunchPlans_BadRequest(t *testing.T) {
assert.Error(t, err)
assert.Nil(t, lpList)
}

func TestIsScheduleEmpty(t *testing.T) {
t.Run("deprecated cron expression used", func(t *testing.T) {
sp := admin.LaunchPlanSpec{
EntityMetadata: &admin.LaunchPlanMetadata{
Schedule: &admin.Schedule{
ScheduleExpression: &admin.Schedule_CronExpression{},
},
},
}
assert.True(t, isScheduleEmpty(sp))
})
t.Run("deprecated cron expression used", func(t *testing.T) {
sp := admin.LaunchPlanSpec{
EntityMetadata: &admin.LaunchPlanMetadata{
Schedule: &admin.Schedule{
ScheduleExpression: &admin.Schedule_CronExpression{
CronExpression: "* * * * *",
},
},
},
}
assert.False(t, isScheduleEmpty(sp))
})
t.Run("fixed rate used", func(t *testing.T) {
sp := admin.LaunchPlanSpec{
EntityMetadata: &admin.LaunchPlanMetadata{
Schedule: &admin.Schedule{
ScheduleExpression: &admin.Schedule_Rate{
Rate: &admin.FixedRate{
Value: 10,
Unit: admin.FixedRateUnit_HOUR,
},
},
},
},
}
assert.False(t, isScheduleEmpty(sp))
})
t.Run("cron schedule used", func(t *testing.T) {
sp := admin.LaunchPlanSpec{
EntityMetadata: &admin.LaunchPlanMetadata{
Schedule: &admin.Schedule{
ScheduleExpression: &admin.Schedule_CronSchedule{
CronSchedule: &admin.CronSchedule{
Schedule: "* * * * *",
},
},
},
},
}
assert.False(t, isScheduleEmpty(sp))
})
t.Run("kick off time used", func(t *testing.T) {
sp := admin.LaunchPlanSpec{
EntityMetadata: &admin.LaunchPlanMetadata{
Schedule: &admin.Schedule{
KickoffTimeInputArg: "name",
},
},
}
assert.False(t, isScheduleEmpty(sp))
})
}

0 comments on commit 96d7276

Please sign in to comment.