forked from TrueCloudLab/frostfs-node
[#1640] object: Add priority metric based on geo distance
Change-Id: I3a7ea4fc4807392bf50e6ff1389c61367c953074 Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
0712c113de
commit
56d09a9957
8 changed files with 241 additions and 38 deletions
|
@ -601,4 +601,53 @@ func TestTraverserPriorityMetrics(t *testing.T) {
|
|||
next = tr.Next()
|
||||
require.Nil(t, next)
|
||||
})
|
||||
|
||||
t.Run("one rep one geo metric", func(t *testing.T) {
|
||||
t.Skip()
|
||||
selectors := []int{2}
|
||||
replicas := []int{2}
|
||||
|
||||
nodes, cnr := testPlacement(selectors, replicas)
|
||||
|
||||
// Node_0, PK - ip4/0.0.0.0/tcp/0
|
||||
nodes[0][0].SetAttribute("UN-LOCODE", "RU MOW")
|
||||
// Node_1, PK - ip4/0.0.0.0/tcp/1
|
||||
nodes[0][1].SetAttribute("UN-LOCODE", "RU LED")
|
||||
|
||||
sdkNode := testNode(2)
|
||||
sdkNode.SetAttribute("UN-LOCODE", "FI HEL")
|
||||
|
||||
nodesCopy := copyVectors(nodes)
|
||||
|
||||
parser, err := NewMetricsParser("/path/to/locode_db")
|
||||
require.NoError(t, err)
|
||||
m, err := parser.ParseMetrics([]string{geoDistance})
|
||||
require.NoError(t, err)
|
||||
|
||||
tr, err := NewTraverser(context.Background(),
|
||||
ForContainer(cnr),
|
||||
UseBuilder(&testBuilder{
|
||||
vectors: nodesCopy,
|
||||
}),
|
||||
WithoutSuccessTracking(),
|
||||
WithPriorityMetrics(m),
|
||||
WithNodeState(&nodeState{
|
||||
node: &sdkNode,
|
||||
}),
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Without priority metric `$geoDistance` the order will be:
|
||||
// [ {Node_0 RU MOW}, {Node_1 RU LED}]
|
||||
// With priority metric `$geoDistance` the order should be:
|
||||
// [ {Node_1 RU LED}, {Node_0 RU MOW}]
|
||||
next := tr.Next()
|
||||
require.NotNil(t, next)
|
||||
require.Equal(t, 2, len(next))
|
||||
require.Equal(t, "/ip4/0.0.0.0/tcp/1", string(next[0].PublicKey()))
|
||||
require.Equal(t, "/ip4/0.0.0.0/tcp/0", string(next[1].PublicKey()))
|
||||
|
||||
next = tr.Next()
|
||||
require.Nil(t, next)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue