Skip to content

Commit 6dcf459

Browse files
authored
Merge 1d720eb into f8b1d19
2 parents f8b1d19 + 1d720eb commit 6dcf459

File tree

10 files changed

+105
-1
lines changed

10 files changed

+105
-1
lines changed

ydb/public/tools/lib/cmds/__init__.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import typing # noqa: F401
1010
import sys
1111

12+
from ydb.library.yql.providers.common.proto.gateways_config_pb2 import TGenericConnectorConfig
1213
from ydb.tests.library.common import yatest_common
1314
from ydb.tests.library.harness.kikimr_cluster import kikimr_cluster_factory
1415
from ydb.tests.library.harness.kikimr_config import KikimrConfigGenerator
@@ -255,6 +256,24 @@ def enable_tls():
255256
return os.getenv('YDB_GRPC_ENABLE_TLS') == 'true'
256257

257258

259+
def generic_connector_config():
260+
endpoint = os.getenv("FQ_CONNECTOR_ENDPOINT")
261+
if not endpoint:
262+
return None
263+
264+
split = endpoint.split(':')
265+
if len(split) != 2:
266+
raise ValueError("Invalid FQ_CONNECTOR_ENDPOINT: '{}'".format(endpoint))
267+
268+
cfg = TGenericConnectorConfig()
269+
print(dir(cfg))
270+
cfg.Endpoint.host = split[0]
271+
cfg.Endpoint.port = int(split[1])
272+
# TODO: pass extra env variable to enable TLS
273+
cfg.UseSsl = False
274+
return cfg
275+
276+
258277
def grpc_tls_data_path(arguments):
259278
default_store = arguments.ydb_working_dir if arguments.ydb_working_dir else None
260279
return os.getenv('YDB_GRPC_TLS_DATA_PATH', default_store)
@@ -338,6 +357,7 @@ def deploy(arguments):
338357
default_users=default_users(),
339358
extra_feature_flags=enable_feature_flags,
340359
extra_grpc_services=arguments.enabled_grpc_services,
360+
generic_connector_config=generic_connector_config(),
341361
**optionals
342362
)
343363

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os
2+
3+
from ydb.public.tools.lib.cmds import generic_connector_config
4+
from ydb.library.yql.providers.common.proto.gateways_config_pb2 import TGenericConnectorConfig
5+
6+
7+
def test_kikimr_config_generator_generic_connector_config():
8+
os.environ["FQ_CONNECTOR_ENDPOINT"] = "localhost:50051"
9+
10+
expected = TGenericConnectorConfig()
11+
expected.Endpoint.host = "localhost"
12+
expected.Endpoint.port = 50051
13+
expected.UseSsl = False
14+
15+
actual = generic_connector_config()
16+
17+
assert (actual == expected)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
PY3TEST()
2+
3+
PEERDIR(
4+
ydb/public/tools/lib/cmds
5+
ydb/library/yql/providers/common/proto
6+
)
7+
8+
TEST_SRCS(
9+
test.py
10+
)
11+
12+
END()

ydb/public/tools/lib/cmds/ya.make

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,5 @@ PEERDIR(
99
)
1010

1111
END()
12+
13+
RECURSE_FOR_TESTS(ut)

ydb/public/tools/local_ydb/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
\033[94m
1010
To deploy the local YDB cluster:
1111
12-
{prog} deploy --ydb-working-dir /absolute/path/to/working/directory --ydb-binary-path /path/to/kikimr/driver
12+
{prog} deploy --ydb-working-dir /absolute/path/to/working/directory --ydb-binary-path /path/to/kikimr/driver
1313
1414
To cleanup the deployed YDB cluster (this includes removal of working directory, all configuration files, disks and so on):
1515

ydb/public/tools/local_ydb/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ PY3_PROGRAM(local_ydb)
33
PY_SRCS(__main__.py)
44

55
PEERDIR(
6+
ydb/library/yql/providers/common/proto
67
ydb/public/tools/lib/cmds
78
)
89

ydb/tests/library/harness/kikimr_config.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ def __init__(
161161
enforce_user_token_requirement=False,
162162
default_user_sid=None,
163163
pg_compatible_expirement=False,
164+
generic_connector_config=None, # typing.Optional[TGenericConnectorConfig]
164165
):
165166
if extra_feature_flags is None:
166167
extra_feature_flags = []
@@ -385,6 +386,23 @@ def __init__(
385386
self.yaml_config["feature_flags"]['enable_temp_tables'] = True
386387
self.yaml_config["feature_flags"]['enable_table_pg_types'] = True
387388

389+
if generic_connector_config:
390+
if "query_service_config" not in self.yaml_config:
391+
self.yaml_config["query_service_config"] = {}
392+
393+
self.yaml_config["query_service_config"]["generic"] = {
394+
"connector": {
395+
"endpoint": {
396+
"host": generic_connector_config.Endpoint.host,
397+
"port": generic_connector_config.Endpoint.port,
398+
},
399+
"use_ssl": generic_connector_config.UseSsl
400+
}
401+
}
402+
403+
self.yaml_config["feature_flags"]["enable_external_data_sources"] = True
404+
self.yaml_config["feature_flags"]["enable_script_execution_operations"] = True
405+
388406
@property
389407
def pdisks_info(self):
390408
return self._pdisks_info
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from ydb.tests.library.harness.kikimr_config import KikimrConfigGenerator
2+
3+
from ydb.library.yql.providers.common.proto.gateways_config_pb2 import TGenericConnectorConfig
4+
5+
6+
def test_kikimr_config_generator_generic_connector_config():
7+
generic_connector_config = TGenericConnectorConfig()
8+
generic_connector_config.Endpoint.host = "localhost"
9+
generic_connector_config.Endpoint.port = 50051
10+
generic_connector_config.UseSsl = False
11+
12+
cfg_gen = KikimrConfigGenerator(generic_connector_config=generic_connector_config)
13+
yaml_config = cfg_gen.yaml_config
14+
15+
assert (yaml_config["query_service_config"]["generic"]["connector"]["endpoint"]["host"] == generic_connector_config.Endpoint.host)
16+
assert (yaml_config["query_service_config"]["generic"]["connector"]["endpoint"]["port"] == generic_connector_config.Endpoint.port)
17+
assert (yaml_config["query_service_config"]["generic"]["connector"]["use_ssl"] == generic_connector_config.UseSsl)
18+
assert (yaml_config["feature_flags"]["enable_external_data_sources"] is True)
19+
assert (yaml_config["feature_flags"]["enable_script_execution_operations"] is True)

ydb/tests/library/ut/ya.make

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
PY3TEST()
2+
3+
PEERDIR(
4+
ydb/tests/library
5+
ydb/library/yql/providers/common/proto
6+
)
7+
8+
TEST_SRCS(
9+
kikimr_config.py
10+
)
11+
12+
END()

ydb/tests/library/ya.make

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ PEERDIR(
9595
library/python/svn_version
9696
library/python/testing/yatest_common
9797
ydb/core/protos
98+
ydb/library/yql/providers/common/proto
9899
ydb/public/api/grpc
99100
ydb/public/api/grpc/draft
100101
ydb/public/api/protos
@@ -103,3 +104,5 @@ PEERDIR(
103104
)
104105

105106
END()
107+
108+
RECURSE_FOR_TESTS(ut)

0 commit comments

Comments
 (0)