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/client: cleanup Dump to remove unnecessary version field #4978

Merged
merged 2 commits into from
Nov 16, 2021

Conversation

menghanl
Copy link
Contributor

Version is not used by anyone (not even in the CSDS responses).
And version doesn't make sense in federation (when there are multiple control plane servers)

RELEASE NOTES: N/A

@@ -16,7 +16,7 @@
*
*/

package xdsclient_test
package xdsclient
Copy link
Member

Choose a reason for hiding this comment

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

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cleanup.
I believe it was put in a different package because of a circular dependency. That's resolved by the xdsclient refactoring.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, and, this will need to access some unexported testing helper functions, in a future change.

Copy link
Member

Choose a reason for hiding this comment

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

I believe it was put in a different package because of a circular dependency

Maybe so, but IMO all our tests should be in a separate package unless they are unit tests of unexported functions or need to access internals of the package being tested (which we should be trying to minimize). This forces the tests to be written at the API layer, which is more representative of actual usage.

Can we leave this as xdsclient_test, and add the things that access unexported fields to a different test file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

all our tests should be in a separate package

I think this is an overkill. There's a trade-off between unit tests and e2e tests. The complexity added by this requirement is not worth the effort.

Accessing unexported fields doesn't mean to check the field values. It can be to use the unexport update handler to send an update.

For example, in xdsclient, the way to receive an update is to have a real control plane, and use that to send an xDS resp. (There are currently exported functions on the xdsclient to trigger updates, but I think that's not in the right place, and will be unexported)
Requiring a control plane for all the watcher tests is too much work. Or you are arguing that we should move most (all?) the xdsclient tests to e2e.


I changed this back to _test. It's not required in this PR.

Copy link
Member

Choose a reason for hiding this comment

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

I think this is an overkill.

It's overkill to say it must be done that way, but not that we should try to do it that way as much as is reasonable.

Obviously if you need to mock out something to test it more easily (e.g. time things), then you'll put your tests in the same package.

you are arguing that we should move most (all?) the xdsclient tests to e2e.

I didn't mean all our tests need to be at the gRPC API level, but at the API level of the package being tested. A fake management server might be too difficult to be worth doing (maybe?), but we definitely don't want every test of "update XYZ happened, what did the xdsclient see?" to be done all the way up at the E2E/application level.

xds/internal/xdsclient/dump_test.go Outdated Show resolved Hide resolved
@dfawley dfawley assigned menghanl and unassigned dfawley Nov 16, 2021
@menghanl menghanl merged commit bdf8336 into grpc:master Nov 16, 2021
@menghanl menghanl deleted the xdsclient_dump_cleanup branch November 16, 2021 18:45
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants