Skip to content

Commit

Permalink
Merge branch 'main' into fix_contrib_tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Boten authored Jan 8, 2024
2 parents bb652de + fb3ed1b commit b4902aa
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .chloggen/addretrysetvalidation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ component: "exporterhelper"
# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: "Add RetrySettings validation function"

subtext: |
Validate that time.Duration, multiplier values in configretry are non-negative, and randomization_factor is between 0 and 1
# One or more tracking issues or pull requests related to the change
issues: [9089]
4 changes: 2 additions & 2 deletions config/configretry/backoff.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ func (bs *BackOffConfig) Validate() error {
if bs.RandomizationFactor < 0 || bs.RandomizationFactor > 1 {
return errors.New("'randomization_factor' must be within [0, 1]")
}
if bs.Multiplier <= 0 {
return errors.New("'multiplier' must be positive")
if bs.Multiplier < 0 {
return errors.New("'multiplier' must be non-negative")
}
if bs.MaxInterval < 0 {
return errors.New("'max_interval' must be non-negative")
Expand Down
9 changes: 8 additions & 1 deletion config/configretry/backoff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,17 @@ func TestInvalidRandomizationFactor(t *testing.T) {
func TestInvalidMultiplier(t *testing.T) {
cfg := NewDefaultBackOffConfig()
assert.NoError(t, cfg.Validate())
cfg.Multiplier = 0
cfg.Multiplier = -1
assert.Error(t, cfg.Validate())
}

func TestZeroMultiplierIsValid(t *testing.T) {
cfg := NewDefaultBackOffConfig()
assert.NoError(t, cfg.Validate())
cfg.Multiplier = 0
assert.NoError(t, cfg.Validate())
}

func TestInvalidMaxInterval(t *testing.T) {
cfg := NewDefaultBackOffConfig()
assert.NoError(t, cfg.Validate())
Expand Down
2 changes: 1 addition & 1 deletion internal/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/charithe/durationcheck v0.0.10 // indirect
github.com/chavacava/garif v0.1.0 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/curioswitch/go-reassign v0.2.0 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/daixiang0/gci v0.11.2 // indirect
Expand Down
3 changes: 2 additions & 1 deletion internal/tools/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b4902aa

Please sign in to comment.