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/resolver: move cluster specifier plugin tests to test only package #6681

Merged
merged 3 commits into from
Oct 12, 2023

Conversation

easwars
Copy link
Contributor

@easwars easwars commented Oct 3, 2023

Summary of changes:

  • Moves the tests in xds/internal/resolver/cluster_specifier_plugin_test.go to resolver_test package, thereby making them not rely on any internal details
  • Adds some helper functions (more to come in other PRs) that are used to make tests shorter and will be used in other tests as well
  • Export scheme from the resolver package
  • Add a String() method on the resolver.Target type for better logging output

#resource-agnostic-xdsclient-api

RELEASE NOTES: none

@easwars easwars requested a review from zasweq October 3, 2023 23:11
@easwars easwars added this to the 1.59 Release milestone Oct 3, 2023
@ginayeh ginayeh modified the milestones: 1.59 Release, 1.60 Release Oct 5, 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. Will require some replumbing for the ResolverClientConn being callback based now.

Comment on lines 65 to 69
func (s) TestRegister(t *testing.T) {
if resolver.Get(xdsresolver.Scheme) == nil {
t.Errorf("Scheme %q is not registered", xdsresolver.Scheme)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I find this test strange since I've never seen anything testing the registry from init() calls. I feel like other tests can fail as a result of this not failing which is how I've previously called this, but I don't feel strongly about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I would say it isn't very common to have this test. But I don't think it hurts to have it either.

I feel like other tests can fail as a result of this not failing

I don't understand why/how other tests would fail as a result of this test. Other tests do read from the registry, and so, at that point, this is a redundant test for sure.

Comment on lines +112 to +115
builder := resolver.Get(xdsresolver.Scheme)
if builder == nil {
t.Fatalf("Scheme %q is not registered", xdsresolver.Scheme)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I.e. here related to the test comment above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thought about it a little more and got rid of TestRegister. Doesn't seem to add much value at all. It if could act as a gate to other tests, i.e failure of this test would prevent other tests from running, then it would be a useful thing to have. Now, if the read from the registry fails, then TestRegister would fail and so would all the other tests. So, it makes sense to get rid of it.

Comment on lines 100 to 104
func (s) TestRegister(t *testing.T) {
if resolver.Get(xdsScheme) == nil {
t.Errorf("scheme %v is not registered", xdsScheme)
if resolver.Get(Scheme) == nil {
t.Errorf("scheme %v is not registered", Scheme)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess it was already in codebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's right :)

}
}

// Waits for the resolver to push an update to the fake resolver.ClientConn and
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional nit: verifyUpdateFromResolver waits

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.

@zasweq zasweq assigned easwars and unassigned zasweq Oct 6, 2023
@easwars easwars force-pushed the xds_resolver_cleanup_2 branch from e8264b2 to 4901fb9 Compare October 12, 2023 17:29
@codecov
Copy link

codecov bot commented Oct 12, 2023

Codecov Report

Merging #6681 (0ea283a) into master (dd4c0ad) will increase coverage by 0.02%.
The diff coverage is 100.00%.

Additional details and impacted files

@easwars easwars merged commit 5a6773c into grpc:master Oct 12, 2023
13 checks passed
@easwars easwars deleted the xds_resolver_cleanup_2 branch October 12, 2023 17:51
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.

3 participants