-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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: unify xDS client creation APIs meant for testing #7268
Conversation
de5e265
to
f27e13a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good overall, just a couple small things.
internal/xds/bootstrap/bootstrap.go
Outdated
@@ -415,6 +418,14 @@ func NewConfigFromContents(data []byte) (*Config, error) { | |||
} | |||
|
|||
func newConfigFromContents(data []byte) (*Config, error) { | |||
// Normalize the input configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments should generally say "why" not "what" -- so why are we doing this step now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment.
Earlier, we were doing this for some of the code paths involving testing xDS clients, but not in others. Doing this here would ensure that this is done for all testing xDS clients. And for non-testing xDS clients, this really does not matter.
} | ||
|
||
func init() { | ||
internal.TriggerXDSResourceNotFoundForTesting = triggerXDSResourceNotFoundForTesting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit unfortunate...if we're going to have tests for xds living outside of xds/
then is that another reason to move all of xds/internal
into internal/xds
? Because we could just export this function directly instead of doing all the dance to trampoline through internal
and losing static type safety.
We even still could expose it for use from inside xds/
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have some tests in test/xds
which is probably why we need this. Also, this is not something new that I added in this PR. Instead there were two vars in the internal
package that I reduced to one. But I agree with your sentiment and I've filed #7290 to ensure that this gets done. I will get to this once I'm done with the changes that are currently in flight.
xds/server_ext_test.go
Outdated
) | ||
|
||
type testService struct { | ||
testgrpc.TestServiceServer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this embed the Unimplemented server?
Also, it might be nice to (*always) use the stub server instead, since that allows you to define the RPC behavior inside the test case. Otherwise your test logic ends up decoupled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switched to the unimplemented server.
With regards to using the stub server, this is also an existing test that I moved to a different place. But I looked to see if I could use the stub server. The problem is that the stub server creates a new grpc.Server
and registers the test service on it. We need to change it to optionally accept a server (a vanilla grpc.Server
or xds.GRPCServer
) and register the test service on it, if provided. Filed #7291 to track this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this mostly looks good to me. Had a few comments. PTAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Approved! :)
Summary of changes:
New()
: almost all production code should use thisNewWithConfig()
: Only thegoogle-c2p
resolver uses this since it has to manually construct the bootstrap configurationNewForTesting()
: All tests should use this and it accepts a config structauthority
type by grabbing the lock early when handling watch timer expirybootstrap.Config
struct being manually initialized instead of being created using one of theNewXxx
functions.test/xds
which were using the above functionality into a test only package inxds
#a71-xds-fallback
RELEASE NOTES: none