Evgenii Stratonikov
9072772a09
This was set in #348 to speed up tests. It seems 100ms doesn't increase overall test time, but it reduces the amount of logs by 100x factor. Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
91 lines
2.3 KiB
Go
91 lines
2.3 KiB
Go
package shard_test
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
"time"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/core/object"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/internal/testutil"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
|
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestShard_Delete(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
t.Run("without write cache", func(t *testing.T) {
|
|
t.Parallel()
|
|
testShardDelete(t, false)
|
|
})
|
|
|
|
t.Run("with write cache", func(t *testing.T) {
|
|
t.Parallel()
|
|
testShardDelete(t, true)
|
|
})
|
|
}
|
|
|
|
func testShardDelete(t *testing.T, hasWriteCache bool) {
|
|
sh := newShard(t, hasWriteCache)
|
|
defer releaseShard(sh, t)
|
|
|
|
cnr := cidtest.ID()
|
|
|
|
obj := testutil.GenerateObjectWithCID(cnr)
|
|
testutil.AddAttribute(obj, "foo", "bar")
|
|
|
|
var putPrm shard.PutPrm
|
|
var getPrm shard.GetPrm
|
|
|
|
t.Run("big object", func(t *testing.T) {
|
|
testutil.AddPayload(obj, 1<<20)
|
|
|
|
putPrm.SetObject(obj)
|
|
getPrm.SetAddress(object.AddressOf(obj))
|
|
|
|
var delPrm shard.DeletePrm
|
|
delPrm.SetAddresses(object.AddressOf(obj))
|
|
|
|
_, err := sh.Put(context.Background(), putPrm)
|
|
require.NoError(t, err)
|
|
|
|
_, err = testGet(t, sh, getPrm, hasWriteCache)
|
|
require.NoError(t, err)
|
|
|
|
_, err = sh.Delete(context.TODO(), delPrm)
|
|
require.NoError(t, err)
|
|
|
|
require.Eventually(t, func() bool {
|
|
_, err = sh.Get(context.Background(), getPrm)
|
|
return client.IsErrObjectNotFound(err)
|
|
}, time.Second, 50*time.Millisecond)
|
|
})
|
|
|
|
t.Run("small object", func(t *testing.T) {
|
|
obj := testutil.GenerateObjectWithCID(cnr)
|
|
testutil.AddAttribute(obj, "foo", "bar")
|
|
testutil.AddPayload(obj, 1<<5)
|
|
|
|
putPrm.SetObject(obj)
|
|
getPrm.SetAddress(object.AddressOf(obj))
|
|
|
|
var delPrm shard.DeletePrm
|
|
delPrm.SetAddresses(object.AddressOf(obj))
|
|
|
|
_, err := sh.Put(context.Background(), putPrm)
|
|
require.NoError(t, err)
|
|
|
|
_, err = sh.Get(context.Background(), getPrm)
|
|
require.NoError(t, err)
|
|
|
|
_, err = sh.Delete(context.Background(), delPrm)
|
|
require.NoError(t, err)
|
|
|
|
require.Eventually(t, func() bool {
|
|
_, err = sh.Get(context.Background(), getPrm)
|
|
return client.IsErrObjectNotFound(err)
|
|
}, time.Second, 50*time.Millisecond)
|
|
})
|
|
}
|