Skip to content

Commit abe5069

Browse files
committed
add test for check many attempts on cluster discovery step
1 parent 7a8d1a6 commit abe5069

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

connection_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"context"
88
"errors"
99
"fmt"
10+
"github.com/ydb-platform/ydb-go-sdk/v3/trace"
1011
"testing"
1112
"time"
1213

@@ -61,3 +62,26 @@ func TestZeroDialTimeout(t *testing.T) {
6162
require.Nil(t, db)
6263
require.True(t, errors.Is(err, context.DeadlineExceeded) || ydb.IsTransportError(err, grpcCodes.DeadlineExceeded))
6364
}
65+
66+
func TestClusterDiscoveryRetry(t *testing.T) {
67+
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
68+
defer cancel()
69+
70+
counter := 0
71+
72+
db, err := ydb.Open(ctx,
73+
"grpc://non-existent.com:2135/some",
74+
ydb.WithDialTimeout(time.Second),
75+
ydb.WithTraceDriver(trace.Driver{
76+
OnBalancerUpdate: func(info trace.DriverBalancerUpdateStartInfo) func(trace.DriverBalancerUpdateDoneInfo) {
77+
counter++
78+
return nil
79+
},
80+
}),
81+
)
82+
t.Logf("attempts: %d", counter)
83+
require.Error(t, err)
84+
require.Nil(t, db)
85+
require.True(t, errors.Is(err, context.DeadlineExceeded) || ydb.IsTransportError(err, grpcCodes.DeadlineExceeded))
86+
require.Greater(t, counter, 1)
87+
}

0 commit comments

Comments
 (0)