From 99825b0ae9fe9c27a419de27df754da6a45fb347 Mon Sep 17 00:00:00 2001 From: xhe Date: Fri, 24 Dec 2021 14:41:31 +0800 Subject: [PATCH] ddl: fix tests Signed-off-by: xhe --- ddl/placement/bundle.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ddl/placement/bundle.go b/ddl/placement/bundle.go index 9c7102178257f..02e8bdcd5a4c9 100644 --- a/ddl/placement/bundle.go +++ b/ddl/placement/bundle.go @@ -88,9 +88,8 @@ func NewBundleFromConstraintsOptions(options *model.PlacementSettings) (*Bundle, Rules = append(Rules, NewRule(Leader, 1, LeaderConstraints)) if followerCount == 0 { - return nil, fmt.Errorf("%w: you must set some followers", ErrInvalidPlacementOptions) + followerCount = 2 } - FollowerRules, err := NewRules(Voter, followerCount, followerConstraints) if err != nil { return nil, fmt.Errorf("%w: invalid FollowerConstraints", err) @@ -145,6 +144,9 @@ func NewBundleFromSugarOptions(options *model.PlacementSettings) (*Bundle, error } followers := options.Followers + if followers == 0 { + followers = 2 + } schedule := options.Schedule primaryIndex := 0 @@ -205,10 +207,6 @@ func newBundleFromOptions(options *model.PlacementSettings) (bundle *Bundle, err isSyntaxSugar = false } - if options.Followers == 0 { - options.Followers = 2 - } - if isSyntaxSugar { bundle, err = NewBundleFromSugarOptions(options) } else {