Skip to content

Commit 3722890

Browse files
authored
xdsclient/tests: move fallback tests to separate directory (#8600)
Currently, tests in the `internal/xds/xdsclient/tests` package can take close to a minute to run. Almost half of that time is taken by the fallback tests which actually have to run longer because they have to wait for connections to go down and come up and for these events to be detected by the code (before fallback is triggered). Splitting the fallback tests into a separate directory almost reduces the time by half since tests from these two packages can now run in parallel. We *could* possibly add a way for tests to add some dial options (to be used when dialing the management server), and thereby reduce the time spent in exponential backoff before connections are reattempted (during the fallback process). But this would require non-trivial amount of work, and could make the code more complicated. The change in this PR seems like a good bang for the buck. RELEASE NOTES: none
1 parent e048bd7 commit 3722890

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

internal/xds/xdsclient/tests/fallback_test.go renamed to internal/xds/xdsclient/tests/fallback/fallback_test.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
*/
1818

19-
package xdsclient_test
19+
package xdsclient_fallback_test
2020

2121
import (
2222
"context"
@@ -30,6 +30,7 @@ import (
3030
"google.golang.org/grpc/codes"
3131
"google.golang.org/grpc/credentials/insecure"
3232
"google.golang.org/grpc/internal"
33+
"google.golang.org/grpc/internal/grpctest"
3334
"google.golang.org/grpc/internal/stubserver"
3435
"google.golang.org/grpc/internal/testutils"
3536
"google.golang.org/grpc/internal/testutils/xds/e2e"
@@ -47,11 +48,23 @@ import (
4748
v3discoverypb "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"
4849
testgrpc "google.golang.org/grpc/interop/grpc_testing"
4950
testpb "google.golang.org/grpc/interop/grpc_testing"
51+
52+
_ "google.golang.org/grpc/internal/xds/httpfilter/router" // Register the router filter.
53+
_ "google.golang.org/grpc/xds" // To ensure internal.NewXDSResolverWithConfigForTesting is set.
5054
)
5155

56+
type s struct {
57+
grpctest.Tester
58+
}
59+
60+
func Test(t *testing.T) {
61+
grpctest.RunSubTests(t, s{})
62+
}
63+
5264
// Give the fallback tests additional time to complete because they need to
5365
// first identify failed connections before establishing new ones.
54-
const defaultFallbackTestTimeout = 2 * defaultTestTimeout
66+
const defaultFallbackTestTimeout = 20 * time.Second
67+
const defaultTestShortTimeout = 10 * time.Millisecond // For events expected to *not* happen.
5568

5669
func waitForRPCsToReachBackend(ctx context.Context, client testgrpc.TestServiceClient, backend string) error {
5770
var lastErr error

0 commit comments

Comments
 (0)