Skip to content

Commit

Permalink
Verify unbounded inputs for all scheduled launch plan types (#4867)
Browse files Browse the repository at this point in the history
Signed-off-by: Katrina Rogan <[email protected]>
  • Loading branch information
katrogan committed Feb 20, 2024
1 parent 53561ac commit acb5d2d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func ValidateLaunchPlan(ctx context.Context,

func validateSchedule(request admin.LaunchPlanCreateRequest, expectedInputs *core.ParameterMap) error {
schedule := request.GetSpec().GetEntityMetadata().GetSchedule()
if schedule.GetCronExpression() != "" || schedule.GetRate() != nil {
if schedule.GetCronExpression() != "" || schedule.GetRate() != nil || schedule.GetCronSchedule() != nil {
for key, value := range expectedInputs.Parameters {
if value.GetRequired() && key != schedule.GetKickoffTimeInputArg() {
return errors.NewFlyteAdminErrorf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ func TestValidateSchedule_NoSchedule(t *testing.T) {
}

func TestValidateSchedule_ArgNotFixed(t *testing.T) {
request := testutils.GetLaunchPlanRequestWithDeprecatedCronSchedule("* * * * * *")
inputMap := &core.ParameterMap{
Parameters: map[string]*core.Parameter{
"foo": {
Expand All @@ -310,9 +309,24 @@ func TestValidateSchedule_ArgNotFixed(t *testing.T) {
},
},
}

err := validateSchedule(request, inputMap)
assert.NotNil(t, err)
t.Run("with deprecated cron expression", func(t *testing.T) {
request := testutils.GetLaunchPlanRequestWithDeprecatedCronSchedule("* * * * * *")

err := validateSchedule(request, inputMap)
assert.NotNil(t, err)
})
t.Run("with rate", func(t *testing.T) {
request := testutils.GetLaunchPlanRequestWithFixedRateSchedule(2, admin.FixedRateUnit_HOUR)

err := validateSchedule(request, inputMap)
assert.NotNil(t, err)
})
t.Run("with cron schedule", func(t *testing.T) {
request := testutils.GetLaunchPlanRequestWithCronSchedule("* * * * * *")

err := validateSchedule(request, inputMap)
assert.NotNil(t, err)
})
}

func TestValidateSchedule_KickoffTimeArgDoesNotExist(t *testing.T) {
Expand Down

0 comments on commit acb5d2d

Please sign in to comment.