milvus/internal/util/segcore/cgo_util_test.go
Zhen Ye 3e788f0fbd
enhance: record memory size (uncompressed) item for index (#38770)
issue: #38715

- Current milvus use a serialized index size(compressed) for estimate
resource for loading.
- Add a new field `MemSize` (before compressing) for index to estimate
resource.

---------

Signed-off-by: chyezh <chyezh@outlook.com>
2025-01-14 10:33:06 +08:00

49 lines
1007 B
Go

package segcore
import (
"context"
"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(context.Background(), "")
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)
}