[#1381] engine: Fix tests
All checks were successful
DCO action / DCO (pull_request) Successful in 1m35s
Tests and linters / Run gofumpt (pull_request) Successful in 1m37s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m40s
Vulncheck / Vulncheck (pull_request) Successful in 2m35s
Tests and linters / Staticcheck (pull_request) Successful in 2m52s
Build / Build Components (pull_request) Successful in 3m33s
Tests and linters / gopls check (pull_request) Successful in 3m35s
Tests and linters / Lint (pull_request) Successful in 4m44s
Tests and linters / Tests (pull_request) Successful in 5m14s
Tests and linters / Tests with -race (pull_request) Successful in 6m1s
All checks were successful
DCO action / DCO (pull_request) Successful in 1m35s
Tests and linters / Run gofumpt (pull_request) Successful in 1m37s
Pre-commit hooks / Pre-commit (pull_request) Successful in 2m40s
Vulncheck / Vulncheck (pull_request) Successful in 2m35s
Tests and linters / Staticcheck (pull_request) Successful in 2m52s
Build / Build Components (pull_request) Successful in 3m33s
Tests and linters / gopls check (pull_request) Successful in 3m35s
Tests and linters / Lint (pull_request) Successful in 4m44s
Tests and linters / Tests (pull_request) Successful in 5m14s
Tests and linters / Tests with -race (pull_request) Successful in 6m1s
Drop not required `Eventually` calls. Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
f71418b73c
commit
0b87be804a
4 changed files with 11 additions and 47 deletions
|
@ -3,7 +3,6 @@ package shard
|
|||
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"
|
||||
|
@ -58,19 +57,14 @@ func testShard(t *testing.T, hasWriteCache bool, payloadSize int) {
|
|||
_, err := sh.Put(context.Background(), putPrm)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = testGet(t, sh, getPrm, hasWriteCache)
|
||||
_, err = sh.Get(context.Background(), getPrm)
|
||||
require.NoError(t, err)
|
||||
|
||||
if hasWriteCache {
|
||||
sh.FlushWriteCache(context.Background(), FlushWriteCachePrm{ignoreErrors: false})
|
||||
require.Eventually(t, func() bool {
|
||||
_, err = sh.Delete(context.Background(), delPrm)
|
||||
return err == nil
|
||||
}, 30*time.Second, 10*time.Millisecond)
|
||||
} else {
|
||||
_, err = sh.Delete(context.Background(), delPrm)
|
||||
require.NoError(t, err)
|
||||
require.NoError(t, sh.FlushWriteCache(context.Background(), FlushWriteCachePrm{ignoreErrors: false}))
|
||||
}
|
||||
_, err = sh.Delete(context.Background(), delPrm)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = sh.Get(context.Background(), getPrm)
|
||||
require.True(t, client.IsErrObjectNotFound(err))
|
||||
|
|
|
@ -5,11 +5,9 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"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-sdk-go/client"
|
||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
oidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id/test"
|
||||
|
@ -49,7 +47,7 @@ func testShardGet(t *testing.T, hasWriteCache bool) {
|
|||
|
||||
getPrm.SetAddress(object.AddressOf(obj))
|
||||
|
||||
res, err := testGet(t, sh, getPrm, hasWriteCache)
|
||||
res, err := sh.Get(context.Background(), getPrm)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, obj, res.Object())
|
||||
})
|
||||
|
@ -67,7 +65,7 @@ func testShardGet(t *testing.T, hasWriteCache bool) {
|
|||
|
||||
getPrm.SetAddress(object.AddressOf(obj))
|
||||
|
||||
res, err := testGet(t, sh, getPrm, hasWriteCache)
|
||||
res, err := sh.Get(context.Background(), getPrm)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, obj, res.Object())
|
||||
})
|
||||
|
@ -95,13 +93,13 @@ func testShardGet(t *testing.T, hasWriteCache bool) {
|
|||
|
||||
getPrm.SetAddress(object.AddressOf(child))
|
||||
|
||||
res, err := testGet(t, sh, getPrm, hasWriteCache)
|
||||
res, err := sh.Get(context.Background(), getPrm)
|
||||
require.NoError(t, err)
|
||||
require.True(t, binaryEqual(child, res.Object()))
|
||||
|
||||
getPrm.SetAddress(object.AddressOf(parent))
|
||||
|
||||
_, err = testGet(t, sh, getPrm, hasWriteCache)
|
||||
_, err = sh.Get(context.Background(), getPrm)
|
||||
|
||||
var si *objectSDK.SplitInfoError
|
||||
require.True(t, errors.As(err, &si))
|
||||
|
@ -115,19 +113,6 @@ func testShardGet(t *testing.T, hasWriteCache bool) {
|
|||
})
|
||||
}
|
||||
|
||||
func testGet(t *testing.T, sh *Shard, getPrm GetPrm, hasWriteCache bool) (GetRes, error) {
|
||||
res, err := sh.Get(context.Background(), getPrm)
|
||||
if hasWriteCache {
|
||||
require.Eventually(t, func() bool {
|
||||
if client.IsErrObjectNotFound(err) {
|
||||
res, err = sh.Get(context.Background(), getPrm)
|
||||
}
|
||||
return !client.IsErrObjectNotFound(err)
|
||||
}, time.Second, time.Millisecond*100)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
|
||||
// binary equal is used when object contains empty lists in the structure and
|
||||
// requre.Equal fails on comparing <nil> and []{} lists.
|
||||
func binaryEqual(a, b *objectSDK.Object) bool {
|
||||
|
|
|
@ -4,11 +4,9 @@ import (
|
|||
"context"
|
||||
"errors"
|
||||
"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-sdk-go/client"
|
||||
cidtest "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id/test"
|
||||
objectSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -46,7 +44,7 @@ func testShardHead(t *testing.T, hasWriteCache bool) {
|
|||
|
||||
headPrm.SetAddress(object.AddressOf(obj))
|
||||
|
||||
res, err := testHead(t, sh, headPrm, hasWriteCache)
|
||||
res, err := sh.Head(context.Background(), headPrm)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, obj.CutPayload(), res.Object())
|
||||
})
|
||||
|
@ -74,7 +72,7 @@ func testShardHead(t *testing.T, hasWriteCache bool) {
|
|||
|
||||
var siErr *objectSDK.SplitInfoError
|
||||
|
||||
_, err = testHead(t, sh, headPrm, hasWriteCache)
|
||||
_, err = sh.Head(context.Background(), headPrm)
|
||||
require.True(t, errors.As(err, &siErr))
|
||||
|
||||
headPrm.SetAddress(object.AddressOf(parent))
|
||||
|
@ -85,16 +83,3 @@ func testShardHead(t *testing.T, hasWriteCache bool) {
|
|||
require.Equal(t, parent.CutPayload(), head.Object())
|
||||
})
|
||||
}
|
||||
|
||||
func testHead(t *testing.T, sh *Shard, headPrm HeadPrm, hasWriteCache bool) (HeadRes, error) {
|
||||
res, err := sh.Head(context.Background(), headPrm)
|
||||
if hasWriteCache {
|
||||
require.Eventually(t, func() bool {
|
||||
if client.IsErrObjectNotFound(err) {
|
||||
res, err = sh.Head(context.Background(), headPrm)
|
||||
}
|
||||
return !client.IsErrObjectNotFound(err)
|
||||
}, time.Second, time.Millisecond*100)
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ func testShardInhume(t *testing.T, hasWriteCache bool) {
|
|||
_, err := sh.Put(context.Background(), putPrm)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = testGet(t, sh, getPrm, hasWriteCache)
|
||||
_, err = sh.Get(context.Background(), getPrm)
|
||||
require.NoError(t, err)
|
||||
|
||||
_, err = sh.Inhume(context.Background(), inhPrm)
|
||||
|
|
Loading…
Reference in a new issue