Skip to content

Commit

Permalink
Revert "test: switching to stubserver in tests instead of testservice (
Browse files Browse the repository at this point in the history
…#7925)"

This reverts commit 5541486.
  • Loading branch information
vinothkumarr227 committed Dec 23, 2024
1 parent 985965a commit 8a0db4c
Showing 1 changed file with 21 additions and 31 deletions.
52 changes: 21 additions & 31 deletions test/balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,15 +417,11 @@ func (s) TestAddressAttributesInNewSubConn(t *testing.T) {
if err != nil {
t.Fatal(err)
}
stub := &stubserver.StubServer{
Listener: lis,
EmptyCallF: func(_ context.Context, _ *testpb.Empty) (*testpb.Empty, error) {
return &testpb.Empty{}, nil
},
S: grpc.NewServer(),
}
stubserver.StartTestService(t, stub)
defer stub.S.Stop()

s := grpc.NewServer()
testgrpc.RegisterTestServiceServer(s, &testServer{})
go s.Serve(lis)
defer s.Stop()
t.Logf("Started gRPC server at %s...", lis.Addr().String())

creds := &attrTransportCreds{}
Expand Down Expand Up @@ -552,16 +548,15 @@ func (s) TestServersSwap(t *testing.T) {
if err != nil {
t.Fatalf("Error while listening. Err: %v", err)
}

stub := &stubserver.StubServer{
Listener: lis,
UnaryCallF: func(_ context.Context, _ *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
s := grpc.NewServer()
ts := &funcServer{
unaryCall: func(context.Context, *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
return &testpb.SimpleResponse{Username: username}, nil
},
S: grpc.NewServer(),
}
stubserver.StartTestService(t, stub)
return lis.Addr().String(), stub.S.Stop
testgrpc.RegisterTestServiceServer(s, ts)
go s.Serve(lis)
return lis.Addr().String(), s.Stop
}
const one = "1"
addr1, cleanup := reg(one)
Expand Down Expand Up @@ -608,16 +603,16 @@ func (s) TestWaitForReady(t *testing.T) {
if err != nil {
t.Fatalf("Error while listening. Err: %v", err)
}
s := grpc.NewServer()
defer s.Stop()
const one = "1"
stub := &stubserver.StubServer{
Listener: lis,
UnaryCallF: func(_ context.Context, _ *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
ts := &funcServer{
unaryCall: func(context.Context, *testpb.SimpleRequest) (*testpb.SimpleResponse, error) {
return &testpb.SimpleResponse{Username: one}, nil
},
S: grpc.NewServer(),
}
stubserver.StartTestService(t, stub)
defer stub.S.Stop()
testgrpc.RegisterTestServiceServer(s, ts)
go s.Serve(lis)

// Initialize client
r := manual.NewBuilderWithScheme("whatever")
Expand Down Expand Up @@ -745,15 +740,10 @@ func (s) TestAuthorityInBuildOptions(t *testing.T) {
t.Fatal(err)
}

stub := &stubserver.StubServer{
Listener: lis,
EmptyCallF: func(_ context.Context, _ *testpb.Empty) (*testpb.Empty, error) {
return &testpb.Empty{}, nil
},
S: grpc.NewServer(),
}
stubserver.StartTestService(t, stub)
defer stub.S.Stop()
s := grpc.NewServer()
testgrpc.RegisterTestServiceServer(s, &testServer{})
go s.Serve(lis)
defer s.Stop()
t.Logf("Started gRPC server at %s...", lis.Addr().String())

r := manual.NewBuilderWithScheme("whatever")
Expand Down

0 comments on commit 8a0db4c

Please sign in to comment.