Skip to content

Commit e093d4c

Browse files
committed
Undo lint change in sample_test.go to fix tests, ignore lint error
Okay to ignore as this only affects test code and we want to minimise production code change as much as possible
1 parent 4c3f064 commit e093d4c

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ issues:
6363
text: 'SA1019: "github.com/golang/protobuf/proto" is deprecated: Use the "google.golang.org/protobuf/proto" package instead.'
6464
- path: rpc/
6565
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'
66+
- path: metrics/sample_test.go
67+
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.'
6668
exclude:
6769
- 'SA1019: event.TypeMux is deprecated: use Feed'
6870
- 'SA1019: strings.Title is deprecated'

metrics/sample_test.go

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,7 @@ func TestExpDecaySampleRescale(t *testing.T) {
187187

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

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

212210
func TestUniformSample(t *testing.T) {
213-
//rand.Seed(1) // quorum: deprecated after go upgrade
214-
rand.New(rand.NewSource(1)) // quorum
211+
rand.Seed(1)
215212
s := NewUniformSample(100)
216213
for i := 0; i < 1000; i++ {
217214
s.Update(int64(i))
@@ -233,8 +230,7 @@ func TestUniformSample(t *testing.T) {
233230
}
234231

235232
func TestUniformSampleIncludesTail(t *testing.T) {
236-
//rand.Seed(1) // quorum: deprecated after go upgrade
237-
rand.New(rand.NewSource(1)) // quorum
233+
rand.Seed(1)
238234
s := NewUniformSample(100)
239235
max := 100
240236
for i := 0; i < max; i++ {
@@ -262,8 +258,7 @@ func TestUniformSampleSnapshot(t *testing.T) {
262258
}
263259

264260
func TestUniformSampleStatistics(t *testing.T) {
265-
//rand.Seed(1) // quorum: deprecated after go upgrade
266-
rand.New(rand.NewSource(1)) // quorum
261+
rand.Seed(1)
267262
s := NewUniformSample(100)
268263
for i := 1; i <= 10000; i++ {
269264
s.Update(int64(i))

0 commit comments

Comments
 (0)