Merge "Fixes unique constraint regex"
This commit is contained in:
commit
9272cf4742
@ -28,7 +28,7 @@ from marconi.openstack.common import timeutils
|
|||||||
from marconi.storage import exceptions as storage_exceptions
|
from marconi.storage import exceptions as storage_exceptions
|
||||||
|
|
||||||
|
|
||||||
DUP_MARKER_REGEX = re.compile(r'\$queue_marker\s+dup key: { : [^:]+: (\d)+')
|
DUP_MARKER_REGEX = re.compile(r'\$queue_marker.*?:\s(\d+)')
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -42,13 +42,13 @@ def dup_marker_from_error(error_message):
|
|||||||
:raises: marconi.common.exceptions.PatternNotFound
|
:raises: marconi.common.exceptions.PatternNotFound
|
||||||
:returns: extracted marker as an integer
|
:returns: extracted marker as an integer
|
||||||
"""
|
"""
|
||||||
match = DUP_MARKER_REGEX.search(error_message)
|
match = DUP_MARKER_REGEX.findall(error_message)
|
||||||
if match is None:
|
if not match:
|
||||||
description = ('Error message could not be parsed: %s' %
|
description = ('Error message could not be parsed: %s' %
|
||||||
error_message)
|
error_message)
|
||||||
raise exceptions.PatternNotFound(description)
|
raise exceptions.PatternNotFound(description)
|
||||||
|
|
||||||
return int(match.groups()[0])
|
return int(match[-1])
|
||||||
|
|
||||||
|
|
||||||
def cached_gen(iterable):
|
def cached_gen(iterable):
|
||||||
|
@ -37,14 +37,14 @@ class MongodbUtilsTest(testing.TestBase):
|
|||||||
def test_dup_marker_from_error(self):
|
def test_dup_marker_from_error(self):
|
||||||
error_message = ('E11000 duplicate key error index: '
|
error_message = ('E11000 duplicate key error index: '
|
||||||
'marconi.messages.$queue_marker dup key: '
|
'marconi.messages.$queue_marker dup key: '
|
||||||
'{ : ObjectId("51adff46b100eb85d8a93a2d"), : 3 }')
|
'{ : "queue", : "project", : 3 }')
|
||||||
|
|
||||||
marker = utils.dup_marker_from_error(error_message)
|
marker = utils.dup_marker_from_error(error_message)
|
||||||
self.assertEquals(marker, 3)
|
self.assertEquals(marker, 3)
|
||||||
|
|
||||||
error_message = ('E11000 duplicate key error index: '
|
error_message = ('E11000 duplicate key error index: '
|
||||||
'marconi.messages.$x_y dup key: '
|
'marconi.messages.$x_y dup key: '
|
||||||
'{ : ObjectId("51adff46b100eb85d8a93a2d"), : 3 }')
|
'{ : "queue", : "project", : 3 }')
|
||||||
|
|
||||||
self.assertRaises(exceptions.PatternNotFound,
|
self.assertRaises(exceptions.PatternNotFound,
|
||||||
utils.dup_marker_from_error, error_message)
|
utils.dup_marker_from_error, error_message)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user