diff --git a/client_test.go b/client_test.go index ab3002dd..1c089af5 100644 --- a/client_test.go +++ b/client_test.go @@ -5652,6 +5652,9 @@ func Test_Client_JobCompletion(t *testing.T) { }) config.RetryPolicy = &retrypolicytest.RetryPolicyNoJitter{} + retryPolicy := &retrypolicytest.RetryPolicySlow{} // make sure job isn't set back to available/running by the time we check it below + config.RetryPolicy = retryPolicy + client, bundle := setup(t, config) now := client.baseService.Time.StubNowUTC(time.Now().UTC()) @@ -5667,7 +5670,7 @@ func Test_Client_JobCompletion(t *testing.T) { require.NoError(err) require.Equal(rivertype.JobStateRetryable, reloadedJob.State) - require.WithinDuration(now.Add(1*time.Second), reloadedJob.ScheduledAt, time.Microsecond) + require.WithinDuration(now.Add(retryPolicy.Interval()), reloadedJob.ScheduledAt, time.Microsecond) require.Nil(reloadedJob.FinalizedAt) }) diff --git a/internal/riverinternaltest/retrypolicytest/retrypolicytest.go b/internal/riverinternaltest/retrypolicytest/retrypolicytest.go index bb150234..7b761223 100644 --- a/internal/riverinternaltest/retrypolicytest/retrypolicytest.go +++ b/internal/riverinternaltest/retrypolicytest/retrypolicytest.go @@ -58,3 +58,23 @@ func (p *RetryPolicyNoJitter) retrySecondsWithoutJitter(attempt int) float64 { retrySeconds := math.Pow(float64(attempt), 4) return min(retrySeconds, maxDurationSeconds) } + +const retryPolicySlowInterval = 1 * time.Hour + +// RetryPolicySlow is a retry policy that has a very slow retry interval. This +// is used in tests that check retries to make sure that in slower environments +// (like GitHub Actions), jobs aren't accidentally set back to available or +// running before a paused test case can check to make sure it's in a retryable +// state. +type RetryPolicySlow struct{} + +// Interval is the slow retry interval exposed for use in test case assertions. +// Unlike the standard retry policy, RetryPolicySlow's interval is constant +// regardless of which attempt number the job was on. +func (p *RetryPolicySlow) Interval() time.Duration { + return retryPolicySlowInterval +} + +func (p *RetryPolicySlow) NextRetry(job *rivertype.JobRow) time.Time { + return job.AttemptedAt.Add(retryPolicySlowInterval) +}