summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPrashanth Pai <ppai@redhat.com>2013-12-27 14:36:06 +0530
committerChetan Risbud <crisbud@redhat.com>2014-01-08 03:07:16 -0800
commitf81f652899b9fd46114ce9089f6b9a97ea9584a1 (patch)
tree1d844686f7734262b69e8b940256468fb0776009 /test
parent2931f64a92341feb2f0ed35266dd8a16612e1ec6 (diff)
Handle ENOSPC on os.close() operation
It is quite possible that errors on a previous write() operation are first reported at the final close(). For fruther info, refer to: http://review.gluster.org/#/c/6269/ Change-Id: If0fbe2f5109d28c82cb493f2526fd5057f86b556 Signed-off-by: Prashanth Pai <ppai@redhat.com> Reviewed-on: http://review.gluster.org/6608 Reviewed-by: Luis Pabon <lpabon@redhat.com> Tested-by: Luis Pabon <lpabon@redhat.com> Signed-off-by: Prashanth Pai <ppai@redhat.com> Reviewed-on: http://review.gluster.org/6666 Tested-by: Chetan Risbud <crisbud@redhat.com> Reviewed-by: Chetan Risbud <crisbud@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/unit/common/test_fs_utils.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/test/unit/common/test_fs_utils.py b/test/unit/common/test_fs_utils.py
index 6e05ad3..4bd0712 100644
--- a/test/unit/common/test_fs_utils.py
+++ b/test/unit/common/test_fs_utils.py
@@ -566,6 +566,19 @@ class TestFsUtils(unittest.TestCase):
finally:
os.remove(tmpfile)
+ def test_do_close_err_ENOSPC(self):
+
+ def _mock_os_close_enospc(fd):
+ raise OSError(errno.ENOSPC, os.strerror(errno.ENOSPC))
+
+ fd, tmpfile = mkstemp()
+ try:
+ with patch('os.close', _mock_os_close_enospc):
+ self.assertRaises(DiskFileNoSpace, fs.do_close, fd)
+ finally:
+ os.close(fd)
+ os.remove(tmpfile)
+
def test_do_unlink(self):
fd, tmpfile = mkstemp()
try: