-
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: move e2e tests into grpc/test/xds directory #5363
Conversation
xds/xds.go
Outdated
@@ -74,22 +77,69 @@ func init() { | |||
v3statusgrpc.RegisterClientStatusDiscoveryServiceServer(grpcServer, csdss) | |||
return csdss.Close, nil | |||
}) | |||
|
|||
internal.NewXDSResolverWithConfigForTesting = func(bootstrapConfig []byte) (resolver.Builder, error) { |
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.
Move this to the xdsresolver package? And can it be just:
internal.NewXDSResolverWithConfigForTesting = xdsresolver.NewBuilderForTesting
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.
Done.
@@ -0,0 +1,98 @@ | |||
/* | |||
* | |||
* Copyright 2020 gRPC authors. |
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.
😢 why didn't it detect these as moves? Is it possible to fix?
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 initially did this as a git mv
. But then realized that we had some commonly used helper functions like this which were defined in some _test.go files (probably the file where it was first defined). I thought it would be better to move these out into separate files which only have related helpers.
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.
Ah, ok.. I think in that case, since it's a brand new file, the (C) date should be 2022.
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.
Done.
@@ -1,6 +1,3 @@ | |||
//go:build !386 |
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.
Why was this here before?
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 can't remember exactly. But the one issue I remember is with go-control-plane, where they had an int64 in a struct which was accessed atomically, but wasn't aligned on 64-bit boundaries. I fixed it, but we had to wait a while for a release. So, I think we started adding these and over time, I'm guessing newer files just mimicked the existing ones.
// | ||
// Experimental | ||
// | ||
// Notice: This API is EXPERIMENTAL and may be changed or removed in a | ||
// later release. | ||
func NewXDSResolverWithConfigForTesting(bootstrapConfig []byte) (resolver.Builder, error) { |
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.
Why was this moved to internal
but these other, temporary, RLS/RBAC testing functions were added here?
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 function is used from a couple of places: internal/testutils/xds/e2e
and test/xds
while the other temporary register/unregister funcs are only used from test/xds
. There are still some tests in xds/internal/
which use the internal/testutils/xds/e2e
package. So, there were some import loops. For example: top-level xds package --> xds/csds --> internal/testutils/xds/e2e --> top-level-xds-package (for the NewXDSResolverWithConfigForTesting func).
I will try to move those tests out after this PR.
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.
Couldn't these also live in internal
, though, just like the new NewXDSResolverWithConfigForTesting
? That should avoid import loops, too, right?
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.
The import loop was only with NewXDSResolverWithConfigForTesting
, which is why I moved it to the internal
package. I felt like moving the other ones to the internal
package would add too many symbols to it. Please let me know if you feel strongly about this. Thanks.
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.
IMO it's better for them to be in internal
than visible in our external godoc. I should have originally done NewXDSResolver...
that way in hindsight. I imagine it shouldn't be that hard to move these, but if it is, then you can leave them because they're also expected to be temporary.
Also, would this work??
package internal
var NewXDSResolverBlah interface{} // as always
.....
package internal/xds
func NewXDSResolverBlah(args) returns {
// optionally handle `nil`?? Or can we actually import the thing that sets it from here?? Seems plausible.
return internal.NewXDSResolverBlah(func(args)returns)(args)
}
That way we don't have to type cast the functions whenever we use them. This could be a follow-up cleanup, and we could even do something similar with all the other stuff in internal
that needs to be type cast every time we use it.
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.
Or can we actually import the thing that sets it from here??
I guess in the xds cases, "no", because of the visibility problem. But in the other cases (e.g. ParseServiceConfig) then I think we could.
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.
Moved everything to internal
package. Thanks.
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.
Thanks for the review.
xds/xds.go
Outdated
@@ -74,22 +77,69 @@ func init() { | |||
v3statusgrpc.RegisterClientStatusDiscoveryServiceServer(grpcServer, csdss) | |||
return csdss.Close, nil | |||
}) | |||
|
|||
internal.NewXDSResolverWithConfigForTesting = func(bootstrapConfig []byte) (resolver.Builder, error) { |
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.
Done.
@@ -1,6 +1,3 @@ | |||
//go:build !386 |
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 can't remember exactly. But the one issue I remember is with go-control-plane, where they had an int64 in a struct which was accessed atomically, but wasn't aligned on 64-bit boundaries. I fixed it, but we had to wait a while for a release. So, I think we started adding these and over time, I'm guessing newer files just mimicked the existing ones.
@@ -0,0 +1,98 @@ | |||
/* | |||
* | |||
* Copyright 2020 gRPC authors. |
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 initially did this as a git mv
. But then realized that we had some commonly used helper functions like this which were defined in some _test.go files (probably the file where it was first defined). I thought it would be better to move these out into separate files which only have related helpers.
// | ||
// Experimental | ||
// | ||
// Notice: This API is EXPERIMENTAL and may be changed or removed in a | ||
// later release. | ||
func NewXDSResolverWithConfigForTesting(bootstrapConfig []byte) (resolver.Builder, error) { |
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 function is used from a couple of places: internal/testutils/xds/e2e
and test/xds
while the other temporary register/unregister funcs are only used from test/xds
. There are still some tests in xds/internal/
which use the internal/testutils/xds/e2e
package. So, there were some import loops. For example: top-level xds package --> xds/csds --> internal/testutils/xds/e2e --> top-level-xds-package (for the NewXDSResolverWithConfigForTesting func).
I will try to move those tests out after this PR.
This change helps to ensure that we don't inadvertently use some xDS features we are not supposed to use in a e2e test.
Fixes #4829
RELEASE NOTES: none