[#1583] metabase/test: Update TestLisObjectsWithCursor
All checks were successful
DCO action / DCO (pull_request) Successful in 4m37s
Vulncheck / Vulncheck (pull_request) Successful in 5m1s
Tests and linters / Run gofumpt (pull_request) Successful in 5m36s
Build / Build Components (pull_request) Successful in 6m3s
Pre-commit hooks / Pre-commit (pull_request) Successful in 6m0s
Tests and linters / Staticcheck (pull_request) Successful in 6m29s
Tests and linters / gopls check (pull_request) Successful in 6m41s
Tests and linters / Tests with -race (pull_request) Successful in 6m56s
Tests and linters / Tests (pull_request) Successful in 7m5s
Tests and linters / Lint (pull_request) Successful in 7m13s
Vulncheck / Vulncheck (push) Successful in 5m9s
Tests and linters / Run gofumpt (push) Successful in 5m18s
Pre-commit hooks / Pre-commit (push) Successful in 5m37s
Build / Build Components (push) Successful in 6m6s
Tests and linters / Staticcheck (push) Successful in 6m30s
Tests and linters / gopls check (push) Successful in 6m33s
Tests and linters / Tests (push) Successful in 7m6s
Tests and linters / Tests with -race (push) Successful in 7m7s
Tests and linters / Lint (push) Successful in 7m26s
All checks were successful
DCO action / DCO (pull_request) Successful in 4m37s
Vulncheck / Vulncheck (pull_request) Successful in 5m1s
Tests and linters / Run gofumpt (pull_request) Successful in 5m36s
Build / Build Components (pull_request) Successful in 6m3s
Pre-commit hooks / Pre-commit (pull_request) Successful in 6m0s
Tests and linters / Staticcheck (pull_request) Successful in 6m29s
Tests and linters / gopls check (pull_request) Successful in 6m41s
Tests and linters / Tests with -race (pull_request) Successful in 6m56s
Tests and linters / Tests (pull_request) Successful in 7m5s
Tests and linters / Lint (pull_request) Successful in 7m13s
Vulncheck / Vulncheck (push) Successful in 5m9s
Tests and linters / Run gofumpt (push) Successful in 5m18s
Pre-commit hooks / Pre-commit (push) Successful in 5m37s
Build / Build Components (push) Successful in 6m6s
Tests and linters / Staticcheck (push) Successful in 6m30s
Tests and linters / gopls check (push) Successful in 6m33s
Tests and linters / Tests (push) Successful in 7m6s
Tests and linters / Tests with -race (push) Successful in 7m7s
Tests and linters / Lint (push) Successful in 7m26s
Update this test following recent changes to ensure that `(*DB).ListWithCursor` skips expired objects. Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
parent
0da998ef50
commit
fa08bfa553
1 changed files with 29 additions and 4 deletions
|
@ -3,14 +3,17 @@ package meta_test
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
||||
meta "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
||||
objectV2 "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/api/object"
|
||||
cidSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
||||
"github.com/stretchr/testify/require"
|
||||
"go.etcd.io/bbolt"
|
||||
|
@ -71,14 +74,16 @@ func benchmarkListWithCursor(b *testing.B, db *meta.DB, batchSize int) {
|
|||
func TestLisObjectsWithCursor(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
db := newDB(t)
|
||||
defer func() { require.NoError(t, db.Close(context.Background())) }()
|
||||
|
||||
const (
|
||||
currEpoch = 100
|
||||
expEpoch = currEpoch - 1
|
||||
containers = 5
|
||||
total = containers * 4 // regular + ts + child + lock
|
||||
total = containers * 6 // regular + ts + child + lock + non-expired regular + locked expired
|
||||
)
|
||||
|
||||
db := newDB(t, meta.WithEpochState(epochState{currEpoch}))
|
||||
defer func() { require.NoError(t, db.Close(context.Background())) }()
|
||||
|
||||
expected := make([]object.Info, 0, total)
|
||||
|
||||
// fill metabase with objects
|
||||
|
@ -127,6 +132,26 @@ func TestLisObjectsWithCursor(t *testing.T) {
|
|||
err = putBig(db, child)
|
||||
require.NoError(t, err)
|
||||
expected = append(expected, object.Info{Address: object.AddressOf(child), Type: objectSDK.TypeRegular})
|
||||
|
||||
// add expired object (do not include into expected)
|
||||
obj = testutil.GenerateObjectWithCID(containerID)
|
||||
testutil.AddAttribute(obj, objectV2.SysAttributeExpEpoch, strconv.Itoa(expEpoch))
|
||||
require.NoError(t, metaPut(db, obj, nil))
|
||||
|
||||
// add non-expired object (include into expected)
|
||||
obj = testutil.GenerateObjectWithCID(containerID)
|
||||
testutil.AddAttribute(obj, objectV2.SysAttributeExpEpoch, strconv.Itoa(currEpoch))
|
||||
require.NoError(t, metaPut(db, obj, nil))
|
||||
expected = append(expected, object.Info{Address: object.AddressOf(obj), Type: objectSDK.TypeRegular})
|
||||
|
||||
// add locked expired object (include into expected)
|
||||
obj = testutil.GenerateObjectWithCID(containerID)
|
||||
objID := oidtest.ID()
|
||||
obj.SetID(objID)
|
||||
testutil.AddAttribute(obj, objectV2.SysAttributeExpEpoch, strconv.Itoa(expEpoch))
|
||||
require.NoError(t, metaPut(db, obj, nil))
|
||||
require.NoError(t, db.Lock(context.Background(), containerID, oidtest.ID(), []oid.ID{objID}))
|
||||
expected = append(expected, object.Info{Address: object.AddressOf(obj), Type: objectSDK.TypeRegular})
|
||||
}
|
||||
|
||||
t.Run("success with various count", func(t *testing.T) {
|
||||
|
|
Loading…
Add table
Reference in a new issue