From 6ad5c38225adba16946991a68eb12a79bd3cf7e3 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 11 Apr 2023 20:30:27 +0300 Subject: [PATCH] [#236] testutil: Use random object id in `RandObjGenerator` Before this commit it was like this: ``` BenchmarkSubstorageWritePerf/memstore-rand10-8 227425 4859 ns/op BenchmarkSubstorageWritePerf/fstree_nosync-rand10-8 --- FAIL: BenchmarkSubstorageWritePerf/fstree_nosync-rand10-8 perf_test.go:165: writing entry: file exists perf_test.go:165: writing entry: file exists perf_test.go:165: writing entry: file exists BenchmarkSubstorageWritePerf/fstree-rand10-8 --- FAIL: BenchmarkSubstorageWritePerf/fstree-rand10-8 perf_test.go:165: writing entry: file exists perf_test.go:165: writing entry: file exists perf_test.go:165: writing entry: file exists ``` Signed-off-by: Evgenii Stratonikov --- pkg/local_object_storage/internal/testutil/generators.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/local_object_storage/internal/testutil/generators.go b/pkg/local_object_storage/internal/testutil/generators.go index a45ea72aa4..4ee92db882 100644 --- a/pkg/local_object_storage/internal/testutil/generators.go +++ b/pkg/local_object_storage/internal/testutil/generators.go @@ -81,7 +81,9 @@ type RandObjGenerator struct { var _ ObjectGenerator = &RandObjGenerator{} func (g *RandObjGenerator) Next() *object.Object { - return generateObjectWithOIDWithCIDWithSize(oid.ID{}, cid.ID{}, g.ObjSize) + var id oid.ID + rand.Read(id[:]) + return generateObjectWithOIDWithCIDWithSize(id, cid.ID{}, g.ObjSize) } // OverwriteObjGenerator is an ObjectGenerator that generates entries with random payloads of size objSize and at most maxObjects distinct IDs.