repository: Fix repack test
This reduces the chance of duplicate blobs, otherwise the tests fail (make the contents of a blob depend on a pseudo-random number instead of the size, sizes may be duplicate).
This commit is contained in:
parent
e835abeceb
commit
59782e347c
1 changed files with 5 additions and 1 deletions
|
@ -16,7 +16,7 @@ func randomSize(min, max int) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
func random(t testing.TB, length int) []byte {
|
func random(t testing.TB, length int) []byte {
|
||||||
rd := restic.NewRandReader(rand.New(rand.NewSource(int64(length))))
|
rd := restic.NewRandReader(rand.New(rand.NewSource(rand.Int63())))
|
||||||
buf := make([]byte, length)
|
buf := make([]byte, length)
|
||||||
_, err := io.ReadFull(rd, buf)
|
_, err := io.ReadFull(rd, buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -189,6 +189,10 @@ func TestRepack(t *testing.T) {
|
||||||
repo, cleanup := repository.TestRepository(t)
|
repo, cleanup := repository.TestRepository(t)
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
||||||
|
seed := rand.Int63()
|
||||||
|
rand.Seed(seed)
|
||||||
|
t.Logf("rand seed is %v", seed)
|
||||||
|
|
||||||
createRandomBlobs(t, repo, 100, 0.7)
|
createRandomBlobs(t, repo, 100, 0.7)
|
||||||
|
|
||||||
packsBefore := listPacks(t, repo)
|
packsBefore := listPacks(t, repo)
|
||||||
|
|
Loading…
Reference in a new issue