Fix InfluxdbClientError exception bug
InfluxdbClientError has content attribute no message attribute. Message attribute deprecated in Python 2.6 and it's go away in Python 3.0 Change-Id: I5fe4bcb018a7c8c99df29d9798aa0e2736f33b6f Story: 2005900 Task: 33762
This commit is contained in:
parent
b88084003f
commit
c78d5ebc43
@ -47,13 +47,13 @@ class Persister(six.with_metaclass(ABCMeta, object)):
|
||||
self._data_points = []
|
||||
self._consumer.commit()
|
||||
except Exception as ex:
|
||||
if "partial write: points beyond retention policy dropped" in ex.message:
|
||||
if "partial write: points beyond retention policy dropped" in str(ex):
|
||||
LOG.warning("Some points older than retention policy were dropped")
|
||||
self._data_points = []
|
||||
self._consumer.commit()
|
||||
|
||||
elif cfg.CONF.repositories.ignore_parse_point_error \
|
||||
and "unable to parse" in ex.message:
|
||||
and "unable to parse" in str(ex):
|
||||
LOG.warning("Some points were unable to be parsed and were dropped")
|
||||
self._data_points = []
|
||||
self._consumer.commit()
|
||||
|
@ -108,14 +108,13 @@ class TestPersisterRepo(base.BaseTestCase):
|
||||
mock_consumer.commit.assert_called()
|
||||
self.assertEqual([], self.persister._data_points)
|
||||
|
||||
@patch.object(LOG, 'info', side_effect=FakeException())
|
||||
def test_flush_logs_warning_and_exception(self, mock_log_info):
|
||||
def test_flush_logs_warning_and_exception(self):
|
||||
exception_msgs = ['partial write: points beyond retention policy dropped',
|
||||
'unable to parse points']
|
||||
'unable to parse']
|
||||
with(patch.object(cfg.CONF.repositories, 'ignore_parse_point_error',
|
||||
return_value=True)):
|
||||
for elem in exception_msgs:
|
||||
mock_log_info.side_effect.message = elem
|
||||
with patch.object(LOG, 'info', side_effect=FakeException(elem)):
|
||||
self.persister._data_points = ['some']
|
||||
self.persister._flush()
|
||||
self.mock_log_warning.assert_called()
|
||||
|
Loading…
x
Reference in New Issue
Block a user