[#86] node: Move testing utils to one package #150

Merged
fyrchik merged 1 commits from aarifullin/frostfs-node:refactor/86-move_test_utils into master 2023-03-23 08:19:16 +00:00
Collaborator

Move testing utils from tests in local_object_storage package to
unified testutil package

Signed-off-by: Airat Arifullin aarifullin@yadro.com

Move testing utils from tests in local_object_storage package to unified testutil package Signed-off-by: Airat Arifullin <aarifullin@yadro.com>
acid-ant approved these changes 2023-03-20 17:44:21 +00:00
aarifullin force-pushed refactor/86-move_test_utils from b1a06a5084 to 98bf8ef58f 2023-03-21 07:14:12 +00:00 Compare
fyrchik was assigned by aarifullin 2023-03-21 07:16:30 +00:00
ale64bit was assigned by aarifullin 2023-03-21 07:16:31 +00:00
aarifullin requested review from acid-ant 2023-03-21 07:22:30 +00:00
fyrchik added the due date 2023-03-22 2023-03-21 07:30:51 +00:00
ale64bit requested changes 2023-03-21 08:00:27 +00:00
@ -0,0 +1,66 @@
package testutil
import (
"crypto/rand"
Collaborator

crypto/rand seems like overkill here. Maybe use golang.org/x/exp/rand instead.

`crypto/rand` seems like overkill here. Maybe use `golang.org/x/exp/rand` instead.
aarifullin marked this conversation as resolved
@ -0,0 +19,4 @@
}
func GenerateObjectWithCID(cnr cid.ID) *object.Object {
data := make([]byte, 32)
Collaborator

the data size should probably be a parameter.

the data size should probably be a parameter.
Poster
Collaborator

Fow now the package contains two methods: GenerateObject that generates an object with default size 32 and GenerateObjectWithSize to create it with given size. IMHO, this will make the refactoring not so cumbersome

Fow now the package contains two methods: `GenerateObject` that generates an object with default size `32` and `GenerateObjectWithSize` to create it with given size. IMHO, this will make the refactoring not so cumbersome
ale64bit marked this conversation as resolved
@ -0,0 +63,4 @@
obj.SetPayload(buf)
obj.SetPayloadSize(uint64(size))
}
Collaborator
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
Poster
Collaborator

I've moved the generators to testutil and reused GenerateObject... methods. Hope it looks good

I've moved the generators to `testutil` and reused `GenerateObject...` methods. Hope it looks good
ale64bit marked this conversation as resolved
aarifullin force-pushed refactor/86-move_test_utils from 98bf8ef58f to 0a85874664 2023-03-21 11:08:49 +00:00 Compare
aarifullin force-pushed refactor/86-move_test_utils from 0a85874664 to 9922546cb2 2023-03-21 12:44:11 +00:00 Compare
aarifullin force-pushed refactor/86-move_test_utils from 9922546cb2 to f893683b02 2023-03-21 13:41:27 +00:00 Compare
fyrchik reviewed 2023-03-21 14:46:20 +00:00
@ -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?

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?
Poster
Collaborator

Followed this suggestion: #150 (comment)

Anyway, let's keep it but I'll make it private?

Followed this suggestion: https://git.frostfs.info/TrueCloudLab/frostfs-node/pulls/150#issuecomment-2679 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.

To me it is an unnecessary abstraction, given that providing freshly generated CID is trivial.
Poster
Collaborator

Okay. I removed GenerateObjectWithSize

Okay. I removed `GenerateObjectWithSize`
fyrchik marked this conversation as resolved
@ -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?

Can we move generators to a separate file?
aarifullin marked this conversation as resolved
dstepanov-yadro reviewed 2023-03-21 14:53:43 +00:00
@ -0,0 +6,4 @@
"go.uber.org/atomic"
"golang.org/x/exp/rand"

Why are the import blocks separated?

Why are the import blocks separated?
Poster
Collaborator

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

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
Collaborator

i think they should be either separated or be merged through the whole repo

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.

Across the repo we use 2 groups: stdlib and everything else.
Poster
Collaborator

Okay. Fixed

Okay. Fixed
fyrchik marked this conversation as resolved
@ -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 think that these comments should either be deleted or formated correctly. I like the first option better.
Poster
Collaborator

I am not the author of these comments but I suggest just to reformat comments in correct way :) (already edited)

I am not the author of these comments but I suggest just to reformat comments in correct way :) (already edited)
aarifullin force-pushed refactor/86-move_test_utils from f893683b02 to 753cdd6147 2023-03-21 17:59:23 +00:00 Compare
carpawell requested review from ale64bit 2023-03-21 19:07:38 +00:00
carpawell requested review from storage-core-committers 2023-03-21 19:07:47 +00:00
carpawell requested review from storage-core-developers 2023-03-21 19:07:47 +00:00
carpawell reviewed 2023-03-21 19:12:13 +00:00
carpawell left a comment
Collaborator

Can you, please, capitalize "Move" word in the commit message? It is widely adopted format in our repos.

Can you, please, capitalize "Move" word in the commit message? It is widely adopted format in our repos.
aarifullin force-pushed refactor/86-move_test_utils from 753cdd6147 to 92fd33a6aa 2023-03-22 07:13:12 +00:00 Compare
aarifullin force-pushed refactor/86-move_test_utils from 92fd33a6aa to e706f82f8f 2023-03-22 07:22:53 +00:00 Compare
aarifullin force-pushed refactor/86-move_test_utils from e706f82f8f to e3433cc3d9 2023-03-22 07:23:46 +00:00 Compare
aarifullin changed title from [#86] node: move testing utils to one package to [#86] node: Move testing utils to one package 2023-03-22 07:23:58 +00:00
aarifullin force-pushed refactor/86-move_test_utils from e3433cc3d9 to 2efa3b8f0d 2023-03-22 07:25:33 +00:00 Compare
dstepanov-yadro approved these changes 2023-03-22 07:55:56 +00:00
aarifullin force-pushed refactor/86-move_test_utils from 2efa3b8f0d to 15585e85dc 2023-03-22 10:10:19 +00:00 Compare
fyrchik approved these changes 2023-03-23 06:21:42 +00:00
aarifullin force-pushed refactor/86-move_test_utils from 15585e85dc to 54fb265598 2023-03-23 07:16:52 +00:00 Compare
aarifullin requested review from dstepanov-yadro 2023-03-23 07:30:42 +00:00
aarifullin requested review from fyrchik 2023-03-23 07:30:45 +00:00
dstepanov-yadro approved these changes 2023-03-23 08:11:40 +00:00
fyrchik approved these changes 2023-03-23 08:12:00 +00:00
fyrchik merged commit 9808dec591 into master 2023-03-23 08:19:16 +00:00
Sign in to join this conversation.
No Milestone
6 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

2023-03-22

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-node#150
There is no content yet.