1import json
2from typing import List
3
4import pytest
5
6
7
8pytest_plugins = ['pytest_userver.plugins.kafka']
9
10
11
12
13
14@pytest.fixture(scope='session')
15def kafka_components() -> List[str]:
16 return ['kafka-consumer', 'kafka-producer']
17
18
19@pytest.fixture(scope='session')
20def service_env(kafka_secdist) -> dict:
21 """
22 Note: kafka_secist fixture generates the secdist config
23
24 Expected secdist format is:
25 "kafka_settings": {
26 "<kafka-component-name>": {
27 "brokers": "<brokers comma-separated endpoint list>",
28 "username": "SASL2 username (may be empty if use PLAINTEXT)",
29 "password": "SASL2 password (may be empty if use PLAINTEXT)"
30 }
31 }
32 """
33
34 return {'SECDIST_CONFIG': json.dumps(kafka_secdist)}
35
36
37
38@pytest.fixture(scope='session')
39def kafka_local(_patched_bootstrap_servers_internal):
40 """
41 Note: Should not be used, if using basic Kafka testsuite plugin.
42
43 kafka_local is testsuite's fixture that is redefined
44 to use custom Kafka cluster,
45 but with kafka_producer and kafka_consumer fixtures.
46 Here is only needed for internal testing purposes.
47 """
48 return _patched_bootstrap_servers_internal