forked from TrueCloudLab/frostfs-node
[#945] metabase: Fix containers listing
Container listing should not ignore tombstone and storage group objects which are not stored in primary buckets. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
8956f015fc
commit
e41aba610d
2 changed files with 57 additions and 10 deletions
|
@ -2,10 +2,12 @@ package meta_test
|
|||
|
||||
import (
|
||||
"math/rand"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||
cidtest "github.com/nspcc-dev/neofs-api-go/pkg/container/id/test"
|
||||
objectSDK "github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/core/object"
|
||||
meta "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/metabase"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -72,6 +74,49 @@ func TestDB_Containers(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestDB_ContainersCount(t *testing.T) {
|
||||
db := newDB(t)
|
||||
t.Cleanup(func() { releaseDB(db) })
|
||||
|
||||
const R, T, SG = 10, 11, 12 // amount of object per type
|
||||
|
||||
uploadObjects := [...]struct {
|
||||
amount int
|
||||
typ objectSDK.Type
|
||||
}{
|
||||
{R, objectSDK.TypeRegular},
|
||||
{T, objectSDK.TypeTombstone},
|
||||
{SG, objectSDK.TypeTombstone},
|
||||
}
|
||||
|
||||
expected := make([]*cid.ID, 0, R+T+SG)
|
||||
|
||||
for _, upload := range uploadObjects {
|
||||
for i := 0; i < upload.amount; i++ {
|
||||
obj := generateRawObject(t)
|
||||
obj.SetType(upload.typ)
|
||||
|
||||
err := putBig(db, obj.Object())
|
||||
require.NoError(t, err)
|
||||
|
||||
expected = append(expected, obj.ContainerID())
|
||||
}
|
||||
}
|
||||
|
||||
sort.Slice(expected, func(i, j int) bool {
|
||||
return expected[i].String() < expected[j].String()
|
||||
})
|
||||
|
||||
got, err := db.Containers()
|
||||
require.NoError(t, err)
|
||||
|
||||
sort.Slice(got, func(i, j int) bool {
|
||||
return got[i].String() < got[j].String()
|
||||
})
|
||||
|
||||
require.Equal(t, expected, got)
|
||||
}
|
||||
|
||||
func TestDB_ContainerSize(t *testing.T) {
|
||||
db := newDB(t)
|
||||
defer releaseDB(db)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue