Skip to content

Commit a08b4df

Browse files
authored
chore: Remove deprecated rand.Seed() calls (#16824)
1 parent ef4f7c4 commit a08b4df

5 files changed

Lines changed: 4 additions & 18 deletions

File tree

‎central/processindicator/pruner/pruner_test.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ func processToIDAndArgs(process *storage.ProcessIndicator) processindicator.IDAn
6464
}
6565

6666
func TestRabbitMQPruning(t *testing.T) {
67-
rand.Seed(time.Now().UnixNano())
6867
var processes []processindicator.IDAndArgs
6968
processes = append(processes, processToIDAndArgs(deterministicRabbitMQProcess))
7069
for i := 0; i < 1000; i++ {

‎compliance/compliance.go‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package compliance
22

33
import (
44
"context"
5-
"math/rand"
65
"os"
76
"os/signal"
87
"syscall"
@@ -61,9 +60,6 @@ func (c *Compliance) Start() {
6160
log.Infof("Running StackRox Version: %s", version.GetMainVersion())
6261
clientconn.SetUserAgent(clientconn.Compliance)
6362

64-
// Set the random seed based on the current time.
65-
rand.Seed(time.Now().UnixNano())
66-
6763
// Start the prometheus metrics server
6864
metrics.NewServer(metrics.ComplianceSubsystem, metrics.NewTLSConfigurerFromEnv()).RunForever()
6965
metrics.GatherThrottleMetricsForever(metrics.ComplianceSubsystem.String())

‎migrator/clone/clone_test.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ func doTestCloneMigrationFailureAndReentry(t *testing.T) {
156156
},
157157
}
158158
// For the parameters that should not matter, run pseudo random to get coverage on different cases
159-
rand.Seed(8181818)
159+
r := rand.New(rand.NewSource(8181818))
160160
for _, c := range testCases {
161-
reboot := rand.Intn(2) == 1
161+
reboot := r.Intn(2) == 1
162162
if reboot {
163163
c.description = c.description + " with reboot"
164164
}
@@ -436,9 +436,9 @@ func doTestRollback(t *testing.T) {
436436
breakPoint: breakAfterGetClone,
437437
},
438438
}
439-
rand.Seed(8056)
439+
r := rand.New(rand.NewSource(8056))
440440
for _, c := range testCases {
441-
reboot := rand.Intn(2) == 1
441+
reboot := r.Intn(2) == 1
442442
if reboot {
443443
c.description = c.description + " with reboot"
444444
}

‎sensor/kubernetes/listener/resources/deployment_store_bench_test.go‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55
"math/rand"
66
"testing"
7-
"time"
87

98
"github.com/stackrox/rox/generated/storage"
109
"github.com/stackrox/rox/sensor/common/selector"
@@ -26,11 +25,6 @@ type namespaceAndSelector struct {
2625
selector selector.Selector
2726
}
2827

29-
func init() {
30-
rand.Seed(time.Now().UnixNano())
31-
32-
}
33-
3428
// BenchmarkBuildDeployments_NoChange uses one deployment and generates
3529
// 10k updates without meaningful change. This is to test that
3630
// we don't do useless clones if the object is the same.

‎sensor/tests/pipeline/bench_test.go‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"math/rand"
66
"net"
77
"testing"
8-
"time"
98

109
"github.com/stackrox/rox/generated/internalapi/central"
1110
"github.com/stackrox/rox/generated/storage"
@@ -40,8 +39,6 @@ var (
4039
)
4140

4241
func init() {
43-
rand.Seed(time.Now().UnixNano())
44-
4542
serviceAccounts = make([]string, 1000)
4643
for i := 0; i < 1000; i++ {
4744
serviceAccounts[i] = randString(5)

0 commit comments

Comments
 (0)