forked from TrueCloudLab/frostfs-node
[#2022] Add metric readonly
to get shards mode
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
e5c304536b
commit
edb1428248
7 changed files with 59 additions and 3 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
meta "github.com/TrueCloudLab/frostfs-node/pkg/local_object_storage/metabase"
|
||||
"github.com/TrueCloudLab/frostfs-node/pkg/local_object_storage/pilorama"
|
||||
"github.com/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard"
|
||||
"github.com/TrueCloudLab/frostfs-node/pkg/local_object_storage/shard/mode"
|
||||
"github.com/TrueCloudLab/frostfs-sdk-go/object"
|
||||
oid "github.com/TrueCloudLab/frostfs-sdk-go/object/id"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -50,13 +51,27 @@ func (m metricsStore) DecObjectCounter(objectType string) {
|
|||
m.AddToObjectCounter(objectType, -1)
|
||||
}
|
||||
|
||||
func (m metricsStore) SetReadonly(r bool) {
|
||||
if r {
|
||||
m.s[readonly] = 1
|
||||
} else {
|
||||
m.s[readonly] = 0
|
||||
}
|
||||
}
|
||||
|
||||
const physical = "phy"
|
||||
const logical = "logic"
|
||||
const readonly = "readonly"
|
||||
|
||||
func TestCounters(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
sh, mm := shardWithMetrics(t, dir)
|
||||
|
||||
sh.SetMode(mode.ReadOnly)
|
||||
require.Equal(t, mm.s[readonly], uint64(1))
|
||||
sh.SetMode(mode.ReadWrite)
|
||||
require.Equal(t, mm.s[readonly], uint64(0))
|
||||
|
||||
const objNumber = 10
|
||||
oo := make([]*object.Object, objNumber)
|
||||
for i := 0; i < objNumber; i++ {
|
||||
|
@ -149,8 +164,9 @@ func shardWithMetrics(t *testing.T, path string) (*shard.Shard, *metricsStore) {
|
|||
|
||||
mm := &metricsStore{
|
||||
s: map[string]uint64{
|
||||
"phy": 0,
|
||||
"logic": 0,
|
||||
"phy": 0,
|
||||
"logic": 0,
|
||||
"readonly": 1,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue