summaryrefslogtreecommitdiffstats
path: root/test/unit/obj/test_diskfile.py
diff options
context:
space:
mode:
authorChetan Risbud <crisbud@redhat.com>2014-03-04 19:35:24 +0530
committerChetan Risbud <crisbud@redhat.com>2014-03-12 06:00:20 -0700
commit1a6b55714fddf7a1b526a31ee3f27589f01e98e5 (patch)
tree8d51f9dfa85e6eb17d1fa214949ed7de9daf8fda /test/unit/obj/test_diskfile.py
parent47cbf09a228040ea33918a472481f464ef9ad261 (diff)
PUT of a Directory failed
PUT of a directory fails with gluster-swift when there exists object of a same name. This is because the objects and directories are placed on the glusterfs. And hence the filesystem semantics are applicable there. Exceptions raised in such situation are needed to be handled and reported correctly back to proxy-server with HTTPConflict as a error code. Although swift still continues to choose 503 as the best respose in such cases. No tracebacks reported. Fix covers the case when there exists a directory and object of the same name is PUT. Code changes fixes both the failure cases mentioned in the bug. Examples of failing PUT requests: 1) curl -v -X PUT http://127.0.0.1:8080/v1/AUTH_test/c1/dir1/obj2/anotherobject -d'asdasdsadA' -- obj2 was already an object. 2)curl -v -H 'Content-Length: 0' -H 'Content-Type: application/directory' -X PUT http://127.0.0.1:8080/v1/AUTH_test/c1/obj1 -- obj1 was already and object Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1071021 Change-Id: Id3042d920e3f99e740d4042ef5907ac8c59e04db Signed-off-by: Chetan Risbud <crisbud@redhat.com> Reviewed-on: http://review.gluster.org/7181 Reviewed-by: Prashanth Pai <ppai@redhat.com> Tested-by: Prashanth Pai <ppai@redhat.com>
Diffstat (limited to 'test/unit/obj/test_diskfile.py')
-rw-r--r--test/unit/obj/test_diskfile.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/test/unit/obj/test_diskfile.py b/test/unit/obj/test_diskfile.py
index a767261..64fa6e7 100644
--- a/test/unit/obj/test_diskfile.py
+++ b/test/unit/obj/test_diskfile.py
@@ -26,7 +26,8 @@ from eventlet import tpool
from mock import Mock, patch
from hashlib import md5
from copy import deepcopy
-
+from gluster.swift.common.exceptions import AlreadyExistsAsDir, \
+ AlreadyExistsAsFile
from swift.common.exceptions import DiskFileNotExist, DiskFileError, \
DiskFileNoSpace, DiskFileNotOpen
from swift.common.utils import ThreadPool
@@ -409,7 +410,7 @@ class TestDiskFile(unittest.TestCase):
dc = gluster.swift.obj.diskfile.do_chown
gluster.swift.obj.diskfile.do_chown = _mock_do_chown
self.assertRaises(
- DiskFileError, gdf._create_dir_object, the_dir)
+ AlreadyExistsAsFile, gdf._create_dir_object, the_dir)
gluster.swift.obj.diskfile.do_chown = dc
self.assertFalse(os.path.isdir(the_dir))
self.assertFalse(_mapit(the_dir) in _metadata)
@@ -431,7 +432,7 @@ class TestDiskFile(unittest.TestCase):
dc = gluster.swift.obj.diskfile.do_chown
gluster.swift.obj.diskfile.do_chown = _mock_do_chown
self.assertRaises(
- DiskFileError, gdf._create_dir_object, the_dir)
+ AlreadyExistsAsFile, gdf._create_dir_object, the_dir)
gluster.swift.obj.diskfile.do_chown = dc
self.assertFalse(os.path.isdir(the_dir))
self.assertFalse(_mapit(the_dir) in _metadata)
@@ -622,7 +623,7 @@ class TestDiskFile(unittest.TestCase):
# directory.
dw.write('12345\n')
dw.put(newmd)
- except DiskFileError:
+ except AlreadyExistsAsDir:
pass
else:
self.fail("Expected to encounter"