From 18d039a893d85821a0215a96fe15c95b2d60f06d Mon Sep 17 00:00:00 2001 From: Prashanth Pai Date: Thu, 9 Jul 2015 12:23:43 +0530 Subject: [PATCH] read_metadata() consumers should catch IOError The xattr module raises IOError which is what the call to read_metadata() in rmobjdir() should be catching. Change-Id: I2983ad0be453647f80b862eea93a5fc16fcef04a Signed-off-by: Prashanth Pai --- swiftonfile/swift/common/utils.py | 2 +- test/unit/common/test_utils.py | 10 ++++++---- tox.ini | 1 - 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/swiftonfile/swift/common/utils.py b/swiftonfile/swift/common/utils.py index cb0d56b..4c9df77 100644 --- a/swiftonfile/swift/common/utils.py +++ b/swiftonfile/swift/common/utils.py @@ -311,7 +311,7 @@ def rmobjdir(dir_path): try: metadata = read_metadata(fullpath) - except OSError as err: + except IOError as err: if err.errno == errno.ENOENT: # Ignore removal from another entity. continue diff --git a/test/unit/common/test_utils.py b/test/unit/common/test_utils.py index 54c0a12..dd1872a 100644 --- a/test/unit/common/test_utils.py +++ b/test/unit/common/test_utils.py @@ -27,7 +27,8 @@ import shutil from collections import defaultdict from mock import patch from swiftonfile.swift.common import utils -from swiftonfile.swift.common.exceptions import SwiftOnFileSystemOSError +from swiftonfile.swift.common.exceptions import SwiftOnFileSystemOSError, \ + SwiftOnFileSystemIOError from swift.common.exceptions import DiskFileNoSpace # @@ -579,7 +580,8 @@ class TestUtilsDirObjects(unittest.TestCase): def _mock_rm(path): print "_mock_rm-metadata_enoent(%s)" % path shutil.rmtree(path) - raise OSError(errno.ENOENT, os.strerror(errno.ENOENT)) + raise SwiftOnFileSystemIOError(errno.ENOENT, + os.strerror(errno.ENOENT)) # Remove the files for f in self.files: @@ -590,8 +592,8 @@ class TestUtilsDirObjects(unittest.TestCase): try: try: self.assertTrue(utils.rmobjdir(self.rootdir)) - except OSError: - self.fail("Unexpected OSError") + except IOError: + self.fail("Unexpected IOError") else: pass finally: diff --git a/tox.ini b/tox.ini index 163ca6a..4a729a4 100644 --- a/tox.ini +++ b/tox.ini @@ -35,7 +35,6 @@ setenv = VIRTUAL_ENV={envdir} NOSE_COVER_HTML_DIR={toxinidir}/cover [tox:jenkins] -# Commented as workaround for PyECLib issue downloadcache = ~/cache/pip # To be used by Jenkins