diff options
author | Luis Pabon <lpabon@redhat.com> | 2013-11-20 15:51:55 -0500 |
---|---|---|
committer | Luis Pabon <lpabon@redhat.com> | 2013-11-21 05:06:33 -0800 |
commit | b46dc3ae9c500ec64b9a7f00c804152fa8e67ef8 (patch) | |
tree | ad5ae27195034415f466b2f7602e346dc1091c26 /test | |
parent | 3f504879c4a41fa688e5f3d336c8f5f9f9d3f49a (diff) |
Log only non-ENOENT errors in diskfile
DiskFile.open() gets called for every PUT. The expected sideeffect
is that if the file exists, the metadata in the object will be
populated.
DiskFile.open() was logging any errors it detected while trying
to open() the file. Issue is that when we PUT a new file, there
is no entry, and open() will return an error. The was incorrectly
logging each one of these errors.
Change-Id: I7d721df177761066fdaa46d278fff2d779924999
Signed-off-by: Luis Pabon <lpabon@redhat.com>
Reviewed-on: http://review.gluster.org/6316
Reviewed-by: Thiago Da Silva <thiago@redhat.com>
Reviewed-by: Peter Portante <pportant@redhat.com>
Tested-by: Prashanth Pai <ppai@redhat.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/unit/obj/test_diskfile.py | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/test/unit/obj/test_diskfile.py b/test/unit/obj/test_diskfile.py index bd34eb1..dc2c2fa 100644 --- a/test/unit/obj/test_diskfile.py +++ b/test/unit/obj/test_diskfile.py @@ -22,7 +22,7 @@ import unittest import tempfile import shutil import mock -from mock import patch +from mock import Mock, patch from hashlib import md5 from swift.common.utils import normalize_timestamp @@ -162,6 +162,31 @@ class TestDiskFile(unittest.TestCase): assert gdf.datadir == os.path.join(self.td, "vol0", "bar", "b", "a") assert gdf.device_path == os.path.join(self.td, "vol0") + def test_open_no_logging_on_enoent(self): + + def _mock_do_open(path, flags): + raise GlusterFileSystemOSError(errno.ENOENT, + os.strerror(errno.ENOENT)) + + with patch("gluster.swift.obj.diskfile.do_open", + _mock_do_open): + gdf = self._get_diskfile("vol0", "p57", "ufo47", "bar", "z") + gdf.logger = Mock() + gdf.open() + self.assertEqual(0, gdf.logger.exception.call_count) + + def test_open_logging_on_no_enoent(self): + def _mock_do_open(path, flags): + raise GlusterFileSystemOSError(errno.EIO, + os.strerror(errno.EIO)) + + with patch("gluster.swift.obj.diskfile.do_open", + _mock_do_open): + gdf = self._get_diskfile("vol0", "p57", "ufo47", "bar", "z") + gdf.logger = Mock() + gdf.open() + self.assertEqual(1, gdf.logger.exception.call_count) + def test_open_no_metadata(self): the_path = os.path.join(self.td, "vol0", "bar") the_file = os.path.join(the_path, "z") |