Skip to content

Commit fcbc778

Browse files
committed
remove deprecated rand.Seed() calls
the generator is seeded randomly at program startup
1 parent 13543cb commit fcbc778

File tree

10 files changed

+0
-21
lines changed

10 files changed

+0
-21
lines changed

cmd/pbm-speed-test/main.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"fmt"
66
stdlog "log"
7-
"math/rand"
87
"os"
98
"time"
109

@@ -62,8 +61,6 @@ func main() {
6261
*sampleSizeF = 1
6362
}
6463

65-
rand.Seed(time.Now().UnixNano())
66-
6764
switch cmd {
6865
case compressionCmd.FullCommand():
6966
fmt.Print("Test started ")

e2e-tests/cmd/pbm-test/main.go

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

33
import (
44
"log"
5-
"math/rand"
65
"os"
7-
"time"
86

97
"github.com/percona/percona-backup-mongodb/e2e-tests/pkg/tests/sharded"
108
)
@@ -46,8 +44,6 @@ func main() {
4644
}
4745
log.Println("Backup Type:", bcpT)
4846

49-
rand.Seed(time.Now().UnixNano())
50-
5147
typ := testTyp(os.Getenv("TESTS_TYPE"))
5248
switch typ {
5349
case testsUnknown, testsSharded:

e2e-tests/cmd/pbm-test/run.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"log"
77
"math/rand"
88
"os"
9-
"time"
109

1110
"golang.org/x/mod/semver"
1211

@@ -31,7 +30,6 @@ func run(t *sharded.Cluster, typ testTyp) {
3130
{"FS", "/etc/pbm/fs.yaml"},
3231
}
3332

34-
rand.Seed(time.Now().UnixNano())
3533
rand.Shuffle(len(remoteStg), func(i, j int) {
3634
remoteStg[i], remoteStg[j] = remoteStg[j], remoteStg[i]
3735
})

e2e-tests/cmd/pbm-test/run_physical.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package main
33
import (
44
"context"
55
"math/rand"
6-
"time"
76

87
"github.com/percona/percona-backup-mongodb/e2e-tests/pkg/tests/sharded"
98
"github.com/percona/percona-backup-mongodb/pbm/defs"
@@ -22,7 +21,6 @@ func runPhysical(t *sharded.Cluster, typ testTyp) {
2221
{"FS", "/etc/pbm/fs.yaml"},
2322
}
2423

25-
rand.Seed(time.Now().UnixNano())
2624
rand.Shuffle(len(remoteStg), func(i, j int) {
2725
remoteStg[i], remoteStg[j] = remoteStg[j], remoteStg[i]
2826
})

e2e-tests/pkg/tests/sharded/backuper.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ func NewPitr(c *Cluster) *Pitr {
6666
}
6767

6868
func (p *Pitr) Backup() {
69-
rand.Seed(time.Now().UnixNano())
70-
7169
bcpName := p.c.LogicalBackup()
7270
p.started <- struct{}{}
7371
p.c.pitrOn()

e2e-tests/pkg/tests/sharded/test_bounds_check.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ func (c *Cluster) BackupBoundsCheck(typ defs.BackupType, mongoVersion string) {
4343
}
4444
}
4545

46-
rand.Seed(time.Now().UnixNano())
4746
counters := make(map[string]scounter)
4847
for name, shard := range c.shards {
4948
c.bcheckClear(name, shard)

e2e-tests/pkg/tests/sharded/test_incremental_backup.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ func (c *Cluster) IncrementalBackup(mongoVersion string) {
2121
inRange = lt
2222
}
2323

24-
rand.Seed(time.Now().UnixNano())
2524
counters := make(map[string]scounter)
2625
for name, shard := range c.shards {
2726
c.bcheckClear(name, shard)

e2e-tests/pkg/tests/sharded/test_oplog_replay.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ func (c *Cluster) OplogReplay() {
1818
log.Println("turn on PITR")
1919
defer c.pitrOff()
2020

21-
rand.Seed(time.Now().UnixNano())
22-
2321
counters := make(map[string]shardCounter)
2422
for name, cn := range c.shards {
2523
c.bcheckClear(name, cn)

e2e-tests/pkg/tests/sharded/test_pitr_basic.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ func (c *Cluster) PITRbasic() {
2121
log.Println("turn on PITR")
2222
defer c.pitrOff()
2323

24-
rand.Seed(time.Now().UnixNano())
25-
2624
counters := make(map[string]shardCounter)
2725
for name, cn := range c.shards {
2826
c.bcheckClear(name, cn)

pbm/restore/physical.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,6 @@ func peekTmpPort(current int) (int, error) {
189189
try = 150
190190
)
191191

192-
rand.Seed(time.Now().UnixNano())
193-
194192
for i := 0; i < try; i++ {
195193
p := current + rand.Intn(rng) + 1
196194
ln, err := net.Listen("tcp", ":"+strconv.Itoa(p))

0 commit comments

Comments
 (0)