Skip to content

Commit

Permalink
Undo lint change in sample_test.go to fix tests, ignore lint error
Browse files Browse the repository at this point in the history
Okay to ignore as this only affects test code and we want to minimise production code change as much as possible
  • Loading branch information
chris-j-h committed May 3, 2024
1 parent 4c3f064 commit e093d4c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ issues:
text: 'SA1019: "github.com/golang/protobuf/proto" is deprecated: Use the "google.golang.org/protobuf/proto" package instead.'
- path: rpc/
text: 'SA1019: "github.com/golang/protobuf/ptypes" is deprecated: Well-known types have specialized functionality directly injected into the generated packages for each message type. See the deprecation notice for each function for the suggested alternative'
- path: metrics/sample_test.go
text: 'SA1019: rand.Seed has been deprecated since Go 1.20 and an alternative has been available since Go 1.0: As of Go 1.20 there is no reason to call Seed with a random value. Programs that call Seed with a known value to get a specific sequence of results should use New.NewSource.seed.. to obtain a local random generator.'
exclude:
- 'SA1019: event.TypeMux is deprecated: use Feed'
- 'SA1019: strings.Title is deprecated'
Expand Down
15 changes: 5 additions & 10 deletions metrics/sample_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,7 @@ func TestExpDecaySampleRescale(t *testing.T) {

func TestExpDecaySampleSnapshot(t *testing.T) {
now := time.Now()
//rand.Seed(1) // quorum: deprecated after go upgrade
rand.New(rand.NewSource(1)) // quorum
rand.Seed(1)
s := NewExpDecaySample(100, 0.99)
for i := 1; i <= 10000; i++ {
s.(*ExpDecaySample).update(now.Add(time.Duration(i)), int64(i))
Expand All @@ -200,8 +199,7 @@ func TestExpDecaySampleSnapshot(t *testing.T) {

func TestExpDecaySampleStatistics(t *testing.T) {
now := time.Now()
//rand.Seed(1) // quorum: deprecated after go upgrade
rand.New(rand.NewSource(1)) // quorum
rand.Seed(1)
s := NewExpDecaySample(100, 0.99)
for i := 1; i <= 10000; i++ {
s.(*ExpDecaySample).update(now.Add(time.Duration(i)), int64(i))
Expand All @@ -210,8 +208,7 @@ func TestExpDecaySampleStatistics(t *testing.T) {
}

func TestUniformSample(t *testing.T) {
//rand.Seed(1) // quorum: deprecated after go upgrade
rand.New(rand.NewSource(1)) // quorum
rand.Seed(1)
s := NewUniformSample(100)
for i := 0; i < 1000; i++ {
s.Update(int64(i))
Expand All @@ -233,8 +230,7 @@ func TestUniformSample(t *testing.T) {
}

func TestUniformSampleIncludesTail(t *testing.T) {
//rand.Seed(1) // quorum: deprecated after go upgrade
rand.New(rand.NewSource(1)) // quorum
rand.Seed(1)
s := NewUniformSample(100)
max := 100
for i := 0; i < max; i++ {
Expand Down Expand Up @@ -262,8 +258,7 @@ func TestUniformSampleSnapshot(t *testing.T) {
}

func TestUniformSampleStatistics(t *testing.T) {
//rand.Seed(1) // quorum: deprecated after go upgrade
rand.New(rand.NewSource(1)) // quorum
rand.Seed(1)
s := NewUniformSample(100)
for i := 1; i <= 10000; i++ {
s.Update(int64(i))
Expand Down

0 comments on commit e093d4c

Please sign in to comment.