Changeset View
Changeset View
Standalone View
Standalone View
swh/journal/tests/conftest.py
Show First 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | |||||
@pytest.fixture(scope='function') | @pytest.fixture(scope='function') | ||||
def kafka_prefix(): | def kafka_prefix(): | ||||
return ''.join(random.choice(string.ascii_lowercase) for _ in range(10)) | return ''.join(random.choice(string.ascii_lowercase) for _ in range(10)) | ||||
TEST_CONFIG = { | TEST_CONFIG = { | ||||
'temporary_prefix': 'swh.tmp_journal.new', | 'temporary_prefix': 'swh.tmp_journal.new', | ||||
'final_prefix': 'swh.journal.objects', | 'final_prefix': 'swh.journal.objects', | ||||
'consumer_id': 'swh.journal.publisher', | 'consumer_id': 'swh.journal.consumer', | ||||
'publisher_id': 'swh.journal.publisher', | |||||
'object_types': OBJECT_TYPE_KEYS.keys(), | 'object_types': OBJECT_TYPE_KEYS.keys(), | ||||
'max_messages': 1, # will read 1 message and stops | 'max_messages': 1, # will read 1 message and stops | ||||
'storage': {'cls': 'memory', 'args': {}}, | 'storage': {'cls': 'memory', 'args': {}}, | ||||
} | } | ||||
@pytest.fixture | @pytest.fixture | ||||
def test_config(kafka_server: Tuple[Popen, int], | def test_config(kafka_server: Tuple[Popen, int], | ||||
kafka_prefix: str): | kafka_prefix: str): | ||||
"""Test configuration needed for publisher/producer/consumer | """Test configuration needed for producer/consumer | ||||
""" | """ | ||||
_, port = kafka_server | _, port = kafka_server | ||||
return { | return { | ||||
**TEST_CONFIG, | **TEST_CONFIG, | ||||
'brokers': ['localhost:{}'.format(port)], | 'brokers': ['localhost:{}'.format(port)], | ||||
'temporary_prefix': kafka_prefix + '.swh.tmp_journal.new', | 'temporary_prefix': kafka_prefix + '.swh.tmp_journal.new', | ||||
'final_prefix': kafka_prefix + '.swh.journal.objects', | 'final_prefix': kafka_prefix + '.swh.journal.objects', | ||||
Show All 31 Lines |