milvus/internal/cdc/cluster/mock_milvus_client.go
Zhen Ye 318db122b8
enhance: cherry pick patch of new DDL framework and CDC (#45025)
issue: #43897, #44123
pr: #44898
related pr: #44607 #44642 #44792 #44809 #44564 #44560 #44735 #44822
#44865 #44850 #44942 #44874 #44963 #44886 #44898

enhance: remove redundant channel manager from datacoord (#44532)

issue: #41611

- After enabling streaming arch, channel manager of data coord is a
redundant component.


fix: Fix CDC OOM due to high buffer size (#44607)

Fix CDC OOM by:
1. free msg buffer manually.
2. limit max msg buffer size.
3. reduce scanner msg hander buffer size.

issue: https://github.com/milvus-io/milvus/issues/44123

fix: remove wrong start timetick to avoid filtering DML whose timetick
is less than it. (#44691)

issue: #41611

- introduced by #44532

enhance: support remove cluster from replicate topology (#44642)

issue: #44558, #44123
- Update config(A->C) to A and C, config(B) to B on replicate topology
(A->B,A->C) can remove the B from replicate topology
- Fix some metric error of CDC

fix: check if qn is sqn with label and streamingnode list (#44792)

issue: #44014

- On standalone, the query node inside need to load segment and watch
channel, so the querynode is not a embeded querynode in streamingnode
without `LabelStreamingNodeEmbeddedQueryNode`. The channel dist manager
can not confirm a standalone node is a embededStreamingNode.

Bug is introduced by #44099

enhance: Make GetReplicateInfo API work at the pchannel level (#44809)

issue: https://github.com/milvus-io/milvus/issues/44123

enhance: Speed up CDC scheduling (#44564)

Make CDC watch etcd replicate pchannel meta instead of listing them
periodically.

issue: https://github.com/milvus-io/milvus/issues/44123


enhance: refactor update replicate config operation using
wal-broadcast-based DDL/DCL framework (#44560)

issue: #43897

- UpdateReplicateConfig operation will broadcast AlterReplicateConfig
message into all pchannels with cluster-exclusive-lock.
- Begin txn message will use commit message timetick now (to avoid
timetick rollback when CDC with txn message).
- If current cluster is secondary, the UpdateReplicateConfig will wait
until the replicate configuration is consistent with the config
replicated from primary.


enhance: support rbac with WAL-based DDL framework (#44735)

issue: #43897

- RBAC(Roles/Users/Privileges/Privilege Groups) is implemented by
WAL-based DDL framework now.
- Support following message type in wal `AlterUser`, `DropUser`,
`AlterRole`, `DropRole`, `AlterUserRole`, `DropUserRole`,
`AlterPrivilege`, `DropPrivilege`, `AlterPrivilegeGroup`,
`DropPrivilegeGroup`, `RestoreRBAC`.
- RBAC can be synced by new CDC now.
- Refactor some UT for RBAC.


enhance: support database with WAL-based DDL framework (#44822)

issue: #43897

- Database related DDL is implemented by WAL-based DDL framework now.
- Support following message type in wal CreateDatabase, AlterDatabase,
DropDatabase.
- Database DDL can be synced by new CDC now.
- Refactor some UT for Database DDL.

enhance: support alias with WAL-based DDL framework (#44865)

issue: #43897

- Alias related DDL is implemented by WAL-based DDL framework now.
- Support following message type in wal AlterAlias, DropAlias.
- Alias DDL can be synced by new CDC now.
- Refactor some UT for Alias DDL.

enhance: Disable import for replicating cluster (#44850)

1. Import in replicating cluster is not supported yet, so disable it for
now.
2. Remove GetReplicateConfiguration wal API

issue: https://github.com/milvus-io/milvus/issues/44123


fix: use short debug string to avoid newline in debug logs (#44925)

issue: #44924

fix: rerank before requery if reranker didn't use field data (#44942)

issue: #44918


enhance: support resource group with WAL-based DDL framework (#44874)

issue: #43897

- Resource group related DDL is implemented by WAL-based DDL framework
now.
- Support following message type in wal AlterResourceGroup,
DropResourceGroup.
- Resource group DDL can be synced by new CDC now.
- Refactor some UT for resource group DDL.


fix: Fix Fix replication txn data loss during chaos (#44963)

Only confirm CommitMsg for txn messages to prevent data loss.

issue: https://github.com/milvus-io/milvus/issues/44962,
https://github.com/milvus-io/milvus/issues/44123

fix: wrong execution order of DDL/DCL on secondary (#44886)

issue: #44697, #44696

- The DDL executing order of secondary keep same with order of control
channel timetick now.
- filtering the control channel operation on shard manager of
streamingnode to avoid wrong vchannel of create segment.
- fix that the immutable txn message lost replicate header.


fix: Fix primary-secondary replication switch blocking (#44898)

1. Fix primary-secondary replication switchover blocking by delete
replicate pchannel meta using modRevision.
2. Stop channel replicator(scanner) when cluster role changes to prevent
continued message consumption and replication.
3. Close Milvus client to prevent goroutine leak.
4. Create Milvus client once for a channel replicator.
5. Simplify CDC controller and resources.

issue: https://github.com/milvus-io/milvus/issues/44123

---------

Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
Signed-off-by: chyezh <chyezh@outlook.com>
Co-authored-by: yihao.dai <yihao.dai@zilliz.com>
2025-11-03 15:39:33 +08:00

234 lines
7.6 KiB
Go

// Code generated by mockery v2.53.3. DO NOT EDIT.
package cluster
import (
context "context"
grpc "google.golang.org/grpc"
milvuspb "github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
mock "github.com/stretchr/testify/mock"
)
// MockMilvusClient is an autogenerated mock type for the MilvusClient type
type MockMilvusClient struct {
mock.Mock
}
type MockMilvusClient_Expecter struct {
mock *mock.Mock
}
func (_m *MockMilvusClient) EXPECT() *MockMilvusClient_Expecter {
return &MockMilvusClient_Expecter{mock: &_m.Mock}
}
// Close provides a mock function with given fields: ctx
func (_m *MockMilvusClient) Close(ctx context.Context) error {
ret := _m.Called(ctx)
if len(ret) == 0 {
panic("no return value specified for Close")
}
var r0 error
if rf, ok := ret.Get(0).(func(context.Context) error); ok {
r0 = rf(ctx)
} else {
r0 = ret.Error(0)
}
return r0
}
// MockMilvusClient_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close'
type MockMilvusClient_Close_Call struct {
*mock.Call
}
// Close is a helper method to define mock.On call
// - ctx context.Context
func (_e *MockMilvusClient_Expecter) Close(ctx interface{}) *MockMilvusClient_Close_Call {
return &MockMilvusClient_Close_Call{Call: _e.mock.On("Close", ctx)}
}
func (_c *MockMilvusClient_Close_Call) Run(run func(ctx context.Context)) *MockMilvusClient_Close_Call {
_c.Call.Run(func(args mock.Arguments) {
run(args[0].(context.Context))
})
return _c
}
func (_c *MockMilvusClient_Close_Call) Return(_a0 error) *MockMilvusClient_Close_Call {
_c.Call.Return(_a0)
return _c
}
func (_c *MockMilvusClient_Close_Call) RunAndReturn(run func(context.Context) error) *MockMilvusClient_Close_Call {
_c.Call.Return(run)
return _c
}
// CreateReplicateStream provides a mock function with given fields: ctx, opts
func (_m *MockMilvusClient) CreateReplicateStream(ctx context.Context, opts ...grpc.CallOption) (milvuspb.MilvusService_CreateReplicateStreamClient, error) {
_va := make([]interface{}, len(opts))
for _i := range opts {
_va[_i] = opts[_i]
}
var _ca []interface{}
_ca = append(_ca, ctx)
_ca = append(_ca, _va...)
ret := _m.Called(_ca...)
if len(ret) == 0 {
panic("no return value specified for CreateReplicateStream")
}
var r0 milvuspb.MilvusService_CreateReplicateStreamClient
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, ...grpc.CallOption) (milvuspb.MilvusService_CreateReplicateStreamClient, error)); ok {
return rf(ctx, opts...)
}
if rf, ok := ret.Get(0).(func(context.Context, ...grpc.CallOption) milvuspb.MilvusService_CreateReplicateStreamClient); ok {
r0 = rf(ctx, opts...)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(milvuspb.MilvusService_CreateReplicateStreamClient)
}
}
if rf, ok := ret.Get(1).(func(context.Context, ...grpc.CallOption) error); ok {
r1 = rf(ctx, opts...)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockMilvusClient_CreateReplicateStream_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateReplicateStream'
type MockMilvusClient_CreateReplicateStream_Call struct {
*mock.Call
}
// CreateReplicateStream is a helper method to define mock.On call
// - ctx context.Context
// - opts ...grpc.CallOption
func (_e *MockMilvusClient_Expecter) CreateReplicateStream(ctx interface{}, opts ...interface{}) *MockMilvusClient_CreateReplicateStream_Call {
return &MockMilvusClient_CreateReplicateStream_Call{Call: _e.mock.On("CreateReplicateStream",
append([]interface{}{ctx}, opts...)...)}
}
func (_c *MockMilvusClient_CreateReplicateStream_Call) Run(run func(ctx context.Context, opts ...grpc.CallOption)) *MockMilvusClient_CreateReplicateStream_Call {
_c.Call.Run(func(args mock.Arguments) {
variadicArgs := make([]grpc.CallOption, len(args)-1)
for i, a := range args[1:] {
if a != nil {
variadicArgs[i] = a.(grpc.CallOption)
}
}
run(args[0].(context.Context), variadicArgs...)
})
return _c
}
func (_c *MockMilvusClient_CreateReplicateStream_Call) Return(_a0 milvuspb.MilvusService_CreateReplicateStreamClient, _a1 error) *MockMilvusClient_CreateReplicateStream_Call {
_c.Call.Return(_a0, _a1)
return _c
}
func (_c *MockMilvusClient_CreateReplicateStream_Call) RunAndReturn(run func(context.Context, ...grpc.CallOption) (milvuspb.MilvusService_CreateReplicateStreamClient, error)) *MockMilvusClient_CreateReplicateStream_Call {
_c.Call.Return(run)
return _c
}
// GetReplicateInfo provides a mock function with given fields: ctx, req, opts
func (_m *MockMilvusClient) GetReplicateInfo(ctx context.Context, req *milvuspb.GetReplicateInfoRequest, opts ...grpc.CallOption) (*milvuspb.GetReplicateInfoResponse, error) {
_va := make([]interface{}, len(opts))
for _i := range opts {
_va[_i] = opts[_i]
}
var _ca []interface{}
_ca = append(_ca, ctx, req)
_ca = append(_ca, _va...)
ret := _m.Called(_ca...)
if len(ret) == 0 {
panic("no return value specified for GetReplicateInfo")
}
var r0 *milvuspb.GetReplicateInfoResponse
var r1 error
if rf, ok := ret.Get(0).(func(context.Context, *milvuspb.GetReplicateInfoRequest, ...grpc.CallOption) (*milvuspb.GetReplicateInfoResponse, error)); ok {
return rf(ctx, req, opts...)
}
if rf, ok := ret.Get(0).(func(context.Context, *milvuspb.GetReplicateInfoRequest, ...grpc.CallOption) *milvuspb.GetReplicateInfoResponse); ok {
r0 = rf(ctx, req, opts...)
} else {
if ret.Get(0) != nil {
r0 = ret.Get(0).(*milvuspb.GetReplicateInfoResponse)
}
}
if rf, ok := ret.Get(1).(func(context.Context, *milvuspb.GetReplicateInfoRequest, ...grpc.CallOption) error); ok {
r1 = rf(ctx, req, opts...)
} else {
r1 = ret.Error(1)
}
return r0, r1
}
// MockMilvusClient_GetReplicateInfo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetReplicateInfo'
type MockMilvusClient_GetReplicateInfo_Call struct {
*mock.Call
}
// GetReplicateInfo is a helper method to define mock.On call
// - ctx context.Context
// - req *milvuspb.GetReplicateInfoRequest
// - opts ...grpc.CallOption
func (_e *MockMilvusClient_Expecter) GetReplicateInfo(ctx interface{}, req interface{}, opts ...interface{}) *MockMilvusClient_GetReplicateInfo_Call {
return &MockMilvusClient_GetReplicateInfo_Call{Call: _e.mock.On("GetReplicateInfo",
append([]interface{}{ctx, req}, opts...)...)}
}
func (_c *MockMilvusClient_GetReplicateInfo_Call) Run(run func(ctx context.Context, req *milvuspb.GetReplicateInfoRequest, opts ...grpc.CallOption)) *MockMilvusClient_GetReplicateInfo_Call {
_c.Call.Run(func(args mock.Arguments) {
variadicArgs := make([]grpc.CallOption, len(args)-2)
for i, a := range args[2:] {
if a != nil {
variadicArgs[i] = a.(grpc.CallOption)
}
}
run(args[0].(context.Context), args[1].(*milvuspb.GetReplicateInfoRequest), variadicArgs...)
})
return _c
}
func (_c *MockMilvusClient_GetReplicateInfo_Call) Return(_a0 *milvuspb.GetReplicateInfoResponse, _a1 error) *MockMilvusClient_GetReplicateInfo_Call {
_c.Call.Return(_a0, _a1)
return _c
}
func (_c *MockMilvusClient_GetReplicateInfo_Call) RunAndReturn(run func(context.Context, *milvuspb.GetReplicateInfoRequest, ...grpc.CallOption) (*milvuspb.GetReplicateInfoResponse, error)) *MockMilvusClient_GetReplicateInfo_Call {
_c.Call.Return(run)
return _c
}
// NewMockMilvusClient creates a new instance of MockMilvusClient. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
// The first argument is typically a *testing.T value.
func NewMockMilvusClient(t interface {
mock.TestingT
Cleanup(func())
}) *MockMilvusClient {
mock := &MockMilvusClient{}
mock.Mock.Test(t)
t.Cleanup(func() { mock.AssertExpectations(t) })
return mock
}