-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't call cmp in non testing file #5370
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,6 @@ package outlierdetection | |
import ( | ||
"time" | ||
|
||
"github.com/google/go-cmp/cmp" | ||
internalserviceconfig "google.golang.org/grpc/internal/serviceconfig" | ||
"google.golang.org/grpc/serviceconfig" | ||
) | ||
|
@@ -154,8 +153,10 @@ type LBConfig struct { | |
ChildPolicy *internalserviceconfig.BalancerConfig `json:"childPolicy,omitempty"` | ||
} | ||
|
||
// Equal returns whether the LBConfig is the same with the parameter. | ||
func (lbc *LBConfig) Equal(lbc2 *LBConfig) bool { | ||
// EqualODOnly returns whether the LBConfig is same with the parameter outside | ||
// of the child policy, only comparing the Outlier Detection specific | ||
// configuration. | ||
func (lbc *LBConfig) EqualODOnly(lbc2 *LBConfig) bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, we should probably have a test of this function that will fail if we add new fields to the config struct. Even a purely change-detector test would help; something like: func TestEqualFields(t *testing.T) {
fields := map[string]bool{"LoadBalancingConfig": true, "Interval": true, "BaseEjectionTime": true, ....}
t := reflect.TypeOf((*LBConfig)(nil))
for i := 0; i < t.NumField(); i++ { // that's probably not the right method name
if n := t.Field(i).Name; !fields[n] {
t.Error("New field %q; update this test and EqualIgnoringChildPolicy", n)
}
}
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added this change-detector test for every node in the config tree. |
||
if lbc == nil && lbc2 == nil { | ||
return true | ||
} | ||
|
@@ -177,8 +178,5 @@ func (lbc *LBConfig) Equal(lbc2 *LBConfig) bool { | |
if !lbc.SuccessRateEjection.Equal(lbc2.SuccessRateEjection) { | ||
return false | ||
} | ||
if !lbc.FailurePercentageEjection.Equal(lbc2.FailurePercentageEjection) { | ||
return false | ||
} | ||
return cmp.Equal(lbc.ChildPolicy, lbc2.ChildPolicy) | ||
return lbc.FailurePercentageEjection.Equal(lbc2.FailurePercentageEjection) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:
EqualIgnoringChildPolicy
?"ODOnly" seems less informative to me since we're comparing OD LB policy structs in the OD package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched.