1- package config
1+ package config_test
22
33import (
44 "context"
55 "fmt"
6+ "github.com/ydb-platform/ydb-go-sdk/v3"
7+ "github.com/ydb-platform/ydb-go-sdk/v3/config"
68 "net"
79 "sync"
810 "testing"
@@ -145,11 +147,11 @@ func (d *CustomDialer) DialContext(ctx context.Context, addr string) (net.Conn,
145147 d .mu .Unlock ()
146148
147149 // Log the dial attempt
148- fmt .Printf ("Attempting to dial %s (attempt #%d)\n " , addr , attemptCount )
150+ fmt .Printf ("Attempting to dial '%s' (attempt #%d)\n " , addr , attemptCount )
149151
150152 if exists && delay > 0 {
151153 // Simulating connection delay or timeout
152- fmt .Printf ("Simulating delay of %v for %s \n " , delay , addr )
154+ fmt .Printf ("Simulating delay of %v for '%s' \n " , delay , addr )
153155
154156 select {
155157 case <- time .After (delay ):
@@ -286,21 +288,23 @@ func TestGRPCLoadBalancingPolicies(t *testing.T) {
286288 t .Logf ("Attempting to connect with %s balancing policy" , tc .balancingPolicy )
287289
288290 // Establish connection with our balancing policy
289- conn , err := grpc .DialContext (
290- ctx ,
291- "test:///unused" ,
292- grpc .WithContextDialer (dialer .DialContext ),
293- grpc .WithTransportCredentials (insecure .NewCredentials ()),
294- grpc .WithDefaultServiceConfig (fmt .Sprintf (`{"loadBalancingPolicy": "%s"}` , tc .balancingPolicy )),
295- grpc .WithBlock (),
291+ db , err := ydb .Open (ctx , "test://localhost:12345/local" , // Используем схему test: которую мы зарегистрировали для manual resolver
292+ //ydb.WithBalancer(balancers.NoDiscovery()),
293+ ydb .With (config .WithGrpcOptions (
294+ grpc .WithResolvers (r ),
295+ grpc .WithContextDialer (dialer .DialContext ),
296+ grpc .WithTransportCredentials (insecure .NewCredentials ()),
297+ grpc .WithDefaultServiceConfig (fmt .Sprintf (`{"loadBalancingPolicy": "%s"}` , tc .balancingPolicy )),
298+ //grpc.WithBlock(),
299+ )),
296300 )
297301
298302 dialDuration := time .Since (dialStart )
299303
300304 if err != nil {
301305 t .Fatalf ("Failed to dial: %v" , err )
302306 }
303- defer conn .Close ()
307+ defer db .Close (ctx )
304308
305309 // Log all dial attempts
306310 t .Logf ("Connection established in %v" , dialDuration )
@@ -310,7 +314,7 @@ func TestGRPCLoadBalancingPolicies(t *testing.T) {
310314 }
311315
312316 // Create client and make a request
313- client := NewSimpleServiceClient (conn )
317+ client := NewSimpleServiceClient (ydb . GRPCConn ( db ) )
314318 _ , err = client .Ping (context .Background (), & emptypb.Empty {})
315319 if err != nil {
316320 t .Fatalf ("Ping failed: %v" , err )
0 commit comments