Atlas › Test

maximum_attempts_negative

Exact test identity: go.temporal.io/server/common/retrypolicy/TestValidateRetryPolicy/maximum_attempts_negative

Package
go.temporal.io/server/common/retrypolicy
Suite / test hierarchy
TestValidateRetryPolicy/maximum_attempts_negative
Test
maximum_attempts_negative
Introduced at
retry_policy.go ×1 Frontier kind: Joint frontier
Covered ranges
12
Covered lines
19
Covered files
2

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/common/retrypolicy/retry_policy.go 10 covered LOC · 8 ranges

Open complete file

57
58 // Validate validates a retry policy
59 > func Validate(policy *commonpb.RetryPolicy) error { retry_policy.go
60 > if policy == nil {
61 // nil policy is valid which means no retry
62 return nil
63 }
64
65 > if policy.GetMaximumAttempts() == 1 { retry_policy.go
66 // One maximum attempt effectively disable retries. Validating the
67 // rest of the arguments is pointless
68 return nil
69 }
70 > if err := timestamp.ValidateAndCapProtoDuration(policy.GetInitialInterval()); err != nil { retry_policy.go
71 return serviceerror.NewInvalidArgumentf("invalid InitialInterval set on retry policy: %v", err)
72 }
73 > if policy.GetBackoffCoefficient() < 1 { retry_policy.go
74 return serviceerror.NewInvalidArgument("BackoffCoefficient cannot be less than 1 on retry policy.")
75 }
76 > if err := timestamp.ValidateAndCapProtoDuration(policy.GetMaximumInterval()); err != nil { retry_policy.go
77 return serviceerror.NewInvalidArgumentf("invalid MaximumInterval set on retry policy: %v", err)
78 }
79 > if timestamp.DurationValue(policy.GetMaximumInterval()) > 0 && timestamp.DurationValue(policy.GetMaximumInterval()) < timestamp.DurationValue(policy.GetInitialInterval()) { retry_policy.go
80 return serviceerror.NewInvalidArgument("MaximumInterval cannot be less than InitialInterval on retry policy.")
81 }
82 > if policy.GetMaximumAttempts() < 0 { retry_policy.go
83 > return serviceerror.NewInvalidArgument("MaximumAttempts cannot be negative on retry policy.") retry_policy.go
84 > }
85
86 for _, nrt := range policy.NonRetryableErrorTypes {
go.temporal.io/server/common/primitives/timestamp/duration.go 9 covered LOC · 4 ranges

Open complete file

19 )
20
21 > func DurationValue(d *durationpb.Duration) time.Duration { duration.go
22 > if d == nil {
23 > return 0 duration.go
24 > }
25 return d.AsDuration()
26 }
65 // durationpb.CheckValid cannot be used directly because it will return an error for
66 // very large durations, but we are okay with truncating these.
67 > func ValidateAndCapProtoDuration(d *durationpb.Duration) error { duration.go
68 > if d == nil {
69 > // nil durations are converted to 0 value duration.go
70 > return nil
71 > }
72
73 if (d.GetSeconds() > 0 && d.GetNanos() < 0) || (d.GetSeconds() < 0 && d.GetNanos() > 0) {