From 6e646721007594e1cff2729b1de81d742ac5696f Mon Sep 17 00:00:00 2001 From: Vissa Janardhan Krishna Sai Date: Fri, 13 Dec 2024 05:20:40 +0000 Subject: [PATCH] reverting stubserver changes --- test/creds_test.go | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/test/creds_test.go b/test/creds_test.go index 0019d0f55454..6fe5e2455771 100644 --- a/test/creds_test.go +++ b/test/creds_test.go @@ -32,7 +32,6 @@ import ( "google.golang.org/grpc/connectivity" "google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials/insecure" - "google.golang.org/grpc/internal/stubserver" "google.golang.org/grpc/internal/testutils" "google.golang.org/grpc/metadata" "google.golang.org/grpc/resolver" @@ -470,37 +469,22 @@ func (s) TestCredsHandshakeServerNameAuthority(t *testing.T) { cred := &authorityCheckCreds{} defer lis.Close() - stub := &stubserver.StubServer{ - Listener: lis, - EmptyCallF: func(context.Context, *testpb.Empty) (*testpb.Empty, error) { - return &testpb.Empty{}, nil - }, - } - stub.S = grpc.NewServer() - stubserver.StartTestService(t, stub) + s := grpc.NewServer() + go s.Serve(lis) + defer s.Stop() r := manual.NewBuilderWithScheme("whatever") - + r.InitialState(resolver.State{Addresses: []resolver.Address{{Addr: lis.Addr().String(), ServerName: testServerName}}}) cc, err := grpc.NewClient(r.Scheme()+":///"+testAuthority, grpc.WithTransportCredentials(cred), grpc.WithResolvers(r)) if err != nil { t.Fatalf("grpc.NewClient(%q) = %v", lis.Addr().String(), err) } + cc.Connect() defer cc.Close() - // Start a goroutine to update the resolver state. - go func() { - <-time.After(100 * time.Millisecond) - r.UpdateState(resolver.State{Addresses: []resolver.Address{{Addr: lis.Addr().String(), ServerName: testServerName}}}) - }() - ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) defer cancel() - - // Perform an RPC to trigger the connection process and use the resolver. - client := testpb.NewTestServiceClient(cc) - if _, err := client.EmptyCall(ctx, &testpb.Empty{}); err != nil { - t.Fatalf("Test RPC failed: %v", err) - } + testutils.AwaitState(ctx, t, cc, connectivity.Ready) if cred.got != testServerName { t.Fatalf("client creds got authority: %q, want: %q", cred.got, testAuthority)