Skip to content

Commit bc4896f

Browse files
committed
Added common TestUtils
1 parent 264be14 commit bc4896f

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

tests/common/__init__.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,23 @@
2424
_TRIVUP_CLUSTER_TYPE_ENV = 'TEST_TRIVUP_CLUSTER_TYPE'
2525

2626

27-
def _trivup_cluster_type_kraft():
28-
return _TRIVUP_CLUSTER_TYPE_ENV in os.environ and os.environ[_TRIVUP_CLUSTER_TYPE_ENV] == 'kraft'
29-
27+
def _update_conf_group_protocol(conf=None):
28+
if conf is not None and 'group.id' in conf and TestUtils.use_group_protocol_consumer():
29+
conf['group.protocol'] = 'consumer'
3030

31-
def use_group_protocol_consumer():
32-
return _GROUP_PROTOCOL_ENV in os.environ and os.environ[_GROUP_PROTOCOL_ENV] == 'consumer'
3331

32+
def _trivup_cluster_type_kraft():
33+
return _TRIVUP_CLUSTER_TYPE_ENV in os.environ and os.environ[_TRIVUP_CLUSTER_TYPE_ENV] == 'kraft'
3434

35-
def use_kraft():
36-
return use_group_protocol_consumer() or _trivup_cluster_type_kraft()
3735

36+
class TestUtils:
37+
@staticmethod
38+
def use_kraft():
39+
return TestUtils.use_group_protocol_consumer() or _trivup_cluster_type_kraft()
3840

39-
def _update_conf_group_protocol(conf=None):
40-
if conf is not None and 'group.id' in conf and use_group_protocol_consumer():
41-
conf['group.protocol'] = 'consumer'
41+
@staticmethod
42+
def use_group_protocol_consumer():
43+
return _GROUP_PROTOCOL_ENV in os.environ and os.environ[_GROUP_PROTOCOL_ENV] == 'consumer'
4244

4345

4446
class TestConsumer(Consumer):

tests/integration/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#
1818

1919
import os
20-
from ..common import use_group_protocol_consumer, use_kraft
20+
from ..common import TestUtils
2121
import pytest
2222

2323
from tests.integration.cluster_fixture import TrivupFixture
@@ -29,7 +29,7 @@
2929
def _broker_conf():
3030
broker_conf = ['transaction.state.log.replication.factor=1',
3131
'transaction.state.log.min.isr=1']
32-
if use_group_protocol_consumer():
32+
if TestUtils.use_group_protocol_consumer():
3333
broker_conf.append('group.coordinator.rebalance.protocols=classic,consumer')
3434
return broker_conf
3535

@@ -38,7 +38,7 @@ def create_trivup_cluster(conf={}):
3838
trivup_fixture_conf = {'with_sr': True,
3939
'debug': True,
4040
'cp_version': '7.6.0',
41-
'kraft': use_kraft(),
41+
'kraft': TestUtils.use_kraft(),
4242
'version': 'trunk',
4343
'broker_conf': _broker_conf()}
4444
trivup_fixture_conf.update(conf)
@@ -49,7 +49,7 @@ def create_sasl_cluster(conf={}):
4949
trivup_fixture_conf = {'with_sr': False,
5050
'version': 'trunk',
5151
'sasl_mechanism': "PLAIN",
52-
'kraft': use_kraft(),
52+
'kraft': TestUtils.use_kraft(),
5353
'sasl_users': 'sasl_user=sasl_user',
5454
'debug': True,
5555
'cp_version': 'latest',

0 commit comments

Comments
 (0)