-
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
balancer: fix tests not properly updating subconn states #6501
Conversation
There seems to be race detected by one of the tests. I haven't looked in detail to figure out whether the race is in the test or in the code. |
@@ -1211,7 +1211,11 @@ var errTestInitIdle = fmt.Errorf("init Idle balancer error 0") | |||
func init() { | |||
stub.Register(initIdleBalancerName, stub.BalancerFuncs{ | |||
UpdateClientConnState: func(bd *stub.BalancerData, opts balancer.ClientConnState) error { | |||
bd.ClientConn.NewSubConn(opts.ResolverState.Addresses, balancer.NewSubConnOptions{}) | |||
sc, err := bd.ClientConn.NewSubConn(opts.ResolverState.Addresses, balancer.NewSubConnOptions{}) |
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.
Don't we need to set the StateListener
here?
@@ -375,7 +375,11 @@ func (s) TestPickerUpdateAfterClose(t *testing.T) { | |||
UpdateClientConnState: func(bd *stub.BalancerData, ccs balancer.ClientConnState) error { | |||
// Create a subConn which will be used later on to test the race | |||
// between UpdateSubConnState() and Close(). | |||
bd.ClientConn.NewSubConn(ccs.ResolverState.Addresses, balancer.NewSubConnOptions{}) | |||
sc, err := bd.ClientConn.NewSubConn(ccs.ResolverState.Addresses, balancer.NewSubConnOptions{}) |
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.
And here, with the StateListener
?
@@ -1746,7 +1746,11 @@ func init() { | |||
ii := i | |||
stub.Register(fmt.Sprintf("%s-%d", initIdleBalancerName, ii), stub.BalancerFuncs{ | |||
UpdateClientConnState: func(bd *stub.BalancerData, opts balancer.ClientConnState) error { | |||
bd.ClientConn.NewSubConn(opts.ResolverState.Addresses, balancer.NewSubConnOptions{}) | |||
sc, err := bd.ClientConn.NewSubConn(opts.ResolverState.Addresses, balancer.NewSubConnOptions{}) |
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.
And here.
@@ -582,7 +582,11 @@ var errTestInitIdle = fmt.Errorf("init Idle balancer error 0") | |||
func init() { | |||
stub.Register(initIdleBalancerName, stub.BalancerFuncs{ | |||
UpdateClientConnState: func(bd *stub.BalancerData, opts balancer.ClientConnState) error { | |||
bd.ClientConn.NewSubConn(opts.ResolverState.Addresses, balancer.NewSubConnOptions{}) | |||
sc, err := bd.ClientConn.NewSubConn(opts.ResolverState.Addresses, balancer.NewSubConnOptions{}) |
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.
And here?
For all of these, I'm trying to avoid changing everything in a single PR. It quickly becomes a gigantic change otherwise. |
Ack. |
Simple cleanup using
sed
to rewriteUpdateSubConnState
intoTestSubConn.UpdateState
calls, which will ensure theStateListener
is called if one is registered.RELEASE NOTES: none