2024-02-09 06:17:17 +00:00
|
|
|
package meta
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
|
|
|
type epochStateTest struct{}
|
|
|
|
|
|
|
|
func (s epochStateTest) CurrentEpoch() uint64 {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
func Test_Mode(t *testing.T) {
|
|
|
|
t.Parallel()
|
|
|
|
bdb := New([]Option{
|
|
|
|
WithPath(filepath.Join(t.TempDir(), "metabase")),
|
|
|
|
WithPermissions(0o600),
|
|
|
|
WithEpochState(epochStateTest{}),
|
|
|
|
}...)
|
|
|
|
|
|
|
|
require.NoError(t, bdb.Open(context.Background(), mode.DegradedReadOnly))
|
|
|
|
require.Nil(t, bdb.boltDB)
|
2024-10-21 13:27:28 +00:00
|
|
|
require.NoError(t, bdb.Init(context.Background()))
|
2024-02-09 06:17:17 +00:00
|
|
|
require.Nil(t, bdb.boltDB)
|
2024-10-21 13:27:28 +00:00
|
|
|
require.NoError(t, bdb.Close(context.Background()))
|
2024-02-09 06:17:17 +00:00
|
|
|
|
|
|
|
require.NoError(t, bdb.Open(context.Background(), mode.Degraded))
|
|
|
|
require.Nil(t, bdb.boltDB)
|
2024-10-21 13:27:28 +00:00
|
|
|
require.NoError(t, bdb.Init(context.Background()))
|
2024-02-09 06:17:17 +00:00
|
|
|
require.Nil(t, bdb.boltDB)
|
2024-10-21 13:27:28 +00:00
|
|
|
require.NoError(t, bdb.Close(context.Background()))
|
2024-02-09 06:17:17 +00:00
|
|
|
}
|