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

pickfirst: add tests for resolver error scenarios #6484

Merged
merged 3 commits into from
Jul 28, 2023

Conversation

easwars
Copy link
Contributor

@easwars easwars commented Jul 27, 2023

Fixes #6468

RELEASE NOTES: none

@easwars easwars requested a review from dfawley July 27, 2023 18:47
@easwars easwars added this to the 1.58 Release milestone Jul 27, 2023
Comment on lines 970 to 975
// RPCs may fail on the client side in two ways, once the fake server closes
// the accepted connection:
// - writing the client preface succeeds, but not reading the server preface
// - writing the client preface fails
const readErr = "error reading server preface"
const writeErr = "write: broken pipe"
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little worried that this will be too brittle, because the broken pipe comes from the standard libraries IIRC. Can we settle for checking status.Code(err) == codes.Unavailable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When I started writing this, it always was failing with error reading server preface locally. But then, when I pushed my code to GA, it was always failing with broken pipe error. I thought about switching to codes.Unavailable at that point, but then told myself that this should work. But I take your point, never know what it will fail with on google3. Switched it to codes.Unavailable. Thanks.

const readErr = "error reading server preface"
const writeErr = "write: broken pipe"
client := testgrpc.NewTestServiceClient(cc)
if _, err := client.EmptyCall(ctx, &testpb.Empty{}); !strings.Contains(err.Error(), readErr) && !strings.Contains(err.Error(), writeErr) {
Copy link
Member

Choose a reason for hiding this comment

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

FWIW if err is nil for any reason, then this will panic.. If we're keeping string checks, then checking err == nil || (these && strings) would be a simple fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched to using status code instead. So, this is not required.

@dfawley dfawley assigned easwars and unassigned dfawley Jul 27, 2023
@easwars easwars merged commit 20c51a9 into grpc:master Jul 28, 2023
10 checks passed
@easwars easwars deleted the pick_first_resolver_error_e2e_tests branch July 28, 2023 18:17
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 25, 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.

pickfirst: add e2e tests for resolver error scenarios
2 participants