frostfs-node/pkg/local_object_storage/pilorama/mode_test.go
Anton Nikiforov d19ade23c8 [#959] node: Set mode to shard's components when open it
Avoid opening database for `metabase` and `cache` in `Degraded` mode.

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
2024-02-09 14:04:01 +00:00

31 lines
761 B
Go

package pilorama
import (
"context"
"path/filepath"
"testing"
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
"github.com/stretchr/testify/require"
)
func Test_Mode(t *testing.T) {
t.Parallel()
f := NewBoltForest(
[]Option{
WithPath(filepath.Join(t.TempDir(), "test.db")),
WithMaxBatchSize(1),
}...)
require.NoError(t, f.Open(context.Background(), mode.DegradedReadOnly))
require.Nil(t, f.(*boltForest).db)
require.NoError(t, f.Init())
require.Nil(t, f.(*boltForest).db)
require.NoError(t, f.Close())
require.NoError(t, f.Open(context.Background(), mode.Degraded))
require.Nil(t, f.(*boltForest).db)
require.NoError(t, f.Init())
require.Nil(t, f.(*boltForest).db)
require.NoError(t, f.Close())
}