mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-04 18:02:08 +08:00
#33285 - add segment alloc interceptor for streamingnode. - add add manual alloc segment rpc for datacoord. --------- Signed-off-by: chyezh <chyezh@outlook.com>
31 lines
1.0 KiB
Go
31 lines
1.0 KiB
Go
//go:build test
|
|
// +build test
|
|
|
|
package resource
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/milvus-io/milvus/internal/streamingnode/server/resource/idalloc"
|
|
"github.com/milvus-io/milvus/internal/streamingnode/server/wal/interceptors/segment/inspector"
|
|
"github.com/milvus-io/milvus/internal/streamingnode/server/wal/interceptors/segment/stats"
|
|
)
|
|
|
|
// InitForTest initializes the singleton of resources for test.
|
|
func InitForTest(t *testing.T, opts ...optResourceInit) {
|
|
r = &resourceImpl{}
|
|
for _, opt := range opts {
|
|
opt(r)
|
|
}
|
|
if r.rootCoordClient != nil {
|
|
r.timestampAllocator = idalloc.NewTSOAllocator(r.rootCoordClient)
|
|
r.idAllocator = idalloc.NewIDAllocator(r.rootCoordClient)
|
|
} else {
|
|
r.rootCoordClient = idalloc.NewMockRootCoordClient(t)
|
|
r.timestampAllocator = idalloc.NewTSOAllocator(r.rootCoordClient)
|
|
r.idAllocator = idalloc.NewIDAllocator(r.rootCoordClient)
|
|
}
|
|
r.segmentAssignStatsManager = stats.NewStatsManager()
|
|
r.segmentSealedInspector = inspector.NewSealedInspector(r.segmentAssignStatsManager.SealNotifier())
|
|
}
|