userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
service.py
1
import
pathlib
2
import
typing
3
4
from
testsuite.environment
import
service, utils
5
6
from
.
import
connection
7
8
DEFAULT_PORT = 15433
9
10
PLUGIN_DIR = pathlib.Path(__file__).parent
11
CONFIGS_DIR = PLUGIN_DIR.joinpath(
'configs'
)
12
SCRIPTS_DIR = PLUGIN_DIR.joinpath(
'scripts'
)
13
14
15
class
ServiceSettings
(typing.NamedTuple):
16
port: int
17
18
def
get_conninfo(self) -> connection.PgConnectionInfo:
19
return
connection.PgConnectionInfo
(
20
host=
'localhost'
,
21
port=self.port,
22
user=
'testsuite'
,
23
)
24
25
26
def
get_service_settings():
27
return
ServiceSettings
(
28
utils.getenv_int(
29
key=
'TESTSUITE_POSTGRESQL_PORT'
,
30
default=DEFAULT_PORT,
31
),
32
)
33
34
35
def
create_pgsql_service(
36
service_name,
37
working_dir,
38
settings: ServiceSettings |
None
=
None
,
39
env=
None
,
40
):
41
if
settings
is
None
:
42
settings = get_service_settings()
43
44
return
service.ScriptService
(
45
service_name=service_name,
46
script_path=str(SCRIPTS_DIR.joinpath(
'service-postgresql'
)),
47
working_dir=working_dir,
48
environment={
49
'POSTGRESQL_TMPDIR'
: working_dir,
50
'POSTGRESQL_CONFIGS_DIR'
: str(CONFIGS_DIR),
51
'POSTGRESQL_PORT'
: str(settings.port),
52
**(env
or
{}),
53
},
54
check_ports=[settings.port],
55
)
en
testsuite
databases
pgsql
service.py
Generated on
for userver by
Doxygen
1.17.0