forked from TrueCloudLab/frostfs-sdk-go
[#76] Add UNIQUE keyword
Signed-off-by: Alejandro Lopez <a.lopez@yadro.com>
This commit is contained in:
parent
4f48f6c9e0
commit
fcbf96add6
17 changed files with 498 additions and 345 deletions
|
@ -1,6 +1,7 @@
|
|||
package netmap
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"sort"
|
||||
|
@ -244,6 +245,43 @@ func TestPlacementPolicy_ProcessSelectors(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestPlacementPolicy_Unique(t *testing.T) {
|
||||
p := newPlacementPolicy(2,
|
||||
[]ReplicaDescriptor{
|
||||
newReplica(1, "S"),
|
||||
newReplica(1, "S"),
|
||||
},
|
||||
[]Selector{
|
||||
newSelector("S", "City", 1, "*", (*Selector).SelectSame),
|
||||
},
|
||||
[]Filter{})
|
||||
p.unique = true
|
||||
|
||||
var nodes []NodeInfo
|
||||
for i, city := range []string{"Moscow", "Berlin", "Shenzhen"} {
|
||||
for j := 0; j < 3; j++ {
|
||||
node := nodeInfoFromAttributes("City", city)
|
||||
node.SetPublicKey(binary.BigEndian.AppendUint16(nil, uint16(i*4+j)))
|
||||
nodes = append(nodes, node)
|
||||
}
|
||||
}
|
||||
|
||||
var nm NetMap
|
||||
nm.SetNodes(nodes)
|
||||
|
||||
v, err := nm.ContainerNodes(p, nil)
|
||||
require.NoError(t, err)
|
||||
for i, vi := range v {
|
||||
for _, ni := range vi {
|
||||
for j := 0; j < i; j++ {
|
||||
for _, nj := range v[j] {
|
||||
require.NotEqual(t, ni.hash, nj.hash)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestPlacementPolicy_ProcessSelectorsExceptForNodes(t *testing.T) {
|
||||
p := newPlacementPolicy(1, nil,
|
||||
[]Selector{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue