[#1445] metabase/test: Add test for tombstones of the new format
All checks were successful
Tests and linters / Run gofumpt (pull_request) Successful in 1m33s
Pre-commit hooks / Pre-commit (pull_request) Successful in 3m5s
Tests and linters / gopls check (pull_request) Successful in 3m48s
DCO action / DCO (pull_request) Successful in 5m11s
Vulncheck / Vulncheck (pull_request) Successful in 5m17s
Build / Build Components (pull_request) Successful in 5m36s
Tests and linters / Staticcheck (pull_request) Successful in 6m26s
Tests and linters / Tests with -race (pull_request) Successful in 6m31s
Tests and linters / Tests (pull_request) Successful in 6m38s
Tests and linters / Lint (pull_request) Successful in 6m59s
All checks were successful
Tests and linters / Run gofumpt (pull_request) Successful in 1m33s
Pre-commit hooks / Pre-commit (pull_request) Successful in 3m5s
Tests and linters / gopls check (pull_request) Successful in 3m48s
DCO action / DCO (pull_request) Successful in 5m11s
Vulncheck / Vulncheck (pull_request) Successful in 5m17s
Build / Build Components (pull_request) Successful in 5m36s
Tests and linters / Staticcheck (pull_request) Successful in 6m26s
Tests and linters / Tests with -race (pull_request) Successful in 6m31s
Tests and linters / Tests (pull_request) Successful in 6m38s
Tests and linters / Lint (pull_request) Successful in 6m59s
Test iterating over graveyard populated with tombstones of both old and new formats. Signed-off-by: Aleksey Savchuk <a.savchuk@yadro.com>
This commit is contained in:
parent
7a4e0dc5fb
commit
be8b99e3bc
1 changed files with 65 additions and 0 deletions
|
@ -14,6 +14,7 @@ import (
|
|||
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"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
func TestDB_IterateDeletedObjects_EmptyDB(t *testing.T) {
|
||||
|
@ -465,3 +466,67 @@ func TestDB_InhumeTombstones(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
require.Zero(t, counter)
|
||||
}
|
||||
|
||||
func TestIterateOverGraveyardWithDifferentGraveFormats(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
type grave struct {
|
||||
addr, tomb oid.Address
|
||||
expEpoch uint64
|
||||
}
|
||||
|
||||
var (
|
||||
numTombstones = 20
|
||||
|
||||
expectedGraves []grave
|
||||
actualGraves []grave
|
||||
eg errgroup.Group
|
||||
)
|
||||
|
||||
db := newDB(t)
|
||||
defer func() { require.NoError(t, db.Close(context.Background())) }()
|
||||
|
||||
var expEpochs []uint64
|
||||
for range numTombstones / 2 {
|
||||
expEpochs = append(expEpochs, rand.Uint64())
|
||||
expEpochs = append(expEpochs, meta.NoExpirationEpoch)
|
||||
}
|
||||
rand.Shuffle(len(expEpochs), func(i, j int) {
|
||||
expEpochs[i], expEpochs[j] = expEpochs[j], expEpochs[i]
|
||||
})
|
||||
|
||||
for _, expEpoch := range expEpochs {
|
||||
cnt := cidtest.ID()
|
||||
|
||||
addr := oidtest.Address()
|
||||
addr.SetContainer(cnt)
|
||||
|
||||
tomb := oidtest.Address()
|
||||
tomb.SetContainer(cnt)
|
||||
|
||||
expectedGraves = append(expectedGraves, grave{
|
||||
addr: addr, tomb: tomb, expEpoch: expEpoch,
|
||||
})
|
||||
|
||||
eg.Go(func() error {
|
||||
var prm meta.InhumePrm
|
||||
prm.SetAddresses(addr)
|
||||
prm.SetTombstoneAddress(tomb, expEpoch)
|
||||
|
||||
_, err := db.Inhume(context.Background(), prm)
|
||||
return err
|
||||
})
|
||||
}
|
||||
require.NoError(t, eg.Wait())
|
||||
|
||||
var iterPrm meta.GraveyardIterationPrm
|
||||
iterPrm.SetHandler(func(o meta.TombstonedObject) error {
|
||||
actualGraves = append(actualGraves, grave{
|
||||
o.Address(), o.Tombstone(), o.ExpirationEpoch(),
|
||||
})
|
||||
return nil
|
||||
})
|
||||
require.NoError(t, db.IterateOverGraveyard(context.Background(), iterPrm))
|
||||
|
||||
require.ElementsMatch(t, expectedGraves, actualGraves)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue