mirror of https://github.com/grpc/grpc-go.git
xds/e2e: move flag check to each test, and call t.Skip() (#4861)
This commit is contained in:
parent
ea41fbfa10
commit
2fe7118076
|
@ -26,7 +26,9 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
|
channelzgrpc "google.golang.org/grpc/channelz/grpc_channelz_v1"
|
||||||
channelzpb "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"
|
testpb "google.golang.org/grpc/interop/grpc_testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -83,7 +85,7 @@ func newClient(target, binaryPath, bootstrap string, logger io.Writer, flags ...
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *client) clientStats(ctx context.Context) (*testpb.LoadBalancerStatsResponse, error) {
|
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{
|
return ccc.GetClientStats(ctx, &testpb.LoadBalancerStatsRequest{
|
||||||
NumRpcs: 100,
|
NumRpcs: 100,
|
||||||
TimeoutSec: 10,
|
TimeoutSec: 10,
|
||||||
|
@ -91,13 +93,13 @@ func (c *client) clientStats(ctx context.Context) (*testpb.LoadBalancerStatsResp
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *client) configRPCs(ctx context.Context, req *testpb.ClientConfigureRequest) error {
|
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)
|
_, err := ccc.Configure(ctx, req)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *client) channelzSubChannels(ctx context.Context) ([]*channelzpb.Subchannel, error) {
|
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{})
|
r, err := ccc.GetTopChannels(ctx, &channelzpb.GetTopChannelsRequest{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -39,17 +39,6 @@ var (
|
||||||
serverPath = flag.String("server", "./binaries/server", "The interop server")
|
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 {
|
type testOpts struct {
|
||||||
testName string
|
testName string
|
||||||
backendCount int
|
backendCount int
|
||||||
|
@ -58,6 +47,12 @@ type testOpts struct {
|
||||||
|
|
||||||
func setup(t *testing.T, opts testOpts) (*controlPlane, *client, []*server) {
|
func setup(t *testing.T, opts testOpts) (*controlPlane, *client, []*server) {
|
||||||
t.Helper()
|
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
|
backendCount := 1
|
||||||
if opts.backendCount != 0 {
|
if opts.backendCount != 0 {
|
||||||
backendCount = opts.backendCount
|
backendCount = opts.backendCount
|
||||||
|
|
Loading…
Reference in New Issue