forked from TrueCloudLab/frostfs-node
[#1433] metabase: Add more tests for Select
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
ea76c989ca
commit
5c48588c64
1 changed files with 16 additions and 3 deletions
|
@ -367,17 +367,25 @@ func TestDB_SelectPayloadHash(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
cs, _ := raw1.PayloadChecksum()
|
cs, _ := raw1.PayloadChecksum()
|
||||||
|
payloadHash := hex.EncodeToString(cs.Value())
|
||||||
|
|
||||||
fs := objectSDK.SearchFilters{}
|
fs := objectSDK.SearchFilters{}
|
||||||
fs.AddFilter(v2object.FilterHeaderPayloadHash,
|
fs.AddFilter(v2object.FilterHeaderPayloadHash,
|
||||||
hex.EncodeToString(cs.Value()),
|
payloadHash,
|
||||||
objectSDK.MatchStringEqual)
|
objectSDK.MatchStringEqual)
|
||||||
|
|
||||||
testSelect(t, db, cnr, fs, object.AddressOf(raw1))
|
testSelect(t, db, cnr, fs, object.AddressOf(raw1))
|
||||||
|
|
||||||
fs = objectSDK.SearchFilters{}
|
fs = objectSDK.SearchFilters{}
|
||||||
fs.AddFilter(v2object.FilterHeaderPayloadHash,
|
fs.AddFilter(v2object.FilterHeaderPayloadHash,
|
||||||
hex.EncodeToString(cs.Value()),
|
payloadHash[:len(payloadHash)-1],
|
||||||
|
objectSDK.MatchCommonPrefix)
|
||||||
|
|
||||||
|
testSelect(t, db, cnr, fs, object.AddressOf(raw1))
|
||||||
|
|
||||||
|
fs = objectSDK.SearchFilters{}
|
||||||
|
fs.AddFilter(v2object.FilterHeaderPayloadHash,
|
||||||
|
payloadHash,
|
||||||
objectSDK.MatchStringNotEqual)
|
objectSDK.MatchStringNotEqual)
|
||||||
|
|
||||||
testSelect(t, db, cnr, fs, object.AddressOf(raw2))
|
testSelect(t, db, cnr, fs, object.AddressOf(raw2))
|
||||||
|
@ -473,6 +481,11 @@ func TestDB_SelectWithSlowFilters(t *testing.T) {
|
||||||
fs.AddFilter(v2object.FilterHeaderCreationEpoch, "", objectSDK.MatchNotPresent)
|
fs.AddFilter(v2object.FilterHeaderCreationEpoch, "", objectSDK.MatchNotPresent)
|
||||||
|
|
||||||
testSelect(t, db, cnr, fs)
|
testSelect(t, db, cnr, fs)
|
||||||
|
|
||||||
|
fs = objectSDK.SearchFilters{}
|
||||||
|
fs.AddFilter(v2object.FilterHeaderCreationEpoch, "1", objectSDK.MatchCommonPrefix)
|
||||||
|
|
||||||
|
testSelect(t, db, cnr, fs, object.AddressOf(raw1))
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("object with version", func(t *testing.T) {
|
t.Run("object with version", func(t *testing.T) {
|
||||||
|
@ -771,7 +784,7 @@ func BenchmarkSelect(b *testing.B) {
|
||||||
|
|
||||||
func benchmarkSelect(b *testing.B, db *meta.DB, cid cidSDK.ID, fs objectSDK.SearchFilters, expected int) {
|
func benchmarkSelect(b *testing.B, db *meta.DB, cid cidSDK.ID, fs objectSDK.SearchFilters, expected int) {
|
||||||
for i := 0; i < b.N; i++ {
|
for i := 0; i < b.N; i++ {
|
||||||
res, err := meta.Select(db, &cid, fs)
|
res, err := meta.Select(db, cid, fs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
b.Fatal(err)
|
b.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue