From 5bec96ed02157ff73bf0789807f2628006602648 Mon Sep 17 00:00:00 2001 From: Vissa Janardhan Krishna Sai Date: Mon, 4 Nov 2024 10:51:40 +0000 Subject: [PATCH] refactored grpc server initialization ans starting --- xds/server_ext_test.go | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) 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 {