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