Skip to content
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

Merged
merged 2 commits into from
Aug 4, 2023

Conversation

dfawley
Copy link
Member

@dfawley dfawley commented Aug 3, 2023

Simple cleanup using sed to rewrite UpdateSubConnState into TestSubConn.UpdateState calls, which will ensure the StateListener is called if one is registered.

RELEASE NOTES: none

@dfawley dfawley added this to the 1.58 Release milestone Aug 3, 2023
@dfawley dfawley requested a review from easwars August 3, 2023 17:37
@easwars
Copy link
Contributor

easwars commented Aug 3, 2023

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.

@dfawley dfawley assigned easwars and unassigned dfawley Aug 3, 2023
@@ -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{})
Copy link
Contributor

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{})
Copy link
Contributor

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{})
Copy link
Contributor

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{})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here?

@easwars easwars assigned dfawley and unassigned easwars Aug 3, 2023
@dfawley
Copy link
Member Author

dfawley commented Aug 3, 2023

For all of these, I'm trying to avoid changing everything in a single PR. It quickly becomes a gigantic change otherwise. StateListener is still optional for leaf policies, so all these uses are okay for now.

@dfawley dfawley assigned easwars and unassigned dfawley Aug 3, 2023
@easwars
Copy link
Contributor

easwars commented Aug 3, 2023

For all of these, I'm trying to avoid changing everything in a single PR. It quickly becomes a gigantic change otherwise. StateListener is still optional for leaf policies, so all these uses are okay for now.

Ack.

@dfawley dfawley merged commit 4fe8d3d into grpc:master Aug 4, 2023
1 check passed
@dfawley dfawley deleted the testfix branch August 10, 2023 22:15
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants