Py3: Fix encoding in _verify_topics method
Change-Id: I18c649b1880b52f5961e3dee18c3c9aef3afdde9
This commit is contained in:
parent
3f530c85e8
commit
c8c5217af0
@ -14,6 +14,7 @@
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
from six import PY3
|
||||
|
||||
from monasca_api.healthcheck import base
|
||||
from monasca_common.kafka_lib import client
|
||||
@ -59,6 +60,8 @@ class KafkaHealthCheck(base.BaseHealthCheck):
|
||||
topics = (CONF.kafka.metrics_topic,
|
||||
CONF.kafka.events_topic,
|
||||
CONF.kafka.alarm_state_transitions_topic)
|
||||
if PY3:
|
||||
topics = tuple(topic.encode('utf-8') for topic in topics)
|
||||
|
||||
for topic in topics:
|
||||
topic_exists = topic in kafka_client.topics
|
||||
|
@ -13,6 +13,7 @@
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
from six import PY3
|
||||
|
||||
from monasca_common.kafka_lib import client
|
||||
|
||||
@ -26,14 +27,15 @@ CONF = config.CONF
|
||||
class TestKafkaHealthCheckLogic(base.BaseTestCase):
|
||||
|
||||
mock_kafka_url = 'localhost:1234'
|
||||
mocked_topics = 'test1'
|
||||
mocked_event_topic = 'test2'
|
||||
mocked_alarm_state_topic = 'test3'
|
||||
mocked_topics = b'test1'
|
||||
mocked_event_topic = b'test2'
|
||||
mocked_alarm_state_topic = b'test3'
|
||||
mocked_config = {
|
||||
'uri': mock_kafka_url,
|
||||
'metrics_topic': mocked_topics,
|
||||
'events_topic': mocked_event_topic,
|
||||
'alarm_state_transitions_topic': mocked_alarm_state_topic
|
||||
'metrics_topic': mocked_topics.decode('utf-8') if PY3 else mocked_topics,
|
||||
'events_topic': mocked_event_topic.decode('utf-8') if PY3 else mocked_event_topic,
|
||||
'alarm_state_transitions_topic':
|
||||
mocked_alarm_state_topic.decode('utf-8') if PY3 else mocked_alarm_state_topic
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
Loading…
Reference in New Issue
Block a user