frostfs-node/pkg/local_object_storage/blobovnicza/get_test.go
Dmitrii Stepanov 7429553266
[#1437] node: Fix contextcheck linter
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
2024-11-13 10:36:10 +03:00

79 lines
1.8 KiB
Go

package blobovnicza
import (
"context"
"path/filepath"
"testing"
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
"github.com/stretchr/testify/require"
)
func TestBlobovnicza_Get(t *testing.T) {
t.Run("re-configure object size limit", func(t *testing.T) {
filename := filepath.Join(t.TempDir(), "blob")
var blz *Blobovnicza
defer func() { require.NoError(t, blz.Close(context.Background())) }()
fnInit := func(szLimit uint64) {
if blz != nil {
require.NoError(t, blz.Close(context.Background()))
}
blz = New(
WithPath(filename),
WithObjectSizeLimit(szLimit),
)
require.NoError(t, blz.Open(context.Background()))
require.NoError(t, blz.Init(context.Background()))
}
// initial distribution: [0:32K] (32K:64K]
fnInit(2 * firstBucketBound)
addr := oidtest.Address()
obj := make([]byte, firstBucketBound+1)
exists, err := blz.Exists(context.Background(), addr)
require.NoError(t, err)
require.False(t, exists)
var prmPut PutPrm
prmPut.SetAddress(addr)
prmPut.SetMarshaledObject(obj)
// place object to [32K:64K] bucket
_, err = blz.Put(context.Background(), prmPut)
require.NoError(t, err)
var prmGet GetPrm
prmGet.SetAddress(addr)
checkObj := func() {
res, err := blz.Get(context.Background(), prmGet)
require.NoError(t, err)
require.Equal(t, obj, res.Object())
exists, err := blz.Exists(context.Background(), addr)
require.NoError(t, err)
require.True(t, exists)
}
// object should be available
checkObj()
// new distribution (extended): [0:32K] (32K:64K] (64K:128K]
fnInit(3 * firstBucketBound)
// object should be still available
checkObj()
// new distribution (shrunk): [0:32K]
fnInit(firstBucketBound)
// object should be still available
checkObj()
})
}