2022-08-22 14:16:35 +00:00
|
|
|
package blobovniczatree
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"strconv"
|
|
|
|
"testing"
|
|
|
|
|
2022-12-23 17:35:35 +00:00
|
|
|
"github.com/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/common"
|
|
|
|
"github.com/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/internal/blobstortest"
|
|
|
|
"github.com/TrueCloudLab/frostfs-node/pkg/util/logger"
|
2022-08-22 14:16:35 +00:00
|
|
|
"go.uber.org/zap/zaptest"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestGeneric(t *testing.T) {
|
|
|
|
const maxObjectSize = 1 << 16
|
|
|
|
|
|
|
|
defer func() { _ = os.RemoveAll(t.Name()) }()
|
|
|
|
|
2022-10-05 12:18:01 +00:00
|
|
|
helper := func(t *testing.T, dir string) common.Storage {
|
2022-08-22 14:16:35 +00:00
|
|
|
return NewBlobovniczaTree(
|
2022-09-28 07:41:01 +00:00
|
|
|
WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
|
2022-08-22 14:16:35 +00:00
|
|
|
WithObjectSizeLimit(maxObjectSize),
|
|
|
|
WithBlobovniczaShallowWidth(2),
|
|
|
|
WithBlobovniczaShallowDepth(2),
|
|
|
|
WithRootPath(dir),
|
|
|
|
WithBlobovniczaSize(1<<20))
|
|
|
|
}
|
|
|
|
|
2022-10-05 12:18:01 +00:00
|
|
|
var n int
|
|
|
|
newTree := func(t *testing.T) common.Storage {
|
|
|
|
dir := filepath.Join(t.Name(), strconv.Itoa(n))
|
|
|
|
return helper(t, dir)
|
|
|
|
}
|
|
|
|
|
2022-08-22 14:16:35 +00:00
|
|
|
blobstortest.TestAll(t, newTree, 1024, maxObjectSize)
|
2022-10-05 12:18:01 +00:00
|
|
|
|
|
|
|
t.Run("info", func(t *testing.T) {
|
|
|
|
dir := filepath.Join(t.Name(), "info")
|
|
|
|
blobstortest.TestInfo(t, func(t *testing.T) common.Storage {
|
|
|
|
return helper(t, dir)
|
|
|
|
}, Type, dir)
|
|
|
|
})
|
2022-08-22 14:16:35 +00:00
|
|
|
}
|
2022-08-23 13:04:01 +00:00
|
|
|
|
|
|
|
func TestControl(t *testing.T) {
|
|
|
|
const maxObjectSize = 2048
|
|
|
|
|
|
|
|
defer func() { _ = os.RemoveAll(t.Name()) }()
|
|
|
|
|
|
|
|
var n int
|
|
|
|
newTree := func(t *testing.T) common.Storage {
|
|
|
|
dir := filepath.Join(t.Name(), strconv.Itoa(n))
|
|
|
|
return NewBlobovniczaTree(
|
2022-09-28 07:41:01 +00:00
|
|
|
WithLogger(&logger.Logger{Logger: zaptest.NewLogger(t)}),
|
2022-08-23 13:04:01 +00:00
|
|
|
WithObjectSizeLimit(maxObjectSize),
|
|
|
|
WithBlobovniczaShallowWidth(2),
|
|
|
|
WithBlobovniczaShallowDepth(2),
|
|
|
|
WithRootPath(dir),
|
|
|
|
WithBlobovniczaSize(1<<20))
|
|
|
|
}
|
|
|
|
|
|
|
|
blobstortest.TestControl(t, newTree, 1024, maxObjectSize)
|
|
|
|
}
|