From 5cef798f8dcdee0d0512e47b67ac67d5f8d6c14c Mon Sep 17 00:00:00 2001 From: Luis Pabon Date: Fri, 21 Jun 2013 16:41:50 -0400 Subject: OpenStack Swift Functional Tests for G4S This commit has the following changes: * G4S no longer accepts URLs that end in /. A HTTP code of 400 is returned when a / at the end of the object is detected. * Directories can be created as objects setting the content-type to application/directory and content-length to 0. * Functional tests have been adjusted to work with G4S constraints Change-Id: I31038a59699a8e3eeaba902db322218c6400093e Signed-off-by: Luis Pabon Reviewed-on: http://review.gluster.org/5246 Reviewed-by: Peter Portante Tested-by: Peter Portante --- gluster/swift/common/DiskDir.py | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'gluster/swift/common/DiskDir.py') diff --git a/gluster/swift/common/DiskDir.py b/gluster/swift/common/DiskDir.py index 364c95e..c1fb674 100644 --- a/gluster/swift/common/DiskDir.py +++ b/gluster/swift/common/DiskDir.py @@ -16,15 +16,14 @@ import os import errno -from gluster.swift.common.fs_utils import dir_empty, rmdirs, mkdirs, os_path, \ - do_chown +from gluster.swift.common.fs_utils import dir_empty, mkdirs, os_path, do_chown from gluster.swift.common.utils import validate_account, validate_container, \ get_container_details, get_account_details, create_container_metadata, \ create_account_metadata, DEFAULT_GID, get_container_metadata, \ get_account_metadata, DEFAULT_UID, validate_object, \ create_object_metadata, read_metadata, write_metadata, X_CONTENT_TYPE, \ X_CONTENT_LENGTH, X_TIMESTAMP, X_PUT_TIMESTAMP, X_ETAG, X_OBJECTS_COUNT, \ - X_BYTES_USED, X_CONTAINER_COUNT, DIR_TYPE + X_BYTES_USED, X_CONTAINER_COUNT, DIR_TYPE, rmobjdir, dir_is_object from gluster.swift.common import Glusterfs from gluster.swift.common.exceptions import FileOrDirNotFoundError @@ -333,14 +332,13 @@ class DiskDir(DiskCommon): else: return container_list - if objects and end_marker: + if end_marker: objects = filter_end_marker(objects, end_marker) - if objects: - if marker and marker >= prefix: - objects = filter_marker(objects, marker) - elif prefix: - objects = filter_prefix_as_marker(objects, prefix) + if marker and marker >= prefix: + objects = filter_marker(objects, marker) + elif prefix: + objects = filter_prefix_as_marker(objects, prefix) if prefix is None: # No prefix, we don't need to apply the other arguments, we just @@ -376,7 +374,8 @@ class DiskDir(DiskCommon): if e.errno != errno.ENOENT: raise if Glusterfs.OBJECT_ONLY and metadata \ - and metadata[X_CONTENT_TYPE] == DIR_TYPE: + and metadata[X_CONTENT_TYPE] == DIR_TYPE \ + and not dir_is_object(metadata): continue list_item = [] list_item.append(obj) @@ -484,19 +483,22 @@ class DiskDir(DiskCommon): # within a directory implicitly. return + def empty(self): + try: + return dir_empty(self.datadir) + except FileOrDirNotFoundError: + return True + def delete_db(self, timestamp): """ Delete the container (directory) if empty. :param timestamp: delete timestamp """ - try: - if not dir_empty(self.datadir): - # FIXME: This is a failure condition here, isn't it? - return - except FileOrDirNotFoundError: - return - rmdirs(self.datadir) + # Let's check and see if it has directories that + # where created by the code, but not by the + # caller as objects + rmobjdir(self.datadir) def set_x_container_sync_points(self, sync_point1, sync_point2): self.metadata['x_container_sync_point1'] = sync_point1 -- cgit