From f81f652899b9fd46114ce9089f6b9a97ea9584a1 Mon Sep 17 00:00:00 2001 From: Prashanth Pai Date: Fri, 27 Dec 2013 14:36:06 +0530 Subject: 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 Reviewed-on: http://review.gluster.org/6608 Reviewed-by: Luis Pabon Tested-by: Luis Pabon Signed-off-by: Prashanth Pai Reviewed-on: http://review.gluster.org/6666 Tested-by: Chetan Risbud Reviewed-by: Chetan Risbud --- test/unit/common/test_fs_utils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test') 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: -- cgit