From e03d906cb73df5c65f3bc105191ff796c5d1264e Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Wed, 20 Jan 2021 21:13:18 +0300 Subject: [PATCH] [#334] engine: Make tests more predictable There is a codecov issue because objects are not placed in the engine the same way every unit test. Therefore sometimes there are more coverage, sometimes there are less. Seeded RNG should solve this issue for engine tests. Signed-off-by: Alex Vanin --- pkg/local_object_storage/blobovnicza/blobovnicza_test.go | 4 +++- pkg/local_object_storage/blobstor/blobovnicza_test.go | 4 +++- pkg/local_object_storage/metabase/db_test.go | 2 +- pkg/local_object_storage/shard/shard_test.go | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pkg/local_object_storage/blobovnicza/blobovnicza_test.go b/pkg/local_object_storage/blobovnicza/blobovnicza_test.go index c603479c..923933d5 100644 --- a/pkg/local_object_storage/blobovnicza/blobovnicza_test.go +++ b/pkg/local_object_storage/blobovnicza/blobovnicza_test.go @@ -1,8 +1,8 @@ package blobovnicza import ( - "crypto/rand" "crypto/sha256" + "math/rand" "os" "testing" @@ -70,6 +70,8 @@ func testGet(t *testing.T, blz *Blobovnicza, addr *objectSDK.Address, expObj []b } func TestBlobovnicza(t *testing.T) { + rand.Seed(1024) + p := "./test_blz" sizeLim := uint64(256 * 1 << 10) // 256KB diff --git a/pkg/local_object_storage/blobstor/blobovnicza_test.go b/pkg/local_object_storage/blobstor/blobovnicza_test.go index d1cf3aaa..833d7242 100644 --- a/pkg/local_object_storage/blobstor/blobovnicza_test.go +++ b/pkg/local_object_storage/blobstor/blobovnicza_test.go @@ -1,9 +1,9 @@ package blobstor import ( - "crypto/rand" "crypto/sha256" "errors" + "math/rand" "os" "testing" @@ -55,6 +55,8 @@ func testObject(sz uint64) *object.Object { } func TestBlobovniczas(t *testing.T) { + rand.Seed(1024) + l := test.NewLogger(false) p := "./test_blz" diff --git a/pkg/local_object_storage/metabase/db_test.go b/pkg/local_object_storage/metabase/db_test.go index 6a2f3a63..d996cbab 100644 --- a/pkg/local_object_storage/metabase/db_test.go +++ b/pkg/local_object_storage/metabase/db_test.go @@ -1,8 +1,8 @@ package meta_test import ( - "crypto/rand" "crypto/sha256" + "math/rand" "os" "testing" diff --git a/pkg/local_object_storage/shard/shard_test.go b/pkg/local_object_storage/shard/shard_test.go index 0d243bc3..5e2465f8 100644 --- a/pkg/local_object_storage/shard/shard_test.go +++ b/pkg/local_object_storage/shard/shard_test.go @@ -1,8 +1,8 @@ package shard_test import ( - "crypto/rand" "crypto/sha256" + "math/rand" "os" "path" "testing"