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

grpclb: improve grpclb tests #5826

Merged
merged 3 commits into from
Dec 1, 2022
Merged

Conversation

easwars
Copy link
Contributor

@easwars easwars commented Nov 30, 2022

There is more cleanup that can be done on these tests, but given that we don't care that much about grpclb, I had to stop here. I was able to get it down to 1 failure in 100K across all tests in this package, and that too looked like some infra flake where a backend did not spin up properly.

Fixes #4392.

RELEASE NOTES: n/a

@easwars easwars requested a review from dfawley November 30, 2022 01:21
@easwars easwars added this to the 1.52 Release milestone Nov 30, 2022
@dfawley
Copy link
Member

dfawley commented Nov 30, 2022

Is there a tl;dr description you can provide about the race(s) that were making it flaky before these changes?

// TestGRPCLB_Basic tests the basic case of a channel being configured with
// grpclb as the load balancing policy.
func (s) TestGRPCLB_Basic(t *testing.T) {
// Start a test backend and the remote balancer.
Copy link
Member

Choose a reason for hiding this comment

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

This comment is redundant with the function name being called. Consider instead a t.Log in startBackendsAndRemoveLoadBalancer (optional), or just delete.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Thanks.

},
},
}
rs := state.Set(resolver.State{ServiceConfig: r.CC.ParseServiceConfig(grpclbConfig)}, s)
r.UpdateState(rs)
Copy link
Member

Choose a reason for hiding this comment

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

Should we be using r.InitialState instead before dialing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@@ -36,11 +36,13 @@ import (

"google.golang.org/grpc"
"google.golang.org/grpc/balancer"
grpclbstate "google.golang.org/grpc/balancer/grpclb/state"
Copy link
Member

Choose a reason for hiding this comment

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

This was being renamed because state is such a common name to want to use as a variable, and it's also not descriptive enough at the call sites ("state.Set: what's that?"). Can we change this back? Or rename the package itself to grpclbstate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Renamed the package.

@dfawley dfawley assigned easwars and unassigned dfawley Nov 30, 2022
@easwars
Copy link
Contributor Author

easwars commented Nov 30, 2022

Is there a tl;dr description you can provide about the race(s) that were making it flaky before these changes?

The main reason for the flakiness was the logic used to determine whether RPCs were reaching expected backends. The logic used was mostly ad-hoc, and included just waiting for 1 or 2 seconds for the expected distribution.

Over time, we have added some routines in internal/testutils to verify round_robin and pick_first distribution. These routines take a context and have more involved logic when they wait for the expected distribution of RPCs.

@easwars easwars assigned dfawley and unassigned easwars Dec 1, 2022
@dfawley dfawley assigned easwars and unassigned dfawley Dec 1, 2022
- rename `state` package to `grpclbstate`
- add test logs for setup
- use InitialState() on the manual resolver wherever possible
@easwars easwars force-pushed the grpclb_flaky_tests branch from 7242574 to 86b59e8 Compare December 1, 2022 18:29
@easwars easwars merged commit ef51864 into grpc:master Dec 1, 2022
@easwars easwars deleted the grpclb_flaky_tests branch December 1, 2022 18:53
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 31, 2023
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.

Flaky tests: many tests under grpclb
2 participants