diff --git a/nomad/structs/structs_test.go b/nomad/structs/structs_test.go index cdf4c091b..e7d0fb0f5 100644 --- a/nomad/structs/structs_test.go +++ b/nomad/structs/structs_test.go @@ -2429,16 +2429,28 @@ func TestReschedulePolicy_Validate(t *testing.T) { testCases := []testCase{ { - ReschedulePolicy: &ReschedulePolicy{1, 5 * time.Minute}, - err: nil, + ReschedulePolicy: &ReschedulePolicy{ + Attempts: 0, + Interval: 0 * time.Second}, + err: nil, }, { - ReschedulePolicy: &ReschedulePolicy{-1, 5 * time.Minute}, - err: nil, + ReschedulePolicy: &ReschedulePolicy{ + Attempts: 1, + Interval: 5 * time.Minute}, + err: nil, }, { - ReschedulePolicy: &ReschedulePolicy{1, 1 * time.Second}, - err: fmt.Errorf("Interval cannot be less than %v (got %v)", RestartPolicyMinInterval, time.Second), + ReschedulePolicy: &ReschedulePolicy{ + Attempts: -1, + Interval: 5 * time.Minute}, + err: nil, + }, + { + ReschedulePolicy: &ReschedulePolicy{ + Attempts: 1, + Interval: 1 * time.Second}, + err: fmt.Errorf("Interval cannot be less than %v (got %v)", RestartPolicyMinInterval, time.Second), }, } @@ -2701,6 +2713,14 @@ func TestAllocation_ShouldReschedule(t *testing.T) { ReschedulePolicy: nil, ShouldReschedule: false, }, + { + Desc: "Disabled recheduling", + ClientStatus: AllocClientStatusFailed, + DesiredStatus: AllocDesiredStatusRun, + FailTime: fail, + ReschedulePolicy: &ReschedulePolicy{0, 1 * time.Minute}, + ShouldReschedule: false, + }, { Desc: "Reschedule when client status is complete", ClientStatus: AllocClientStatusComplete,