Skip to content

Commit

Permalink
Reproducing YDB SDK bug - no success
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalyisaev2 committed Oct 14, 2024
1 parent 3210559 commit 017e814
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions tools/ydb/query_service_negative/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,31 @@ import (
)

const (
dbName = "/local"
tableName = "simple"
endpoint = "grpc://localhost:2136"
dbEndpoint = "localhost:2136"
dbName = "/local"
tableName = "simple"
)

func main() {
log.Println("Correct credentials")
obtainTableDesciption("admin", "password")
obtainTableDesciption(dbEndpoint, "admin", "password")

log.Println("Invalid credentials")
obtainTableDesciption(dbEndpoint, "admin2", "password")
}

func obtainTableDesciption(login, password string) {
ydbDriver, err := makeDriver(login, password)
func obtainTableDesciption(endpoint, login, password string) {
ydbDriver, err := makeDriver(endpoint, login, password)
if err != nil {
log.Fatal(err)
}

defer func() {
if err := ydbDriver.Close(context.Background()); err != nil {

Check failure on line 40 in tools/ydb/query_service_negative/main.go

View workflow job for this annotation

GitHub Actions / lint

shadow: declaration of "err" shadows declaration at line 34 (govet)
log.Fatal(err)
}
}()

desc, err := getTableDescription(ydbDriver)
if err != nil {
log.Fatal(err)
Expand All @@ -41,15 +50,15 @@ func obtainTableDesciption(login, password string) {
log.Printf("Table description: %+v", desc)
}

func makeDriver(login, password string) (*ydb.Driver, error) {
func makeDriver(endpoint, login, password string) (*ydb.Driver, error) {
ydbOptions := []ydb.Option{
ydb.WithStaticCredentials(login, password),
ydb.WithDialTimeout(5 * time.Second),
ydb.WithBalancer(balancers.SingleConn()), // see YQ-3089
ydb.With(config.WithGrpcOptions(grpc.WithDisableServiceConfig())),
}

dsn := sugar.DSN("localhost:2136", dbName, false)
dsn := sugar.DSN(endpoint, dbName, false)

ydbDriver, err := ydb.Open(context.Background(), dsn, ydbOptions...)
if err != nil {
Expand Down

0 comments on commit 017e814

Please sign in to comment.