From 2097606f1ed3123af6b4f755d0233c43f8a392fb Mon Sep 17 00:00:00 2001 From: LLThomas Date: Wed, 22 Jun 2022 18:25:30 +0800 Subject: [PATCH 1/2] pkg/testutil: add a WithTestify func for CheckTransferLeader Signed-off-by: LLThomas --- pkg/testutil/operator_check.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/testutil/operator_check.go b/pkg/testutil/operator_check.go index 1df641e7e0a..675131561b9 100644 --- a/pkg/testutil/operator_check.go +++ b/pkg/testutil/operator_check.go @@ -165,6 +165,16 @@ func CheckRemovePeerWithTestify(re *require.Assertions, op *operator.Operator, s } } +// CheckTransferLeaderWithTestify checks if the operator is to transfer leader between the specified source and target stores. +func CheckTransferLeaderWithTestify(re *require.Assertions, op *operator.Operator, kind operator.OpKind, sourceID, targetID uint64) { + re.NotNil(op) + re.Equal(1, op.Len()) + re.Equal(operator.TransferLeader{FromStore: sourceID, ToStore: targetID}, op.Step(0)) + kind |= operator.OpLeader + re.Equal(kind, op.Kind()&kind) +} + + // CheckTransferPeerWithTestify checks if the operator is to transfer peer between the specified source and target stores. func CheckTransferPeerWithTestify(re *require.Assertions, op *operator.Operator, kind operator.OpKind, sourceID, targetID uint64) { re.NotNil(op) From e49ef93fae77a49d712895c5a9d078a1fda282eb Mon Sep 17 00:00:00 2001 From: LLThomas Date: Wed, 22 Jun 2022 18:43:53 +0800 Subject: [PATCH 2/2] change format Signed-off-by: LLThomas --- pkg/testutil/operator_check.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/testutil/operator_check.go b/pkg/testutil/operator_check.go index 675131561b9..e8dca8dff47 100644 --- a/pkg/testutil/operator_check.go +++ b/pkg/testutil/operator_check.go @@ -174,7 +174,6 @@ func CheckTransferLeaderWithTestify(re *require.Assertions, op *operator.Operato re.Equal(kind, op.Kind()&kind) } - // CheckTransferPeerWithTestify checks if the operator is to transfer peer between the specified source and target stores. func CheckTransferPeerWithTestify(re *require.Assertions, op *operator.Operator, kind operator.OpKind, sourceID, targetID uint64) { re.NotNil(op)