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: move e2e tests into grpc/test/xds directory #5363

Merged
merged 4 commits into from
May 24, 2022

Conversation

easwars
Copy link
Contributor

@easwars easwars commented May 17, 2022

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

@easwars easwars marked this pull request as draft May 17, 2022 23:01
@easwars easwars added this to the 1.47 Release milestone May 17, 2022
@easwars easwars marked this pull request as ready for review May 17, 2022 23:13
@dfawley dfawley self-assigned this May 18, 2022
@dfawley dfawley self-requested a review May 18, 2022 16:44
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) {
Copy link
Member

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

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.

@@ -0,0 +1,98 @@
/*
*
* Copyright 2020 gRPC authors.
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

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.

@@ -1,6 +1,3 @@
//go:build !386
Copy link
Member

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?

Copy link
Contributor Author

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) {
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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?

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 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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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.

@dfawley dfawley assigned easwars and unassigned dfawley May 18, 2022
Copy link
Contributor Author

@easwars easwars left a 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) {
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.

@@ -1,6 +1,3 @@
//go:build !386
Copy link
Contributor Author

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.
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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.

@easwars easwars assigned dfawley and unassigned easwars May 18, 2022
@dfawley dfawley assigned easwars and unassigned dfawley May 18, 2022
@easwars easwars assigned dfawley and unassigned easwars May 18, 2022
@easwars easwars assigned easwars and dfawley and unassigned dfawley and easwars May 19, 2022
@zasweq zasweq modified the milestones: 1.47 Release, 1.48 Release May 23, 2022
@dfawley dfawley assigned easwars and unassigned dfawley May 24, 2022
@easwars easwars merged commit c0e3573 into grpc:master May 24, 2022
@easwars easwars deleted the xds_e2e_tests_move branch May 24, 2022 18:58
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 21, 2022
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.

xds: move e2e tests out of xds/internal
3 participants