[#86] node: Move testing utils to one package #150
No reviewers
Labels
No labels
P0
P1
P2
P3
badger
frostfs-adm
frostfs-cli
frostfs-ir
frostfs-lens
frostfs-node
good first issue
triage
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
6 participants
Notifications
Due date
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-node#150
Loading…
Reference in a new issue
No description provided.
Delete branch "aarifullin/frostfs-node:refactor/86-move_test_utils"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Move testing utils from tests in local_object_storage package to
unified testutil package
Signed-off-by: Airat Arifullin aarifullin@yadro.com
b1a06a5084
to98bf8ef58f
@ -0,0 +1,66 @@
package testutil
import (
"crypto/rand"
crypto/rand
seems like overkill here. Maybe usegolang.org/x/exp/rand
instead.@ -0,0 +19,4 @@
}
func GenerateObjectWithCID(cnr cid.ID) *object.Object {
data := make([]byte, 32)
the data size should probably be a parameter.
Fow now the package contains two methods:
GenerateObject
that generates an object with default size32
andGenerateObjectWithSize
to create it with given size. IMHO, this will make the refactoring not so cumbersome@ -0,0 +63,4 @@
obj.SetPayload(buf)
obj.SetPayloadSize(uint64(size))
}
Consider moving the generators here and remove the TODO from https://git.frostfs.info/TrueCloudLab/frostfs-node/src/branch/master/pkg/local_object_storage/blobstor/perf_test.go#L257-L402
I've moved the generators to
testutil
and reusedGenerateObject...
methods. Hope it looks good98bf8ef58f
to0a85874664
0a85874664
to9922546cb2
9922546cb2
tof893683b02
@ -0,0 +28,4 @@
return GenerateObjectWithCIDWithSize(cnr, defaultDataSize)
}
func GenerateObjectWithSize(sz uint64) *object.Object {
It seems to be used only 3 times and only privately, do we need this function?
It seems to be used only 3 times and only privately, do we need this function?
Followed this suggestion: #150 (comment)
Anyway, let's keep it but I'll make it private?
To me it is an unnecessary abstraction, given that providing freshly generated CID is trivial.
Okay. I removed
GenerateObjectWithSize
@ -0,0 +86,4 @@
}
// AddressGenerator is the interface of types that generate object addresses.
type AddressGenerator interface {
Can we move generators to a separate file?
@ -0,0 +6,4 @@
"go.uber.org/atomic"
"golang.org/x/exp/rand"
Why are the import blocks separated?
Sorry, I just did the same on my previous work :)
The reason for the separate group: these are third-party packages (neither std's nor frostfs')
If it's unnecessary, I can unite them with third group
i think they should be either separated or be merged through the whole repo
Across the repo we use 2 groups: stdlib and everything else.
Okay. Fixed
@ -0,0 +90,4 @@
Next() oid.Address
}
// seqAddrGenerator is an AddressGenerator that generates addresses sequentially and wraps around the given max ID.
I think that these comments should either be deleted or formated correctly. I like the first option better.
I am not the author of these comments but I suggest just to reformat comments in correct way :) (already edited)
f893683b02
to753cdd6147
Can you, please, capitalize "Move" word in the commit message? It is widely adopted format in our repos.
753cdd6147
to92fd33a6aa
92fd33a6aa
toe706f82f8f
e706f82f8f
toe3433cc3d9
[#86] node: move testing utils to one packageto [#86] node: Move testing utils to one packagee3433cc3d9
to2efa3b8f0d
2efa3b8f0d
to15585e85dc
15585e85dc
to54fb265598