提交 e21397d6 编写于 作者: S sunby 提交者: yefu.chen

Add runtime stats unittest

Signed-off-by: Nsunby <bingyi.sun@zilliz.com>
上级 a03ab05c
......@@ -41,3 +41,33 @@ func TestRuntimeStats_UpdateFieldStats(t *testing.T) {
assert.EqualValues(t, 1, found)
}
}
func TestRuntimeStats_GetTotalNumOfRelatedSegments(t *testing.T) {
runtimeStats := NewRuntimeStats()
runtimeStats.collStats = make(map[UniqueID]*CollRuntimeStats)
runtimeStats.collStats[1] = &CollRuntimeStats{
fieldIndexStats: map[UniqueID][]*FieldIndexRuntimeStats{
100: {
{1, []*commonpb.KeyValuePair{{Key: "k1", Value: "v1"}}, 10},
{3, []*commonpb.KeyValuePair{{Key: "k1", Value: "v1"}}, 20},
{2, []*commonpb.KeyValuePair{{Key: "k2", Value: "v2"}}, 20},
},
200: {
{1, []*commonpb.KeyValuePair{}, 20},
},
},
}
runtimeStats.collStats[2] = &CollRuntimeStats{
fieldIndexStats: map[UniqueID][]*FieldIndexRuntimeStats{
100: {
{1, []*commonpb.KeyValuePair{{Key: "k1", Value: "v1"}}, 10},
},
},
}
assert.EqualValues(t, 30, runtimeStats.GetTotalNumOfRelatedSegments(1, 100, []*commonpb.KeyValuePair{{Key: "k1", Value: "v1"}}))
assert.EqualValues(t, 20, runtimeStats.GetTotalNumOfRelatedSegments(1, 100, []*commonpb.KeyValuePair{{Key: "k2", Value: "v2"}}))
assert.EqualValues(t, 20, runtimeStats.GetTotalNumOfRelatedSegments(1, 200, []*commonpb.KeyValuePair{}))
assert.EqualValues(t, 10, runtimeStats.GetTotalNumOfRelatedSegments(2, 100, []*commonpb.KeyValuePair{{Key: "k1", Value: "v1"}}))
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册