forked from TrueCloudLab/frostfs-api-go
[#356] netmap: Fix potential double-processing of zero subnet
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
051b103df3
commit
4560e447e1
2 changed files with 72 additions and 29 deletions
|
@ -264,4 +264,31 @@ func TestSubnets(t *testing.T) {
|
|||
require.Error(t, err)
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("zero subnet removal via attribute", func(t *testing.T) {
|
||||
var (
|
||||
node netmap.NodeInfo
|
||||
|
||||
attrZero, attrOther netmap.Attribute
|
||||
)
|
||||
|
||||
attrZero.SetKey(subnetAttrKey("0"))
|
||||
attrZero.SetValue("False")
|
||||
|
||||
attrOther.SetKey(subnetAttrKey("1"))
|
||||
attrOther.SetValue("True")
|
||||
|
||||
node.SetAttributes([]*netmap.Attribute{&attrZero, &attrOther})
|
||||
|
||||
calledCount := 0
|
||||
|
||||
err := netmap.IterateSubnets(&node, func(id refs.SubnetID) error {
|
||||
require.False(t, refs.IsZeroSubnet(&id))
|
||||
calledCount++
|
||||
return nil
|
||||
})
|
||||
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, 1, calledCount)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue