Files
wehub-resource-sync 498b235461
Build and test / Build and test AMD64 Ubuntu 22.04 (push) Failing after 0s
Publish Builder / amazonlinux2023 (push) Failing after 1s
Build and test / UT for Go (push) Has been skipped
Publish KRTE Images / KRTE (push) Failing after 1s
Build and test / Integration Test (push) Has been skipped
Build and test / Upload Code Coverage (push) Has been skipped
Publish Builder / rockylinux9 (push) Failing after 1s
Publish Builder / ubuntu22.04 (push) Failing after 0s
Publish Builder / ubuntu24.04 (push) Failing after 0s
Publish Gpu Builder / publish-gpu-builder (push) Failing after 1s
Publish Test Images / PyTest (push) Failing after 0s
Build and test / UT for Cpp (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:31:17 +08:00

51 lines
1.6 KiB
Go

//go:build test
// +build test
package resource
import (
"testing"
"github.com/milvus-io/milvus/internal/flushcommon/syncmgr"
"github.com/milvus-io/milvus/internal/flushcommon/writebuffer"
"github.com/milvus-io/milvus/internal/streamingnode/server/wal/interceptors/shard/stats"
tinspector "github.com/milvus-io/milvus/internal/streamingnode/server/wal/interceptors/timetick/inspector"
"github.com/milvus-io/milvus/internal/types"
"github.com/milvus-io/milvus/internal/util/idalloc"
"github.com/milvus-io/milvus/pkg/v3/mlog"
"github.com/milvus-io/milvus/pkg/v3/util/syncutil"
)
// OptWriteBufferManager provides a write buffer manager to the resource (test only).
func OptWriteBufferManager(wbMgr writebuffer.BufferManager) optResourceInit {
return func(r *resourceImpl) {
r.wbMgr = wbMgr
}
}
// InitForTest initializes the singleton of resources for test.
func InitForTest(t *testing.T, opts ...optResourceInit) {
r = &resourceImpl{
logger: mlog.With(),
}
for _, opt := range opts {
opt(r)
}
if r.wbMgr == nil && r.chunkManager != nil {
r.syncMgr = syncmgr.NewSyncManager(r.chunkManager)
r.wbMgr = writebuffer.NewManager(r.syncMgr)
}
if r.mixCoordClient != nil {
r.timestampAllocator = idalloc.NewTSOAllocator(r.mixCoordClient)
r.idAllocator = idalloc.NewIDAllocator(r.mixCoordClient)
} else {
f := syncutil.NewFuture[types.MixCoordClient]()
f.Set(idalloc.NewMockRootCoordClient(t))
r.mixCoordClient = f
r.timestampAllocator = idalloc.NewTSOAllocator(r.mixCoordClient)
r.idAllocator = idalloc.NewIDAllocator(r.mixCoordClient)
}
r.segmentStatsManager = stats.NewStatsManager()
r.timeTickInspector = tinspector.NewTimeTickSyncInspector()
}