2021-11-11 13:58:07 +00:00
|
|
|
package engine
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
2021-10-27 14:50:58 +00:00
|
|
|
"os"
|
2021-11-11 13:58:07 +00:00
|
|
|
"testing"
|
|
|
|
|
2021-11-15 09:37:56 +00:00
|
|
|
cidtest "github.com/nspcc-dev/neofs-sdk-go/container/id/test"
|
2021-11-11 13:58:07 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestExecBlocks(t *testing.T) {
|
|
|
|
e := testNewEngineWithShardNum(t, 2) // number doesn't matter in this test, 2 is several but not many
|
2021-10-27 14:50:58 +00:00
|
|
|
t.Cleanup(func() {
|
|
|
|
e.Close()
|
|
|
|
os.RemoveAll(t.Name())
|
|
|
|
})
|
2021-11-11 13:58:07 +00:00
|
|
|
|
|
|
|
// put some object
|
2021-12-01 13:56:48 +00:00
|
|
|
obj := generateRawObjectWithCID(t, cidtest.ID()).Object()
|
2021-11-11 13:58:07 +00:00
|
|
|
|
|
|
|
addr := obj.Address()
|
|
|
|
|
|
|
|
require.NoError(t, Put(e, obj))
|
|
|
|
|
|
|
|
// block executions
|
|
|
|
errBlock := errors.New("block exec err")
|
|
|
|
|
|
|
|
require.NoError(t, e.BlockExecution(errBlock))
|
|
|
|
|
|
|
|
// try to exec some op
|
|
|
|
_, err := Head(e, addr)
|
|
|
|
require.ErrorIs(t, err, errBlock)
|
|
|
|
|
|
|
|
// resume executions
|
|
|
|
require.NoError(t, e.ResumeExecution())
|
|
|
|
|
|
|
|
_, err = Head(e, addr) // can be any data-related op
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
// close
|
|
|
|
require.NoError(t, e.Close())
|
|
|
|
|
|
|
|
// try exec after close
|
|
|
|
_, err = Head(e, addr)
|
|
|
|
require.Error(t, err)
|
|
|
|
|
|
|
|
// try to resume
|
|
|
|
require.Error(t, e.ResumeExecution())
|
|
|
|
}
|