userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
__init__.py
1
"""
2
Plugin that imports the required fixtures to start the broker.
3
"""
4
5
import
logging
6
import
os
7
8
import
pytest
9
10
from
testsuite.databases.kafka.classes
import
BootstrapServers
11
12
pytest_plugins = [
13
'testsuite.databases.kafka.pytest_plugin'
,
14
'pytest_userver.plugins.core'
,
15
]
16
17
18
# @cond
19
20
21
@pytest.fixture(scope='session')
22
def
_patched_bootstrap_servers_internal() -> BootstrapServers:
23
"""Used for internal testing purposes"""
24
25
brokers_list = os.getenv(
'KAFKA_RECIPE_BROKER_LIST'
)
26
if
brokers_list:
27
return
brokers_list.split(
','
)
28
29
return
[]
30
31
32
# @endcond
33
34
35
@pytest.fixture(scope='session')
36
def
kafka_components
() -> list[str]:
37
"""
38
Should contain manually listed names of kafka producer and consumer
39
components.
40
41
@ingroup userver_testsuite_fixtures
42
"""
43
44
return
[]
45
46
47
@pytest.fixture(scope='session')
48
def
kafka_secdist
(_bootstrap_servers, kafka_components) -> dict:
49
"""
50
Automatically generates secdist config from user static config.
51
`_bootstrap_servers` is testsuite's fixture that determines current
52
bootstrap servers list depends on Kafka testsuite plugin's settings.
53
54
@snippet samples/kafka_service/testsuite/conftest.py Kafka service sample - secdist
55
56
@ingroup userver_testsuite_fixtures
57
"""
58
59
single_setting = {
60
'brokers'
: _bootstrap_servers,
61
'username'
:
''
,
62
'password'
:
''
,
63
}
64
logging.info(f
'Kafka brokers are: {single_setting["brokers"]}'
)
65
66
return
{
67
'kafka_settings'
: {component_name: single_setting
for
component_name
in
kafka_components},
68
}
testsuite
pytest_plugins
pytest_userver
plugins
kafka
__init__.py
Generated on
for userver by
Doxygen
1.17.0