Merge "Fixed bug in object replicator"
This commit is contained in:
commit
d69509a779
@ -564,7 +564,10 @@ class ObjectReplicator(Daemon):
|
||||
continue
|
||||
unlink_older_than(tmp_path, time.time() - self.reclaim_age)
|
||||
if not os.path.exists(obj_path):
|
||||
mkdirs(obj_path)
|
||||
try:
|
||||
mkdirs(obj_path)
|
||||
except Exception, err:
|
||||
self.logger.exception('ERROR creating %s' % obj_path)
|
||||
continue
|
||||
for partition in os.listdir(obj_path):
|
||||
try:
|
||||
|
@ -397,6 +397,28 @@ class TestObjectReplicator(unittest.TestCase):
|
||||
self.replicator.next_check = orig_check - 30
|
||||
self.assertFalse(self.replicator.check_ring())
|
||||
|
||||
def test_collect_jobs_mkdirs_error(self):
|
||||
|
||||
def blowup_mkdirs(path):
|
||||
raise OSError('Ow!')
|
||||
|
||||
mkdirs_orig = object_replicator.mkdirs
|
||||
try:
|
||||
rmtree(self.objects, ignore_errors=1)
|
||||
object_replicator.mkdirs = blowup_mkdirs
|
||||
jobs = self.replicator.collect_jobs()
|
||||
self.assertTrue('exception' in self.replicator.logger.log_dict)
|
||||
self.assertEquals(
|
||||
len(self.replicator.logger.log_dict['exception']), 1)
|
||||
exc_args, exc_kwargs, exc_str = \
|
||||
self.replicator.logger.log_dict['exception'][0]
|
||||
self.assertEquals(len(exc_args), 1)
|
||||
self.assertTrue(exc_args[0].startswith('ERROR creating '))
|
||||
self.assertEquals(exc_kwargs, {})
|
||||
self.assertEquals(exc_str, 'Ow!')
|
||||
finally:
|
||||
object_replicator.mkdirs = mkdirs_orig
|
||||
|
||||
def test_collect_jobs(self):
|
||||
jobs = self.replicator.collect_jobs()
|
||||
jobs_to_delete = [j for j in jobs if j['delete']]
|
||||
|
Loading…
x
Reference in New Issue
Block a user