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

xds/internal/resolver: final bit of test cleanup #6725

Merged
merged 4 commits into from
Oct 13, 2023

Conversation

easwars
Copy link
Contributor

@easwars easwars commented Oct 12, 2023

Summary of changes:

  • Move the remaining xds resolver tests to resolver_test package
    • Remove previously used helpers defined here since they are no longer required
    • Modify existing tests to use new helpers defined in previous test cleanup PRs
    • Split TestXDSResolverHTTPFilters into two
    • One tests config selector failure cases
    • The other tests HTTP filters
      • This is simplified to use a slice of paths instead of using a channel
  • Add a helper to verify error received from resolver
  • Create an internal package within xds/internal/resolver and move things to be overridden in tests to that package

#resource-agnostic-xdsclient-api

RELEASE NOTES: none

@easwars easwars requested a review from zasweq October 12, 2023 23:21
@easwars easwars added this to the 1.60 Release milestone Oct 12, 2023
@easwars easwars force-pushed the xds_resolver_cleanup_4 branch from 9d9646b to 4fdb846 Compare October 13, 2023 18:07
@codecov
Copy link

codecov bot commented Oct 13, 2023

Codecov Report

Merging #6725 (79417f0) into master (c76442c) will decrease coverage by 0.04%.
Report is 5 commits behind head on master.
The diff coverage is 100.00%.

Additional details and impacted files

xds/internal/resolver/internal/internal.go Outdated Show resolved Hide resolved
xds/internal/resolver/xds_resolver_test.go Outdated Show resolved Hide resolved
xds/internal/resolver/xds_resolver_test.go Outdated Show resolved Hide resolved
xds/internal/resolver/xds_resolver_test.go Show resolved Hide resolved
c, cancel, err := xdsclient.NewWithConfigForTesting(bootstrapCfg, defaultTestTimeout, defaultTestTimeout)
return c, func() {
return c, grpcsync.OnceFunc(func() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious, wrapping it with a once func doesn't change this test technically right? The verification on line 327 just requires one read.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The cancel func returned by xdsclient.NewWithConfigForTesting is wrapped inside of a grpcsync.OnceFunc. So calling it any number of times is safe. But that is not the case with the cancel func that we are returning here.

And this becomes a real issue because the helper buildResolverForTarget calls t.Cleanup(r.Close()) and this makes sense for most other tests which don't have to then manually call defer r.Close(). But here we have an explicit call to r.Close(). So, this means that we end up with two calls to r.Close(), which both end up calling xdsClientClose which is safe in the real code because of what I mentioned at the top of this comment.

Copy link
Contributor

Choose a reason for hiding this comment

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

Alright sounds good.

xds/internal/resolver/xds_resolver_test.go Show resolved Hide resolved
xds/internal/resolver/xds_resolver_test.go Show resolved Hide resolved
xds/internal/resolver/xds_resolver_test.go Outdated Show resolved Hide resolved
xds/internal/resolver/xds_resolver_test.go Show resolved Hide resolved
xds/internal/resolver/xds_resolver_test.go Outdated Show resolved Hide resolved
@zasweq zasweq assigned easwars and unassigned zasweq Oct 13, 2023
Copy link
Contributor

@zasweq zasweq left a comment

Choose a reason for hiding this comment

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

LGTM.


target := resolver.Target{URL: *testutils.MustParseURL("xds:///target")}
if _, err := builder.Build(target, nil, resolver.BuildOptions{}); err == nil {
t.Fatalf("xds Resolver Build(%v) succeeded when expected to fail, because there is not bootstrap configuration for the xDS client", target)
Copy link
Contributor

Choose a reason for hiding this comment

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

Whoops there's actualy a lot of Build(....) comments in this file. I'm fine with either one actually, I don't think we need to add it to all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got to a couple more.

@easwars easwars merged commit 6e9c88b into grpc:master Oct 13, 2023
13 checks passed
@easwars easwars deleted the xds_resolver_cleanup_4 branch October 13, 2023 22:27
arvindbr8 pushed a commit to arvindbr8/grpc-go that referenced this pull request Nov 7, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 3, 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