Skip to content

Commit

Permalink
xds/e2e: move flag check to each test, and call t.Skip() (#4861)
Browse files Browse the repository at this point in the history
  • Loading branch information
menghanl committed Oct 11, 2021
1 parent ea41fbf commit 2fe7118
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
8 changes: 5 additions & 3 deletions xds/internal/test/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ import (
"os/exec"

"google.golang.org/grpc"
channelzgrpc "google.golang.org/grpc/channelz/grpc_channelz_v1"
channelzpb "google.golang.org/grpc/channelz/grpc_channelz_v1"
testgrpc "google.golang.org/grpc/interop/grpc_testing"
testpb "google.golang.org/grpc/interop/grpc_testing"
)

Expand Down Expand Up @@ -83,21 +85,21 @@ func newClient(target, binaryPath, bootstrap string, logger io.Writer, flags ...
}

func (c *client) clientStats(ctx context.Context) (*testpb.LoadBalancerStatsResponse, error) {
ccc := testpb.NewLoadBalancerStatsServiceClient(c.statsCC)
ccc := testgrpc.NewLoadBalancerStatsServiceClient(c.statsCC)
return ccc.GetClientStats(ctx, &testpb.LoadBalancerStatsRequest{
NumRpcs: 100,
TimeoutSec: 10,
})
}

func (c *client) configRPCs(ctx context.Context, req *testpb.ClientConfigureRequest) error {
ccc := testpb.NewXdsUpdateClientConfigureServiceClient(c.statsCC)
ccc := testgrpc.NewXdsUpdateClientConfigureServiceClient(c.statsCC)
_, err := ccc.Configure(ctx, req)
return err
}

func (c *client) channelzSubChannels(ctx context.Context) ([]*channelzpb.Subchannel, error) {
ccc := channelzpb.NewChannelzClient(c.statsCC)
ccc := channelzgrpc.NewChannelzClient(c.statsCC)
r, err := ccc.GetTopChannels(ctx, &channelzpb.GetTopChannelsRequest{})
if err != nil {
return nil, err
Expand Down
17 changes: 6 additions & 11 deletions xds/internal/test/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,6 @@ var (
serverPath = flag.String("server", "./binaries/server", "The interop server")
)

func TestMain(m *testing.M) {
flag.Parse()
if _, err := os.Stat(*clientPath); os.IsNotExist(err) {
return
}
if _, err := os.Stat(*serverPath); os.IsNotExist(err) {
return
}
os.Exit(m.Run())
}

type testOpts struct {
testName string
backendCount int
Expand All @@ -58,6 +47,12 @@ type testOpts struct {

func setup(t *testing.T, opts testOpts) (*controlPlane, *client, []*server) {
t.Helper()
if _, err := os.Stat(*clientPath); os.IsNotExist(err) {
t.Skip("skipped because client is not found")
}
if _, err := os.Stat(*serverPath); os.IsNotExist(err) {
t.Skip("skipped because server is not found")
}
backendCount := 1
if opts.backendCount != 0 {
backendCount = opts.backendCount
Expand Down

0 comments on commit 2fe7118

Please sign in to comment.