From 71dacb1532517609b412e5eb97ebcd36f0490a44 Mon Sep 17 00:00:00 2001 From: Vissa Janardhan Krishna Sai Date: Wed, 25 Dec 2024 11:51:57 +0000 Subject: [PATCH 1/7] replace dial with newclient --- test/clientconn_state_transition_test.go | 18 +++++++++--------- test/gracefulstop_test.go | 6 ++---- test/xds/xds_security_config_nack_test.go | 4 ++-- test/xds/xds_server_rbac_test.go | 12 ++++++------ .../cdsbalancer/cdsbalancer_security_test.go | 5 +++-- .../balancer/cdsbalancer/cdsbalancer_test.go | 15 +++++++++------ .../clusterresolver/e2e_test/balancer_test.go | 5 +++-- 7 files changed, 34 insertions(+), 31 deletions(-) diff --git a/test/clientconn_state_transition_test.go b/test/clientconn_state_transition_test.go index 547b5ffb9a24..d7617466401d 100644 --- a/test/clientconn_state_transition_test.go +++ b/test/clientconn_state_transition_test.go @@ -236,14 +236,14 @@ func (s) TestStateTransitions_ReadyToConnecting(t *testing.T) { conn.Close() }() - client, err := grpc.Dial(lis.Addr().String(), + client, err := grpc.NewClient(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"loadBalancingConfig": [{"%s":{}}]}`, stateRecordingBalancerName))) if err != nil { t.Fatal(err) } defer client.Close() - + client.Connect() ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) defer cancel() go testutils.StayConnected(ctx, client) @@ -324,7 +324,7 @@ func (s) TestStateTransitions_TriesAllAddrsBeforeTransientFailure(t *testing.T) {Addr: lis1.Addr().String()}, {Addr: lis2.Addr().String()}, }}) - client, err := grpc.Dial("whatever:///this-gets-overwritten", + client, err := grpc.NewClient("whatever:///this-gets-overwritten", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"loadBalancingConfig": [{"%s":{}}]}`, stateRecordingBalancerName)), grpc.WithConnectParams(grpc.ConnectParams{ @@ -339,7 +339,7 @@ func (s) TestStateTransitions_TriesAllAddrsBeforeTransientFailure(t *testing.T) t.Fatal(err) } defer client.Close() - + client.Connect() stateNotifications := testBalancerBuilder.nextStateNotifier() want := []connectivity.State{ connectivity.Connecting, @@ -427,7 +427,7 @@ func (s) TestStateTransitions_MultipleAddrsEntersReady(t *testing.T) { {Addr: lis1.Addr().String()}, {Addr: lis2.Addr().String()}, }}) - client, err := grpc.Dial("whatever:///this-gets-overwritten", + client, err := grpc.NewClient("whatever:///this-gets-overwritten", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"loadBalancingConfig": [{"%s":{}}]}`, stateRecordingBalancerName)), grpc.WithResolvers(rb)) @@ -435,7 +435,7 @@ func (s) TestStateTransitions_MultipleAddrsEntersReady(t *testing.T) { t.Fatal(err) } defer client.Close() - + client.Connect() ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) defer cancel() go testutils.StayConnected(ctx, client) @@ -571,15 +571,15 @@ func (s) TestConnectivityStateSubscriber(t *testing.T) { // Create the ClientConn. const testResName = "any" rb := manual.NewBuilderWithScheme(testResName) - cc, err := grpc.Dial(testResName+":///", + cc, err := grpc.NewClient(testResName+":///", grpc.WithResolvers(rb), grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"loadBalancingConfig": [{"%s":{}}]}`, testBalName)), grpc.WithTransportCredentials(insecure.NewCredentials()), ) if err != nil { - t.Fatalf("Unexpected error from grpc.Dial: %v", err) + t.Fatalf("NewClient() failed: %v", err) } - + cc.Connect() // Subscribe to state updates. Use a buffer size of 1 to allow the // Shutdown state to go into the channel when Close()ing. connCh := make(chan connectivity.State, 1) diff --git a/test/gracefulstop_test.go b/test/gracefulstop_test.go index a1e968e8deb0..bf2aa91ca04f 100644 --- a/test/gracefulstop_test.go +++ b/test/gracefulstop_test.go @@ -148,11 +148,9 @@ func (s) TestGracefulStop(t *testing.T) { // Now dial. The listener's Accept method will return a valid connection, // even though GracefulStop has closed the listener. - ctx, dialCancel := context.WithTimeout(context.Background(), defaultTestTimeout) - defer dialCancel() - cc, err := grpc.DialContext(ctx, "", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithContextDialer(d)) + cc, err := grpc.NewClient("localhost:0", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithContextDialer(d)) if err != nil { - t.Fatalf("grpc.DialContext(_, %q, _) = %v", lis.Addr().String(), err) + t.Fatalf("grpc.NewClient(_, %q, _) = %v", lis.Addr().String(), err) } client := testgrpc.NewTestServiceClient(cc) defer cc.Close() diff --git a/test/xds/xds_security_config_nack_test.go b/test/xds/xds_security_config_nack_test.go index d14f9821411d..574574601aa8 100644 --- a/test/xds/xds_security_config_nack_test.go +++ b/test/xds/xds_security_config_nack_test.go @@ -191,9 +191,9 @@ func (s) TestUnmarshalListener_WithUpdateValidatorFunc(t *testing.T) { } // Create a ClientConn with the xds scheme and make an RPC. - cc, err := grpc.DialContext(ctx, fmt.Sprintf("xds:///%s", serviceName), grpc.WithTransportCredentials(creds), grpc.WithResolvers(xdsResolver)) + cc, err := grpc.NewClient(fmt.Sprintf("xds:///%s", serviceName), grpc.WithTransportCredentials(creds), grpc.WithResolvers(xdsResolver)) if err != nil { - t.Fatalf("failed to dial local test server: %v", err) + t.Fatalf("NewClient() failed: %v", err) } defer cc.Close() diff --git a/test/xds/xds_server_rbac_test.go b/test/xds/xds_server_rbac_test.go index 831f2512a96a..a38f66e9643d 100644 --- a/test/xds/xds_server_rbac_test.go +++ b/test/xds/xds_server_rbac_test.go @@ -245,9 +245,9 @@ func (s) TestServerSideXDS_RouteConfiguration(t *testing.T) { t.Fatal(err) } - cc, err := grpc.DialContext(ctx, fmt.Sprintf("xds:///%s", serviceName), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(xdsResolver)) + cc, err := grpc.NewClient(fmt.Sprintf("xds:///%s", serviceName), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(xdsResolver)) if err != nil { - t.Fatalf("failed to dial local test server: %v", err) + t.Fatalf("NewClient() failed: %v", err) } defer cc.Close() @@ -654,9 +654,9 @@ func (s) TestRBACHTTPFilter(t *testing.T) { t.Fatal(err) } - cc, err := grpc.DialContext(ctx, fmt.Sprintf("xds:///%s", serviceName), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(xdsResolver)) + cc, err := grpc.NewClient(fmt.Sprintf("xds:///%s", serviceName), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(xdsResolver)) if err != nil { - t.Fatalf("failed to dial local test server: %v", err) + t.Fatalf("NewClient() failed: %v", err) } defer cc.Close() @@ -836,9 +836,9 @@ func (s) TestRBACToggledOn_WithBadRouteConfiguration(t *testing.T) { t.Fatal(err) } - cc, err := grpc.DialContext(ctx, fmt.Sprintf("xds:///%s", serviceName), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(xdsResolver)) + cc, err := grpc.NewClient(fmt.Sprintf("xds:///%s", serviceName), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(xdsResolver)) if err != nil { - t.Fatalf("failed to dial local test server: %v", err) + t.Fatalf("NewClient() failed: %v", err) } defer cc.Close() diff --git a/xds/internal/balancer/cdsbalancer/cdsbalancer_security_test.go b/xds/internal/balancer/cdsbalancer/cdsbalancer_security_test.go index cb6eff0cd1c8..97cbaf41a562 100644 --- a/xds/internal/balancer/cdsbalancer/cdsbalancer_security_test.go +++ b/xds/internal/balancer/cdsbalancer/cdsbalancer_security_test.go @@ -162,10 +162,11 @@ func setupForSecurityTests(t *testing.T, bootstrapContents []byte, clientCreds, r.InitialState(state) // Create a ClientConn with the specified transport credentials. - cc, err := grpc.Dial(r.Scheme()+":///test.service", grpc.WithTransportCredentials(clientCreds), grpc.WithResolvers(r)) + cc, err := grpc.NewClient(r.Scheme()+":///test.service", grpc.WithTransportCredentials(clientCreds), grpc.WithResolvers(r)) if err != nil { - t.Fatalf("Failed to dial local test server: %v", err) + t.Fatalf("NewClient() failed: %v", err) } + cc.Connect() t.Cleanup(func() { cc.Close() }) // Start a test service backend with the specified transport credentials. diff --git a/xds/internal/balancer/cdsbalancer/cdsbalancer_test.go b/xds/internal/balancer/cdsbalancer/cdsbalancer_test.go index 9c17cee62cdf..84fb9e622d3f 100644 --- a/xds/internal/balancer/cdsbalancer/cdsbalancer_test.go +++ b/xds/internal/balancer/cdsbalancer/cdsbalancer_test.go @@ -261,10 +261,11 @@ func setupWithManagementServerAndListener(t *testing.T, lis net.Listener) (*e2e. scpr := internal.ParseServiceConfig.(func(string) *serviceconfig.ParseResult)(jsonSC) r.InitialState(xdsclient.SetClient(resolver.State{ServiceConfig: scpr}, xdsC)) - cc, err := grpc.Dial(r.Scheme()+":///test.service", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(r)) + cc, err := grpc.NewClient(r.Scheme()+":///test.service", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(r)) if err != nil { - t.Fatalf("Failed to dial local test server: %v", err) + t.Fatalf("NewClient() failed: %v", err) } + cc.Connect() t.Cleanup(func() { cc.Close() }) return mgmtServer, nodeID, cc, r, xdsC, cdsResourceRequestedCh, cdsResourceCanceledCh @@ -392,10 +393,11 @@ func (s) TestConfigurationUpdate_EmptyCluster(t *testing.T) { r.InitialState(xdsclient.SetClient(resolver.State{ServiceConfig: scpr}, xdsClient)) // Create a ClientConn with the above manual resolver. - cc, err := grpc.Dial(r.Scheme()+":///test.service", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(r)) + cc, err := grpc.NewClient(r.Scheme()+":///test.service", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(r)) if err != nil { - t.Fatalf("Failed to dial: %v", err) + t.Fatalf("NewClient() failed: %v", err) } + cc.Connect() t.Cleanup(func() { cc.Close() }) select { @@ -429,10 +431,11 @@ func (s) TestConfigurationUpdate_MissingXdsClient(t *testing.T) { r.InitialState(resolver.State{ServiceConfig: scpr}) // Create a ClientConn with the above manual resolver. - cc, err := grpc.Dial(r.Scheme()+":///test.service", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(r)) + cc, err := grpc.NewClient(r.Scheme()+":///test.service", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(r)) if err != nil { - t.Fatalf("Failed to dial: %v", err) + t.Fatalf("NewClient() failed: %v", err) } + cc.Connect() t.Cleanup(func() { cc.Close() }) select { diff --git a/xds/internal/balancer/clusterresolver/e2e_test/balancer_test.go b/xds/internal/balancer/clusterresolver/e2e_test/balancer_test.go index 2d934ef3ae10..77b73927159c 100644 --- a/xds/internal/balancer/clusterresolver/e2e_test/balancer_test.go +++ b/xds/internal/balancer/clusterresolver/e2e_test/balancer_test.go @@ -97,11 +97,12 @@ func setupAndDial(t *testing.T, bootstrapContents []byte) (*grpc.ClientConn, fun r.InitialState(xdsclient.SetClient(resolver.State{ServiceConfig: scpr}, xdsC)) // Create a ClientConn and make a successful RPC. - cc, err := grpc.Dial(r.Scheme()+":///test.service", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(r)) + cc, err := grpc.NewClient(r.Scheme()+":///test.service", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(r)) if err != nil { xdsClose() - t.Fatalf("Failed to dial local test server: %v", err) + t.Fatalf("NewClient() failed: %v", err) } + cc.Connect() return cc, func() { xdsClose() cc.Close() From 88c3f0f4d12e315f8b4b274b879da217a5811ca7 Mon Sep 17 00:00:00 2001 From: Vissa Janardhan Krishna Sai Date: Thu, 26 Dec 2024 11:58:35 +0000 Subject: [PATCH 2/7] updating error msg and replacing dial with newclient --- test/xds/xds_server_serving_mode_test.go | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/test/xds/xds_server_serving_mode_test.go b/test/xds/xds_server_serving_mode_test.go index 0299d6954ddb..1f40e879e207 100644 --- a/test/xds/xds_server_serving_mode_test.go +++ b/test/xds/xds_server_serving_mode_test.go @@ -247,7 +247,7 @@ func (s) TestServerSideXDS_ServingModeChanges(t *testing.T) { // Create a ClientConn to the first listener and make a successful RPCs. cc1, err := grpc.NewClient(lis1.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { - t.Fatalf("failed to dial local test server: %v", err) + t.Fatalf("failed to create a client for server: %v", err) } defer cc1.Close() waitForSuccessfulRPC(ctx, t, cc1) @@ -255,7 +255,7 @@ func (s) TestServerSideXDS_ServingModeChanges(t *testing.T) { // Create a ClientConn to the second listener and make a successful RPCs. cc2, err := grpc.NewClient(lis2.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { - t.Fatalf("failed to dial local test server: %v", err) + t.Fatalf("failed to create a client for server: %v", err) } defer cc2.Close() waitForSuccessfulRPC(ctx, t, cc2) @@ -309,14 +309,11 @@ func (s) TestServerSideXDS_ServingModeChanges(t *testing.T) { waitForFailedRPC(ctx, t, cc1) waitForFailedRPC(ctx, t, cc2) - // Make sure new connection attempts to "not-serving" servers fail. We use a - // short timeout since we expect this to fail. - sCtx, sCancel := context.WithTimeout(ctx, defaultTestShortTimeout) - defer sCancel() - if _, err := grpc.DialContext(sCtx, lis1.Addr().String(), grpc.WithBlock(), grpc.WithTransportCredentials(insecure.NewCredentials())); err == nil { - t.Fatal("successfully created clientConn to a server in \"not-serving\" state") + // Make sure new connection attempts to "not-serving" servers fail. + if cc1, err = grpc.NewClient(lis1.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()); err != nil { + t.Fatalf("failed to create a client for server: %v", err) } - + defer cc1.Close() // Update the management server with both listener resources. if err := managementServer.Update(ctx, e2e.UpdateOptions{ NodeID: nodeID, From ceb12042f328571a99321decd2174a4f94943cc3 Mon Sep 17 00:00:00 2001 From: Vissa Janardhan Krishna Sai Date: Thu, 26 Dec 2024 12:10:06 +0000 Subject: [PATCH 3/7] updating error mdg --- test/clientconn_state_transition_test.go | 2 +- test/xds/xds_client_federation_test.go | 7 ++++--- test/xds/xds_security_config_nack_test.go | 2 +- test/xds/xds_server_rbac_test.go | 6 +++--- xds/internal/balancer/cdsbalancer/cdsbalancer_test.go | 6 +++--- .../balancer/clusterresolver/e2e_test/balancer_test.go | 2 +- 6 files changed, 13 insertions(+), 12 deletions(-) diff --git a/test/clientconn_state_transition_test.go b/test/clientconn_state_transition_test.go index d7617466401d..84957d5d96c9 100644 --- a/test/clientconn_state_transition_test.go +++ b/test/clientconn_state_transition_test.go @@ -577,7 +577,7 @@ func (s) TestConnectivityStateSubscriber(t *testing.T) { grpc.WithTransportCredentials(insecure.NewCredentials()), ) if err != nil { - t.Fatalf("NewClient() failed: %v", err) + t.Fatalf("failed to create a client for server: %v", err) } cc.Connect() // Subscribe to state updates. Use a buffer size of 1 to allow the diff --git a/test/xds/xds_client_federation_test.go b/test/xds/xds_client_federation_test.go index f94f2c182f44..382bdf97f9be 100644 --- a/test/xds/xds_client_federation_test.go +++ b/test/xds/xds_client_federation_test.go @@ -244,7 +244,7 @@ func (s) TestClientSideFederationWithOnlyXDSTPStyleLDS(t *testing.T) { // is created with a dial target containing an authority which is not specified // in the bootstrap configuration. The test verifies that RPCs on the ClientConn // fail with an appropriate error. -func (s) TestFederation_UnknownAuthorityInDialTarget(t *testing.T) { +func TestFederation_UnknownAuthorityInDialTarget(t *testing.T) { // Setting up the management server is not *really* required for this test // case. All we need is a bootstrap configuration which does not contain the // authority mentioned in the dial target. But setting up the management @@ -288,10 +288,11 @@ func (s) TestFederation_UnknownAuthorityInDialTarget(t *testing.T) { target = fmt.Sprintf("xds://unknown-authority/%s", serviceName) t.Logf("Dialing target %q with unknown authority which is expected to fail", target) wantErr := fmt.Sprintf("authority \"unknown-authority\" specified in dial target %q is not found in the bootstrap file", target) - _, err = grpc.Dial(target, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(xdsResolver)) + cc, err = grpc.NewClient(target, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(xdsResolver)) if err == nil || !strings.Contains(err.Error(), wantErr) { - t.Fatalf("grpc.Dial(%q) returned %v, want: %s", target, err, wantErr) + t.Fatalf("grpc.NewClient(%q) returned %v, want: %s", target, err, wantErr) } + defer cc.Close() } // TestFederation_UnknownAuthorityInReceivedResponse tests the case where the diff --git a/test/xds/xds_security_config_nack_test.go b/test/xds/xds_security_config_nack_test.go index 574574601aa8..8ef26b92860e 100644 --- a/test/xds/xds_security_config_nack_test.go +++ b/test/xds/xds_security_config_nack_test.go @@ -193,7 +193,7 @@ func (s) TestUnmarshalListener_WithUpdateValidatorFunc(t *testing.T) { // Create a ClientConn with the xds scheme and make an RPC. cc, err := grpc.NewClient(fmt.Sprintf("xds:///%s", serviceName), grpc.WithTransportCredentials(creds), grpc.WithResolvers(xdsResolver)) if err != nil { - t.Fatalf("NewClient() failed: %v", err) + t.Fatalf("failed to create a client for server: %v", err) } defer cc.Close() diff --git a/test/xds/xds_server_rbac_test.go b/test/xds/xds_server_rbac_test.go index a38f66e9643d..af5cfba0b486 100644 --- a/test/xds/xds_server_rbac_test.go +++ b/test/xds/xds_server_rbac_test.go @@ -247,7 +247,7 @@ func (s) TestServerSideXDS_RouteConfiguration(t *testing.T) { cc, err := grpc.NewClient(fmt.Sprintf("xds:///%s", serviceName), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(xdsResolver)) if err != nil { - t.Fatalf("NewClient() failed: %v", err) + t.Fatalf("failed to create a client for server: %v", err) } defer cc.Close() @@ -656,7 +656,7 @@ func (s) TestRBACHTTPFilter(t *testing.T) { cc, err := grpc.NewClient(fmt.Sprintf("xds:///%s", serviceName), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(xdsResolver)) if err != nil { - t.Fatalf("NewClient() failed: %v", err) + t.Fatalf("failed to create a client for server: %v", err) } defer cc.Close() @@ -838,7 +838,7 @@ func (s) TestRBACToggledOn_WithBadRouteConfiguration(t *testing.T) { cc, err := grpc.NewClient(fmt.Sprintf("xds:///%s", serviceName), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(xdsResolver)) if err != nil { - t.Fatalf("NewClient() failed: %v", err) + t.Fatalf("failed to create a client for server: %v", err) } defer cc.Close() diff --git a/xds/internal/balancer/cdsbalancer/cdsbalancer_test.go b/xds/internal/balancer/cdsbalancer/cdsbalancer_test.go index 84fb9e622d3f..0a20c3ba1e4b 100644 --- a/xds/internal/balancer/cdsbalancer/cdsbalancer_test.go +++ b/xds/internal/balancer/cdsbalancer/cdsbalancer_test.go @@ -263,7 +263,7 @@ func setupWithManagementServerAndListener(t *testing.T, lis net.Listener) (*e2e. cc, err := grpc.NewClient(r.Scheme()+":///test.service", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(r)) if err != nil { - t.Fatalf("NewClient() failed: %v", err) + t.Fatalf("failed to create a client for server: %v", err) } cc.Connect() t.Cleanup(func() { cc.Close() }) @@ -395,7 +395,7 @@ func (s) TestConfigurationUpdate_EmptyCluster(t *testing.T) { // Create a ClientConn with the above manual resolver. cc, err := grpc.NewClient(r.Scheme()+":///test.service", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(r)) if err != nil { - t.Fatalf("NewClient() failed: %v", err) + t.Fatalf("failed to create a client for server: %v", err) } cc.Connect() t.Cleanup(func() { cc.Close() }) @@ -433,7 +433,7 @@ func (s) TestConfigurationUpdate_MissingXdsClient(t *testing.T) { // Create a ClientConn with the above manual resolver. cc, err := grpc.NewClient(r.Scheme()+":///test.service", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(r)) if err != nil { - t.Fatalf("NewClient() failed: %v", err) + t.Fatalf("failed to create a client for server: %v", err) } cc.Connect() t.Cleanup(func() { cc.Close() }) diff --git a/xds/internal/balancer/clusterresolver/e2e_test/balancer_test.go b/xds/internal/balancer/clusterresolver/e2e_test/balancer_test.go index 77b73927159c..bab624c7bdec 100644 --- a/xds/internal/balancer/clusterresolver/e2e_test/balancer_test.go +++ b/xds/internal/balancer/clusterresolver/e2e_test/balancer_test.go @@ -100,7 +100,7 @@ func setupAndDial(t *testing.T, bootstrapContents []byte) (*grpc.ClientConn, fun cc, err := grpc.NewClient(r.Scheme()+":///test.service", grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(r)) if err != nil { xdsClose() - t.Fatalf("NewClient() failed: %v", err) + t.Fatalf("failed to create a client for server: %v", err) } cc.Connect() return cc, func() { From 6be3cf0b9fe28ec7606e60d443441f3ff7b6159c Mon Sep 17 00:00:00 2001 From: Vissa Janardhan Krishna Sai Date: Thu, 26 Dec 2024 13:19:49 +0000 Subject: [PATCH 4/7] revert TestFederation_UnknownAuthorityInDialTarget --- test/xds/xds_client_federation_test.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/xds/xds_client_federation_test.go b/test/xds/xds_client_federation_test.go index 382bdf97f9be..f94f2c182f44 100644 --- a/test/xds/xds_client_federation_test.go +++ b/test/xds/xds_client_federation_test.go @@ -244,7 +244,7 @@ func (s) TestClientSideFederationWithOnlyXDSTPStyleLDS(t *testing.T) { // is created with a dial target containing an authority which is not specified // in the bootstrap configuration. The test verifies that RPCs on the ClientConn // fail with an appropriate error. -func TestFederation_UnknownAuthorityInDialTarget(t *testing.T) { +func (s) TestFederation_UnknownAuthorityInDialTarget(t *testing.T) { // Setting up the management server is not *really* required for this test // case. All we need is a bootstrap configuration which does not contain the // authority mentioned in the dial target. But setting up the management @@ -288,11 +288,10 @@ func TestFederation_UnknownAuthorityInDialTarget(t *testing.T) { target = fmt.Sprintf("xds://unknown-authority/%s", serviceName) t.Logf("Dialing target %q with unknown authority which is expected to fail", target) wantErr := fmt.Sprintf("authority \"unknown-authority\" specified in dial target %q is not found in the bootstrap file", target) - cc, err = grpc.NewClient(target, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(xdsResolver)) + _, err = grpc.Dial(target, grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithResolvers(xdsResolver)) if err == nil || !strings.Contains(err.Error(), wantErr) { - t.Fatalf("grpc.NewClient(%q) returned %v, want: %s", target, err, wantErr) + t.Fatalf("grpc.Dial(%q) returned %v, want: %s", target, err, wantErr) } - defer cc.Close() } // TestFederation_UnknownAuthorityInReceivedResponse tests the case where the From f6cb17cd699d2b9bc06c196c49f5cd0ab8c2284c Mon Sep 17 00:00:00 2001 From: Vissa Janardhan Krishna Sai Date: Fri, 27 Dec 2024 06:37:43 +0000 Subject: [PATCH 5/7] updating fatal msg --- test/xds/xds_server_serving_mode_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/xds/xds_server_serving_mode_test.go b/test/xds/xds_server_serving_mode_test.go index 1f40e879e207..9a42e34888f8 100644 --- a/test/xds/xds_server_serving_mode_test.go +++ b/test/xds/xds_server_serving_mode_test.go @@ -311,7 +311,7 @@ func (s) TestServerSideXDS_ServingModeChanges(t *testing.T) { // Make sure new connection attempts to "not-serving" servers fail. if cc1, err = grpc.NewClient(lis1.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()), grpc.WithBlock()); err != nil { - t.Fatalf("failed to create a client for server: %v", err) + t.Fatal("successfully created clientConn to a server in \"not-serving\" state") } defer cc1.Close() // Update the management server with both listener resources. From 9f02ddd804f3156e454a2b121265b03fba8e5095 Mon Sep 17 00:00:00 2001 From: Vissa Janardhan Krishna Sai Date: Mon, 30 Dec 2024 14:03:30 +0000 Subject: [PATCH 6/7] replace dial with newclient --- test/goaway_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/goaway_test.go b/test/goaway_test.go index 65d2cc02d05a..0a50e8b5a6a0 100644 --- a/test/goaway_test.go +++ b/test/goaway_test.go @@ -587,12 +587,12 @@ func (s) TestGoAwayThenClose(t *testing.T) { {Addr: lis1.Addr().String()}, {Addr: lis2.Addr().String()}, }}) - cc, err := grpc.DialContext(ctx, r.Scheme()+":///", grpc.WithResolvers(r), grpc.WithTransportCredentials(insecure.NewCredentials())) + cc, err := grpc.NewClient(r.Scheme()+":///", grpc.WithResolvers(r), grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { t.Fatalf("Error creating client: %v", err) } defer cc.Close() - + cc.Connect() client := testgrpc.NewTestServiceClient(cc) t.Log("Waiting for the ClientConn to enter READY state.") @@ -672,12 +672,12 @@ func (s) TestGoAwayStreamIDSmallerThanCreatedStreams(t *testing.T) { ctCh.Send(ct) }() - cc, err := grpc.Dial(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials())) + cc, err := grpc.NewClient(lis.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { - t.Fatalf("error dialing: %v", err) + t.Fatalf("Failed to create a client: %v", err) } defer cc.Close() - + cc.Connect() ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) defer cancel() From 7fa6e5ea6ef0146ba95906807bb7591702005b98 Mon Sep 17 00:00:00 2001 From: Vissa Janardhan Krishna Sai Date: Mon, 30 Dec 2024 14:05:10 +0000 Subject: [PATCH 7/7] updating error msg --- xds/internal/balancer/cdsbalancer/cdsbalancer_security_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xds/internal/balancer/cdsbalancer/cdsbalancer_security_test.go b/xds/internal/balancer/cdsbalancer/cdsbalancer_security_test.go index 97cbaf41a562..d019c5b6f3d2 100644 --- a/xds/internal/balancer/cdsbalancer/cdsbalancer_security_test.go +++ b/xds/internal/balancer/cdsbalancer/cdsbalancer_security_test.go @@ -164,7 +164,7 @@ func setupForSecurityTests(t *testing.T, bootstrapContents []byte, clientCreds, // Create a ClientConn with the specified transport credentials. cc, err := grpc.NewClient(r.Scheme()+":///test.service", grpc.WithTransportCredentials(clientCreds), grpc.WithResolvers(r)) if err != nil { - t.Fatalf("NewClient() failed: %v", err) + t.Fatalf("failed to create a client for server: %v", err) } cc.Connect() t.Cleanup(func() { cc.Close() })