mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 17:18:35 +08:00
1. Make the segment loader lock protect only the resource. 2. Optimize GetDiskUsage to avoid excessive overhead. issue: https://github.com/milvus-io/milvus/issues/37630 --------- Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
48 lines
974 B
Go
48 lines
974 B
Go
package segcore
|
|
|
|
import (
|
|
"runtime"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"google.golang.org/protobuf/proto"
|
|
|
|
"github.com/milvus-io/milvus/pkg/proto/cgopb"
|
|
)
|
|
|
|
func TestConsumeCStatusIntoError(t *testing.T) {
|
|
err := ConsumeCStatusIntoError(nil)
|
|
assert.NoError(t, err)
|
|
}
|
|
|
|
func TestGetLocalUsedSize(t *testing.T) {
|
|
size, err := GetLocalUsedSize("")
|
|
assert.NoError(t, err)
|
|
assert.NotNil(t, size)
|
|
}
|
|
|
|
func TestProtoLayout(t *testing.T) {
|
|
layout := CreateProtoLayout()
|
|
testProto := cgopb.IndexStats{
|
|
MemSize: 1024,
|
|
SerializedIndexInfos: []*cgopb.SerializedIndexFileInfo{
|
|
{
|
|
FileName: "test",
|
|
FileSize: 768,
|
|
},
|
|
},
|
|
}
|
|
msg, err := proto.Marshal(&testProto)
|
|
defer runtime.KeepAlive(msg)
|
|
assert.NoError(t, err)
|
|
SetProtoLayout(layout, msg)
|
|
|
|
resultProto := cgopb.IndexStats{}
|
|
UnmarshalProtoLayout(layout, &resultProto)
|
|
|
|
assert.True(t, proto.Equal(&testProto, &resultProto))
|
|
layout.blob = nil
|
|
layout.size = 0
|
|
ReleaseProtoLayout(layout)
|
|
}
|