Merge "Retry DBDuplicate errors in retry decorator"
This commit is contained in:
commit
928e16c213
|
@ -37,7 +37,8 @@ MAX_RETRIES = 10
|
|||
|
||||
|
||||
def is_retriable(e):
|
||||
if _is_nested_instance(e, (db_exc.DBDeadlock, exc.StaleDataError)):
|
||||
if _is_nested_instance(e, (db_exc.DBDeadlock, exc.StaleDataError,
|
||||
db_exc.DBDuplicateEntry)):
|
||||
return True
|
||||
# looking savepoints mangled by deadlocks. see bug/1590298 for details.
|
||||
return _is_nested_instance(e, db_exc.DBError) and '1305' in str(e)
|
||||
|
|
|
@ -1701,6 +1701,20 @@ fixed_ips=ip_address%%3D%s&fixed_ips=ip_address%%3D%s&fixed_ips=subnet_id%%3D%s
|
|||
mac = port['port']['mac_address']
|
||||
self.assertTrue(mac.startswith("12:34:56:78"))
|
||||
|
||||
def test_duplicate_mac_generation(self):
|
||||
# simulate duplicate mac generation to make sure DBDuplicate is retried
|
||||
responses = ['12:34:56:78:00:00', '12:34:56:78:00:00',
|
||||
'12:34:56:78:00:01']
|
||||
with mock.patch('neutron.common.utils.get_random_mac',
|
||||
side_effect=responses) as grand_mac:
|
||||
with self.subnet() as s:
|
||||
with self.port(subnet=s) as p1, self.port(subnet=s) as p2:
|
||||
self.assertEqual('12:34:56:78:00:00',
|
||||
p1['port']['mac_address'])
|
||||
self.assertEqual('12:34:56:78:00:01',
|
||||
p2['port']['mac_address'])
|
||||
self.assertEqual(3, grand_mac.call_count)
|
||||
|
||||
def test_bad_mac_format(self):
|
||||
cfg.CONF.set_override('base_mac', "bad_mac")
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue