6from testsuite.environment
import service
7from testsuite.environment
import utils
9DEFAULT_HOST =
'localhost'
10DEFAULT_GRPC_TLS_PORT = 2135
11DEFAULT_GRPC_PORT = 2136
12DEFAULT_MON_PORT = 8765
13DEFAULT_DATABASE =
'local'
14DEFAULT_CONTAINER_NAME =
'ydb-local-testsuite'
15DEFAULT_DOCKER_IMAGE =
'cr.yandex/yc/yandex-docker-local-ydb:latest'
17PLUGIN_DIR = pathlib.Path(__file__).parent
18SCRIPTS_DIR = PLUGIN_DIR.joinpath(
'scripts')
21@dataclasses.dataclass(frozen=True)
30def create_ydb_service(
33 settings: typing.Optional[ServiceSettings] =
None,
34 env: typing.Optional[typing.Dict[str, str]] =
None,
37 settings = get_service_settings()
38 return service.ScriptService(
39 service_name=service_name,
40 script_path=str(SCRIPTS_DIR.joinpath(
'service-ydb')),
41 working_dir=working_dir,
43 'YDB_TMPDIR': working_dir,
44 'YDB_SCRIPTS_DIR': str(SCRIPTS_DIR),
45 'YDB_HOSTNAME': settings.host,
46 'YDB_GRPC_PORT': str(settings.grpc_port),
47 'YDB_GRPC_TLS_PORT': str(DEFAULT_GRPC_TLS_PORT),
48 'YDB_MON_PORT': str(settings.mon_port),
49 'YDB_CONTAINER_NAME': DEFAULT_CONTAINER_NAME,
50 'YDB_DOCKER_IMAGE': DEFAULT_DOCKER_IMAGE,
53 check_ports=[settings.grpc_port, settings.mon_port],
57def get_service_settings():
59 host=os.getenv(
'TESTSUITE_YDB_HOST', DEFAULT_HOST),
60 grpc_port=utils.getenv_int(
61 'TESTSUITE_YDB_GRPC_PORT', DEFAULT_GRPC_PORT,
63 mon_port=utils.getenv_int(
'TESTSUITE_YDB_MON_PORT', DEFAULT_MON_PORT),
64 ic_port=utils.getenv_int(
'TESTSUITE_YDB_IC_PORT', 0),
65 database=os.getenv(
'TESTSUITE_YDB_DATABASE', DEFAULT_DATABASE),