diff --git a/xds/server_ext_test.go b/xds/server_ext_test.go index f23c937dfa4c..67ed5e610808 100644 --- a/xds/server_ext_test.go +++ b/xds/server_ext_test.go @@ -141,14 +141,12 @@ func (s) TestServingModeChanges(t *testing.T) { } }, } - server, err := xds.NewGRPCServer(grpc.Creds(insecure.NewCredentials()), modeChangeOpt, xds.BootstrapContentsForTesting(bootstrapContents)) - if err != nil { - t.Fatalf("Failed to create an xDS enabled gRPC server: %v", err) + sopts := []grpc.ServerOption{grpc.Creds(insecure.NewCredentials()), modeChangeOpt, xds.BootstrapContentsForTesting(bootstrapContents)} + if stub.S, err = xds.NewGRPCServer(sopts...); err != nil { + t.Errorf("error in grpc server: %v", err) } - defer server.Stop() - - stub.S = server - stubserver.StartTestService(t, stub) + stubserver.StartTestService(t, stub, sopts...) + defer stub.S.Stop() go func() { if err := stub.S.Serve(lis); err != nil { @@ -286,14 +284,12 @@ func (s) TestResourceNotFoundRDS(t *testing.T) { } }, } - server, err := xds.NewGRPCServer(grpc.Creds(insecure.NewCredentials()), modeChangeOpt, xds.BootstrapContentsForTesting(bootstrapContents)) - if err != nil { - t.Fatalf("Failed to create an xDS enabled gRPC server: %v", err) + sopts := []grpc.ServerOption{grpc.Creds(insecure.NewCredentials()), modeChangeOpt, xds.BootstrapContentsForTesting(bootstrapContents)} + if stub.S, err = xds.NewGRPCServer(sopts...); err != nil { + t.Errorf("error in grpc server: %v", err) } - defer server.Stop() - - stub.S = server - stubserver.StartTestService(t, stub) + stubserver.StartTestService(t, stub, sopts...) + defer stub.S.Stop() go func() { if err := stub.S.Serve(lis); err != nil {