forked from TrueCloudLab/frostfs-api-go
[#213] netmap: Do not append not twice if selector is unnamed
Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
ea6b6adfe0
commit
4e65fa41b8
2 changed files with 28 additions and 0 deletions
|
@ -68,6 +68,8 @@ func (m *Netmap) GetContainerNodes(p *PlacementPolicy, pivot []byte) (ContainerN
|
|||
for _, s := range p.Selectors() {
|
||||
result[i] = append(result[i], flattenNodes(c.Selections[s.Name()])...)
|
||||
}
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
nodes, ok := c.Selections[r.Selector()]
|
||||
|
|
|
@ -119,6 +119,32 @@ func TestPlacementPolicy_LowerBound(t *testing.T) {
|
|||
require.Equal(t, 3, len(v.Flatten()))
|
||||
}
|
||||
|
||||
func TestIssue213(t *testing.T) {
|
||||
p := newPlacementPolicy(1,
|
||||
[]*Replica{
|
||||
newReplica(4, ""),
|
||||
},
|
||||
[]*Selector{
|
||||
newSelector("", "", ClauseDistinct, 4, "LOC_EU"),
|
||||
},
|
||||
[]*Filter{
|
||||
newFilter("LOC_EU", "Location", "Europe", OpEQ),
|
||||
})
|
||||
nodes := []NodeInfo{
|
||||
nodeInfoFromAttributes("Location", "Europe", "Country", "Russia", "City", "Moscow"),
|
||||
nodeInfoFromAttributes("Location", "Europe", "Country", "Russia", "City", "Saint-Petersburg"),
|
||||
nodeInfoFromAttributes("Location", "Europe", "Country", "Sweden", "City", "Stockholm"),
|
||||
nodeInfoFromAttributes("Location", "Europe", "Country", "Finalnd", "City", "Helsinki"),
|
||||
}
|
||||
|
||||
nm, err := NewNetmap(NodesFromInfo(nodes))
|
||||
require.NoError(t, err)
|
||||
|
||||
v, err := nm.GetContainerNodes(p, nil)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 4, len(v.Flatten()))
|
||||
}
|
||||
|
||||
func TestPlacementPolicy_ProcessSelectors(t *testing.T) {
|
||||
p := newPlacementPolicy(2, nil,
|
||||
[]*Selector{
|
||||
|
|
Loading…
Reference in a new issue