Skip to content

Commit bc56fcf

Browse files
authored
Merge pull request #827 from ydb-platform/23-3
23.3 integration tests
2 parents 2ed2056 + f8db069 commit bc56fcf

File tree

4 files changed

+36
-13
lines changed

4 files changed

+36
-13
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
fail-fast: false
4646
matrix:
4747
go-version: [1.17.x, 1.20.x, 1.21.x]
48-
ydb-version: [22.5, 23.1, 23.2, 23.2-slim]
48+
ydb-version: [22.5, 23.1, 23.2, 23.3]
4949
services:
5050
ydb:
5151
image: cr.yandex/yc/yandex-docker-local-ydb:${{ matrix.ydb-version }}

tests/integration/database_sql_static_credentials_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818

1919
"github.com/ydb-platform/ydb-go-sdk/v3"
2020
"github.com/ydb-platform/ydb-go-sdk/v3/credentials"
21+
"github.com/ydb-platform/ydb-go-sdk/v3/internal/version"
2122
)
2223

2324
func TestDatabaseSqlStaticCredentials(t *testing.T) {
@@ -36,7 +37,11 @@ func TestDatabaseSqlStaticCredentials(t *testing.T) {
3637
t.Fatal(err)
3738
}
3839

39-
u.User = url.UserPassword("root", "")
40+
if version.Gte(os.Getenv("YDB_VERSION"), "23.3") {
41+
u.User = url.UserPassword("root", "1234")
42+
} else {
43+
u.User = url.User("root")
44+
}
4045

4146
t.Run("sql.Open", func(t *testing.T) {
4247
var db *sql.DB
@@ -53,7 +58,10 @@ func TestDatabaseSqlStaticCredentials(t *testing.T) {
5358
t.Run("sql.OpenDB", func(t *testing.T) {
5459
var cc *ydb.Driver
5560
cc, err = ydb.Open(ctx, os.Getenv("YDB_CONNECTION_STRING"),
56-
ydb.WithCredentials(credentials.NewStaticCredentials("root", "", u.Host, func() grpc.DialOption {
61+
ydb.WithCredentials(credentials.NewStaticCredentials(u.User.Username(), func() string {
62+
password, _ := u.User.Password()
63+
return password
64+
}(), u.Host, func() grpc.DialOption {
5765
if u.Scheme == "grpcs" { //nolint:goconst
5866
transportCredentials, transportCredentialsErr := grpcCredentials.NewClientTLSFromFile(
5967
os.Getenv("YDB_SSL_ROOT_CERTIFICATES_FILE"), u.Hostname(),
@@ -64,7 +72,8 @@ func TestDatabaseSqlStaticCredentials(t *testing.T) {
6472
return grpc.WithTransportCredentials(transportCredentials)
6573
}
6674
return grpc.WithTransportCredentials(insecure.NewCredentials())
67-
}())))
75+
}())),
76+
)
6877
require.NoError(t, err)
6978

7079
defer func() {

tests/integration/kv_test.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ func TestKeyValue(t *testing.T) {
4040

4141
// get
4242
err = driver.Table().Do(scope.Ctx, func(ctx context.Context, s table.Session) error {
43-
rows, err := s.ReadRows(ctx, tablePath, types.ListValue(types.Int64Value(id)),
43+
rows, err := s.ReadRows(ctx, tablePath,
44+
types.ListValue(types.StructValue(
45+
types.StructFieldValue("id", types.Int64Value(id)),
46+
)),
4447
options.ReadColumn("val"),
4548
)
4649
if err != nil {
@@ -49,10 +52,10 @@ func TestKeyValue(t *testing.T) {
4952
defer func() {
5053
_ = rows.Close()
5154
}()
52-
if !rows.HasNextResultSet() {
55+
if !rows.NextResultSet(ctx) {
5356
return fmt.Errorf("no result sets")
5457
}
55-
if !rows.HasNextRow() {
58+
if !rows.NextRow() {
5659
return fmt.Errorf("no rows")
5760
}
5861
if rows.CurrentResultSet().RowCount() != 1 {
@@ -61,10 +64,11 @@ func TestKeyValue(t *testing.T) {
6164
if rows.CurrentResultSet().ColumnCount() != 1 {
6265
return fmt.Errorf("wrong column count (%d)", rows.CurrentResultSet().ColumnCount())
6366
}
64-
var actualValue int64
65-
if err := rows.ScanNamed(named.Optional("val", &actualValue)); err != nil {
67+
var actualValue string
68+
if err := rows.ScanNamed(named.OptionalWithDefault("val", &actualValue)); err != nil {
6669
return err
6770
}
71+
t.Logf("%s[%d] = %q", tablePath, id, actualValue)
6872
return rows.Err()
6973
})
7074
scope.Require.NoError(err)

tests/integration/static_credentials_test.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717

1818
"github.com/ydb-platform/ydb-go-sdk/v3"
1919
"github.com/ydb-platform/ydb-go-sdk/v3/credentials"
20+
"github.com/ydb-platform/ydb-go-sdk/v3/internal/version"
2021
)
2122

2223
func TestStaticCredentials(t *testing.T) {
@@ -30,15 +31,24 @@ func TestStaticCredentials(t *testing.T) {
3031
dsn = v
3132
}
3233

33-
url, err := url.Parse(dsn)
34+
u, err := url.Parse(dsn)
3435
if err != nil {
3536
t.Fatal(err)
3637
}
3738

38-
staticCredentials := credentials.NewStaticCredentials("root", "", url.Host, func() grpc.DialOption {
39-
if url.Scheme == "grpcs" {
39+
if version.Gte(os.Getenv("YDB_VERSION"), "23.3") {
40+
u.User = url.UserPassword("root", "1234")
41+
} else {
42+
u.User = url.User("root")
43+
}
44+
45+
staticCredentials := credentials.NewStaticCredentials(u.User.Username(), func() string {
46+
password, _ := u.User.Password()
47+
return password
48+
}(), u.Host, func() grpc.DialOption {
49+
if u.Scheme == "grpcs" {
4050
transportCredentials, transportCredentialsErr := grpcCredentials.NewClientTLSFromFile(
41-
os.Getenv("YDB_SSL_ROOT_CERTIFICATES_FILE"), url.Hostname(),
51+
os.Getenv("YDB_SSL_ROOT_CERTIFICATES_FILE"), u.Hostname(),
4252
)
4353
if err != nil {
4454
t.Fatalf("cannot create transport credentials: %v", transportCredentialsErr)

0 commit comments

Comments
 (0)