From de24352275066c204051ec329e8386cbb925171d Mon Sep 17 00:00:00 2001 From: Thiago da Silva Date: Mon, 7 Jul 2014 13:33:40 -0400 Subject: [PATCH] changing references of gluster to swiftonfile Renamed files and directories as well as replaced infile references to gluster where appropriate Signed-off-by: Thiago da Silva --- ...nt-metadata => swiftonfile-print-metadata} | 2 +- etc/{fs.conf-gluster => fs.conf-swiftonfile} | 0 ...gluster => object-server.conf-swiftonfile} | 2 +- ...ft.conf-gluster => swift.conf-swiftonfile} | 0 extras/apache-deploy/install.sh | 2 +- extras/hook-scripts/S40ufo-stop.py | 2 +- makerpm.sh | 2 +- pkgconfig.py | 2 +- setup.py | 10 +-- ...s-openstack-swift.spec => swiftonfile.spec | 24 ++---- {gluster => swiftonfile}/__init__.py | 0 {gluster => swiftonfile}/swift/__init__.py | 4 +- .../swift/common/Glusterfs.py | 4 +- .../swift/common/__init__.py | 0 .../swift/common/constraints.py | 0 .../swift/common/exceptions.py | 0 .../swift/common/fs_utils.py | 2 +- .../swift/common/utils.py | 4 +- .../swift/obj/__init__.py | 0 .../swift/obj/diskfile.py | 12 +-- {gluster => swiftonfile}/swift/obj/server.py | 8 +- test/unit/common/test_Glusterfs.py | 20 ++--- test/unit/common/test_constraints.py | 4 +- test/unit/common/test_fs_utils.py | 4 +- test/unit/common/test_utils.py | 8 +- test/unit/obj/test_diskfile.py | 76 +++++++++---------- test/unit/obj/test_server.py | 4 +- test/unit/test_swift.py | 14 ++-- tools/functional_tests.sh | 6 +- tox.ini | 4 +- 30 files changed, 104 insertions(+), 116 deletions(-) rename bin/{gluster-swift-print-metadata => swiftonfile-print-metadata} (95%) rename etc/{fs.conf-gluster => fs.conf-swiftonfile} (100%) rename etc/{object-server.conf-gluster => object-server.conf-swiftonfile} (98%) rename etc/{swift.conf-gluster => swift.conf-swiftonfile} (100%) rename glusterfs-openstack-swift.spec => swiftonfile.spec (79%) rename {gluster => swiftonfile}/__init__.py (100%) rename {gluster => swiftonfile}/swift/__init__.py (94%) rename {gluster => swiftonfile}/swift/common/Glusterfs.py (98%) rename {gluster => swiftonfile}/swift/common/__init__.py (100%) rename {gluster => swiftonfile}/swift/common/constraints.py (100%) rename {gluster => swiftonfile}/swift/common/exceptions.py (100%) rename {gluster => swiftonfile}/swift/common/fs_utils.py (99%) rename {gluster => swiftonfile}/swift/common/utils.py (99%) rename {gluster => swiftonfile}/swift/obj/__init__.py (100%) rename {gluster => swiftonfile}/swift/obj/diskfile.py (99%) rename {gluster => swiftonfile}/swift/obj/server.py (91%) diff --git a/bin/gluster-swift-print-metadata b/bin/swiftonfile-print-metadata similarity index 95% rename from bin/gluster-swift-print-metadata rename to bin/swiftonfile-print-metadata index 5cf04f7..0fae3e1 100755 --- a/bin/gluster-swift-print-metadata +++ b/bin/swiftonfile-print-metadata @@ -20,7 +20,7 @@ import pprint import os import json from optparse import OptionParser -from gluster.swift.common.utils import read_metadata +from swiftonfile.swift.common.utils import read_metadata # Parser Setup USAGE = "Usage: %prog [options] OBJECT" diff --git a/etc/fs.conf-gluster b/etc/fs.conf-swiftonfile similarity index 100% rename from etc/fs.conf-gluster rename to etc/fs.conf-swiftonfile diff --git a/etc/object-server.conf-gluster b/etc/object-server.conf-swiftonfile similarity index 98% rename from etc/object-server.conf-gluster rename to etc/object-server.conf-swiftonfile index 033a2fb..262256f 100644 --- a/etc/object-server.conf-gluster +++ b/etc/object-server.conf-swiftonfile @@ -30,7 +30,7 @@ disable_fallocate = true pipeline = object-server [app:object-server] -use = egg:gluster_swift#object +use = egg:swiftonfile#object user = root log_facility = LOG_LOCAL2 log_level = WARN diff --git a/etc/swift.conf-gluster b/etc/swift.conf-swiftonfile similarity index 100% rename from etc/swift.conf-gluster rename to etc/swift.conf-swiftonfile diff --git a/extras/apache-deploy/install.sh b/extras/apache-deploy/install.sh index aa24250..770d851 100755 --- a/extras/apache-deploy/install.sh +++ b/extras/apache-deploy/install.sh @@ -40,5 +40,5 @@ effect." fi echo "Successfully configured Apache as frontend for Swift." -echo "Make sure GlusterFS volume is mounted at /mnt/gluster-object/ \ +echo "Make sure GlusterFS volume is mounted at /mnt/swiftonfile/ \ before starting httpd" diff --git a/extras/hook-scripts/S40ufo-stop.py b/extras/hook-scripts/S40ufo-stop.py index 92418df..f40d46b 100755 --- a/extras/hook-scripts/S40ufo-stop.py +++ b/extras/hook-scripts/S40ufo-stop.py @@ -21,7 +21,7 @@ from optparse import OptionParser if __name__ == '__main__': # check if swift is installed try: - from gluster.swift.common.Glusterfs import get_mnt_point, unmount + from swiftonfile.swift.common.Glusterfs import get_mnt_point, unmount except ImportError: import sys sys.exit("Openstack Swift does not appear to be installed properly") diff --git a/makerpm.sh b/makerpm.sh index 591190a..f308eee 100644 --- a/makerpm.sh +++ b/makerpm.sh @@ -3,7 +3,7 @@ # Simple script to create RPMs for G4S ## RPM NAME -RPMNAME=glusterfs-openstack-swift +RPMNAME=swiftonfile cleanup() { diff --git a/pkgconfig.py b/pkgconfig.py index 9434e3a..54fdc68 100644 --- a/pkgconfig.py +++ b/pkgconfig.py @@ -1,7 +1,7 @@ # Simple program to save all package information # into a file which can be sourced by a bash script -from gluster.swift import _pkginfo as pkginfo +from swiftonfile.swift import _pkginfo as pkginfo PKGCONFIG = 'pkgconfig.in' diff --git a/setup.py b/setup.py index f928c5c..9cdfb3c 100644 --- a/setup.py +++ b/setup.py @@ -14,17 +14,17 @@ # limitations under the License. from setuptools import setup, find_packages -from gluster.swift import _pkginfo +from swiftonfile.swift import _pkginfo setup( name=_pkginfo.name, version=_pkginfo.full_version, - description='Gluster For Swift', + description='SwiftOnfile', license='Apache License (2.0)', author='Red Hat, Inc.', author_email='gluster-users@gluster.org', - url='http://launchpad.net/gluster-swift', + url='https://github.com/swiftonfile/swiftonfile', packages=find_packages(exclude=['test', 'bin']), test_suite='nose.collector', classifiers=[ @@ -41,11 +41,11 @@ setup( ], install_requires=[], scripts=[ - 'bin/gluster-swift-print-metadata', + 'bin/swiftonfile-print-metadata', ], entry_points={ 'paste.app_factory': [ - 'object=gluster.swift.obj.server:app_factory', + 'object=swiftonfile.swift.obj.server:app_factory', ], }, ) diff --git a/glusterfs-openstack-swift.spec b/swiftonfile.spec similarity index 79% rename from glusterfs-openstack-swift.spec rename to swiftonfile.spec index 7db2055..41ddfc5 100644 --- a/glusterfs-openstack-swift.spec +++ b/swiftonfile.spec @@ -8,12 +8,12 @@ %{!?_name:%define _name __PKG_NAME__} %{!?_release:%define _release __PKG_RELEASE__} -Summary : GlusterFS Integration with OpenStack Object Storage (Swift). +Summary : SwiftOnFile enables Swift objects to be accessed as files. Name : %{_name} Version : %{_version} Release : %{_release}%{?dist} Group : Application/File -URL : http://launchpad.net/gluster-swift +URL : https://github.com/swiftonfile/swiftonfile Vendor : Fedora Project Source0 : %{_name}-%{_version}-%{_release}.tar.gz License : ASL 2.0 @@ -46,7 +46,7 @@ as top-level directories of volumes, where accounts are mapped one-to-one to gluster volumes. %prep -%setup -q -n gluster_swift-%{_version} +%setup -q -n swiftonfile-%{_version} %build %{__python} setup.py build @@ -68,23 +68,11 @@ done # Remove tests %{__rm} -rf %{buildroot}/%{python_sitelib}/test -# Remove files provided by glusterfs-api -%{__rm} -rf %{buildroot}/%{python_sitelib}/gluster/__init__.p* - %files %defattr(-,root,root) -%{python_sitelib}/gluster -%{python_sitelib}/gluster_swift-%{_version}_*.egg-info -%{_bindir}/gluster-swift-gen-builders -%{_bindir}/gluster-swift-print-metadata -%{_bindir}/gswauth-add-account -%{_bindir}/gswauth-add-user -%{_bindir}/gswauth-cleanup-tokens -%{_bindir}/gswauth-delete-account -%{_bindir}/gswauth-delete-user -%{_bindir}/gswauth-list -%{_bindir}/gswauth-prep -%{_bindir}/gswauth-set-account-service +%{python_sitelib}/swiftonfile +%{python_sitelib}/swiftonfile-%{_version}_*.egg-info +%{_bindir}/swiftonfile-print-metadata %{_mandir}/man8/* %dir %{_confdir} diff --git a/gluster/__init__.py b/swiftonfile/__init__.py similarity index 100% rename from gluster/__init__.py rename to swiftonfile/__init__.py diff --git a/gluster/swift/__init__.py b/swiftonfile/swift/__init__.py similarity index 94% rename from gluster/swift/__init__.py rename to swiftonfile/swift/__init__.py index e5b79d2..5a8c3c0 100644 --- a/gluster/swift/__init__.py +++ b/swiftonfile/swift/__init__.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" Gluster for Swift """ +""" SwiftOnFile """ class PkgInfo(object): @@ -45,6 +45,6 @@ class PkgInfo(object): ### ### Change the Package version here ### -_pkginfo = PkgInfo('1.13.1', '0', 'gluster_swift', False) +_pkginfo = PkgInfo('1.13.1', '0', 'swiftonfile', False) __version__ = _pkginfo.pretty_version __canonical_version__ = _pkginfo.canonical_version diff --git a/gluster/swift/common/Glusterfs.py b/swiftonfile/swift/common/Glusterfs.py similarity index 98% rename from gluster/swift/common/Glusterfs.py rename to swiftonfile/swift/common/Glusterfs.py index 5545ded..5d7dced 100644 --- a/gluster/swift/common/Glusterfs.py +++ b/swiftonfile/swift/common/Glusterfs.py @@ -22,8 +22,8 @@ import urllib from ConfigParser import ConfigParser, NoSectionError, NoOptionError from swift.common.utils import TRUE_VALUES -from gluster.swift.common.fs_utils import do_ismount -from gluster.swift.common.exceptions import FailureToMountError +from swiftonfile.swift.common.fs_utils import do_ismount +from swiftonfile.swift.common.exceptions import FailureToMountError # # Read the fs.conf file once at startup (module load) diff --git a/gluster/swift/common/__init__.py b/swiftonfile/swift/common/__init__.py similarity index 100% rename from gluster/swift/common/__init__.py rename to swiftonfile/swift/common/__init__.py diff --git a/gluster/swift/common/constraints.py b/swiftonfile/swift/common/constraints.py similarity index 100% rename from gluster/swift/common/constraints.py rename to swiftonfile/swift/common/constraints.py diff --git a/gluster/swift/common/exceptions.py b/swiftonfile/swift/common/exceptions.py similarity index 100% rename from gluster/swift/common/exceptions.py rename to swiftonfile/swift/common/exceptions.py diff --git a/gluster/swift/common/fs_utils.py b/swiftonfile/swift/common/fs_utils.py similarity index 99% rename from gluster/swift/common/fs_utils.py rename to swiftonfile/swift/common/fs_utils.py index 03dff53..0b13c4f 100644 --- a/gluster/swift/common/fs_utils.py +++ b/swiftonfile/swift/common/fs_utils.py @@ -25,7 +25,7 @@ from itertools import repeat import ctypes from eventlet import sleep from swift.common.utils import load_libc_function -from gluster.swift.common.exceptions import FileOrDirNotFoundError, \ +from swiftonfile.swift.common.exceptions import FileOrDirNotFoundError, \ NotDirectoryError, GlusterFileSystemOSError from swift.common.exceptions import DiskFileNoSpace diff --git a/gluster/swift/common/utils.py b/swiftonfile/swift/common/utils.py similarity index 99% rename from gluster/swift/common/utils.py rename to swiftonfile/swift/common/utils.py index c58b870..8a999a4 100644 --- a/gluster/swift/common/utils.py +++ b/swiftonfile/swift/common/utils.py @@ -21,9 +21,9 @@ import logging from hashlib import md5 from eventlet import sleep import cPickle as pickle -from gluster.swift.common.exceptions import GlusterFileSystemIOError +from swiftonfile.swift.common.exceptions import GlusterFileSystemIOError from swift.common.exceptions import DiskFileNoSpace -from gluster.swift.common.fs_utils import do_stat, \ +from swiftonfile.swift.common.fs_utils import do_stat, \ do_walk, do_rmdir, do_log_rl, get_filename_from_fd, do_open, \ do_getxattr, do_setxattr, do_removexattr, do_read, \ do_close, do_dup, do_lseek, do_fstat, do_fsync, do_rename diff --git a/gluster/swift/obj/__init__.py b/swiftonfile/swift/obj/__init__.py similarity index 100% rename from gluster/swift/obj/__init__.py rename to swiftonfile/swift/obj/__init__.py diff --git a/gluster/swift/obj/diskfile.py b/swiftonfile/swift/obj/diskfile.py similarity index 99% rename from gluster/swift/obj/diskfile.py rename to swiftonfile/swift/obj/diskfile.py index cc677b7..9515db2 100644 --- a/gluster/swift/obj/diskfile.py +++ b/swiftonfile/swift/obj/diskfile.py @@ -28,7 +28,7 @@ from hashlib import md5 from eventlet import sleep from greenlet import getcurrent from contextlib import contextmanager -from gluster.swift.common.exceptions import AlreadyExistsAsFile, \ +from swiftonfile.swift.common.exceptions import AlreadyExistsAsFile, \ AlreadyExistsAsDir from swift.common.utils import TRUE_VALUES, ThreadPool, hash_path, \ normalize_timestamp @@ -37,14 +37,14 @@ from swift.common.exceptions import DiskFileNotExist, DiskFileError, \ DiskFileExpired from swift.common.swob import multi_range_iterator -from gluster.swift.common.exceptions import GlusterFileSystemOSError -from gluster.swift.common.fs_utils import do_fstat, do_open, do_close, \ +from swiftonfile.swift.common.exceptions import GlusterFileSystemOSError +from swiftonfile.swift.common.fs_utils import do_fstat, do_open, do_close, \ do_unlink, do_chown, do_fsync, do_fchown, do_stat, do_write, do_read, \ do_fadvise64, do_rename, do_fdatasync, do_lseek, do_mkdir -from gluster.swift.common.utils import read_metadata, write_metadata, \ +from swiftonfile.swift.common.utils import read_metadata, write_metadata, \ validate_object, create_object_metadata, rmobjdir, dir_is_object, \ get_object_metadata, write_pickle -from gluster.swift.common.utils import X_CONTENT_TYPE, \ +from swiftonfile.swift.common.utils import X_CONTENT_TYPE, \ X_TIMESTAMP, X_TYPE, X_OBJECT_TYPE, FILE, OBJECT, DIR_TYPE, \ FILE_TYPE, DEFAULT_UID, DEFAULT_GID, DIR_NON_OBJECT, DIR_OBJECT, \ X_ETAG, X_CONTENT_LENGTH @@ -561,7 +561,7 @@ class DiskFile(object): Object names ending or beginning with a '/' as in /a, a/, /a/b/, etc, or object names with multiple consecutive slahes, like a//b, are not supported. The proxy server's contraints filter - gluster.common.constrains.gluster_check_object_creation() should + swiftonfile.common.constrains.sof_check_object_creation() should reject such requests. :param mgr: associated on-disk manager instance diff --git a/gluster/swift/obj/server.py b/swiftonfile/swift/obj/server.py similarity index 91% rename from gluster/swift/obj/server.py rename to swiftonfile/swift/obj/server.py index 0ecfc27..cec3809 100644 --- a/gluster/swift/obj/server.py +++ b/swiftonfile/swift/obj/server.py @@ -15,16 +15,16 @@ """ Object Server for Gluster for Swift """ -import gluster.swift.common.constraints # noqa +import swiftonfile.swift.common.constraints # noqa from swift.common.swob import HTTPConflict from swift.common.utils import public, timing_stats -from gluster.swift.common.exceptions import AlreadyExistsAsFile, \ +from swiftonfile.swift.common.exceptions import AlreadyExistsAsFile, \ AlreadyExistsAsDir from swift.common.request_helpers import split_and_validate_path from swift.obj import server -from gluster.swift.obj.diskfile import DiskFileManager +from swiftonfile.swift.obj.diskfile import DiskFileManager class ObjectController(server.ObjectController): @@ -64,7 +64,7 @@ class ObjectController(server.ObjectController): def PUT(self, request): try: server.check_object_creation = \ - gluster.swift.common.constraints.sof_check_object_creation + swiftonfile.swift.common.constraints.sof_check_object_creation return server.ObjectController.PUT(self, request) except (AlreadyExistsAsFile, AlreadyExistsAsDir): device = \ diff --git a/test/unit/common/test_Glusterfs.py b/test/unit/common/test_Glusterfs.py index 8a111f7..9463fce 100644 --- a/test/unit/common/test_Glusterfs.py +++ b/test/unit/common/test_Glusterfs.py @@ -19,7 +19,7 @@ import time import StringIO import mock from tempfile import mkdtemp -import gluster.swift.common.Glusterfs as gfs +import swiftonfile.swift.common.Glusterfs as gfs def mock_os_path_ismount_false(path): return False @@ -92,7 +92,7 @@ class TestGlusterfs(unittest.TestCase): def test_mount(self): try: tmpdir = mkdtemp() - root = os.path.join(tmpdir, 'mnt/gluster-object') + root = os.path.join(tmpdir, 'mnt/swiftonfile') drive = 'test' _init_mock_variables(tmpdir) @@ -104,7 +104,7 @@ class TestGlusterfs(unittest.TestCase): def test_mount_egain(self): try: tmpdir = mkdtemp() - root = os.path.join(tmpdir, 'mnt/gluster-object') + root = os.path.join(tmpdir, 'mnt/swiftonfile') drive = 'test' _init_mock_variables(tmpdir) @@ -117,7 +117,7 @@ class TestGlusterfs(unittest.TestCase): def test_mount_get_export_list_err(self): try: tmpdir = mkdtemp() - root = os.path.join(tmpdir, 'mnt/gluster-object') + root = os.path.join(tmpdir, 'mnt/swiftonfile') drive = 'test3' _init_mock_variables(tmpdir) @@ -132,7 +132,7 @@ class TestGlusterfs(unittest.TestCase): """ try: tmpdir = mkdtemp() - root = os.path.join(tmpdir, 'mnt/gluster-object') + root = os.path.join(tmpdir, 'mnt/swiftonfile') drive = 'test' _init_mock_variables(tmpdir) @@ -150,7 +150,7 @@ class TestGlusterfs(unittest.TestCase): """ try: tmpdir = mkdtemp() - root = os.path.join(tmpdir, 'mnt/gluster-object') + root = os.path.join(tmpdir, 'mnt/swiftonfile') drive = 'test' _init_mock_variables(tmpdir) @@ -166,7 +166,7 @@ class TestGlusterfs(unittest.TestCase): def test_invalid_drive_name(self): try: tmpdir = mkdtemp() - root = os.path.join(tmpdir, 'mnt/gluster-object') + root = os.path.join(tmpdir, 'mnt/swiftonfile') drive = 'te st' _init_mock_variables(tmpdir) @@ -178,14 +178,14 @@ class TestGlusterfs(unittest.TestCase): def test_already_mounted(self): try: tmpdir = mkdtemp() - root = os.path.join(tmpdir, 'mnt/gluster-object') + root = os.path.join(tmpdir, 'mnt/swiftonfile') drive = 'test' _init_mock_variables(tmpdir) def mock_do_ismount(path): return True - with mock.patch("gluster.swift.common.Glusterfs.do_ismount", + with mock.patch("swiftonfile.swift.common.Glusterfs.do_ismount", mock_do_ismount): self.assertTrue(gfs.mount(root, drive)) finally: @@ -195,7 +195,7 @@ class TestGlusterfs(unittest.TestCase): def test_get_export_list(self): try: tmpdir = mkdtemp() - root = os.path.join(tmpdir, 'mnt/gluster-object') + root = os.path.join(tmpdir, 'mnt/swiftonfile-object') drive = 'test' # undo mocking of _get_export_list diff --git a/test/unit/common/test_constraints.py b/test/unit/common/test_constraints.py index 952e1e6..8a1616f 100644 --- a/test/unit/common/test_constraints.py +++ b/test/unit/common/test_constraints.py @@ -15,7 +15,7 @@ import unittest from mock import Mock, patch -from gluster.swift.common import constraints as cnt +from swiftonfile.swift.common import constraints as cnt def mock_check_object_creation(*args, **kwargs): @@ -41,7 +41,7 @@ class TestConstraints(unittest.TestCase): self.assertTrue(cnt.validate_obj_name_component('')) def test_sof_check_object_creation(self): - with patch('gluster.swift.common.constraints.swift_check_object_creation', + with patch('swiftonfile.swift.common.constraints.swift_check_object_creation', mock_check_object_creation): req = Mock() req.headers = [] diff --git a/test/unit/common/test_fs_utils.py b/test/unit/common/test_fs_utils.py index 9f3ad3e..f816543 100644 --- a/test/unit/common/test_fs_utils.py +++ b/test/unit/common/test_fs_utils.py @@ -22,8 +22,8 @@ from nose import SkipTest from mock import patch, Mock from time import sleep from tempfile import mkdtemp, mkstemp -from gluster.swift.common import fs_utils as fs -from gluster.swift.common.exceptions import NotDirectoryError, \ +from swiftonfile.swift.common import fs_utils as fs +from swiftonfile.swift.common.exceptions import NotDirectoryError, \ FileOrDirNotFoundError, GlusterFileSystemOSError from swift.common.exceptions import DiskFileNoSpace diff --git a/test/unit/common/test_utils.py b/test/unit/common/test_utils.py index 189bbb8..04b1580 100644 --- a/test/unit/common/test_utils.py +++ b/test/unit/common/test_utils.py @@ -26,8 +26,8 @@ import tarfile import shutil from collections import defaultdict from mock import patch -from gluster.swift.common import utils, Glusterfs -from gluster.swift.common.exceptions import GlusterFileSystemOSError +from swiftonfile.swift.common import utils, Glusterfs +from swiftonfile.swift.common.exceptions import GlusterFileSystemOSError from swift.common.exceptions import DiskFileNoSpace # @@ -466,7 +466,7 @@ class TestUtils(unittest.TestCase): try: fpp = os.path.join(td, 'pp') # FIXME: Remove this patch when coverage.py can handle eventlet - with patch("gluster.swift.common.fs_utils.do_fsync", + with patch("swiftonfile.swift.common.fs_utils.do_fsync", _mock_os_fsync): utils.write_pickle('pickled peppers', fpp) with open(fpp, "rb") as f: @@ -483,7 +483,7 @@ class TestUtils(unittest.TestCase): fpp = os.path.join(td, 'pp') # Also test an explicity pickle protocol # FIXME: Remove this patch when coverage.py can handle eventlet - with patch("gluster.swift.common.fs_utils.do_fsync", + with patch("swiftonfile.swift.common.fs_utils.do_fsync", _mock_os_fsync): utils.write_pickle('pickled peppers', fpp, tmp=tf.name, pickle_protocol=2) diff --git a/test/unit/obj/test_diskfile.py b/test/unit/obj/test_diskfile.py index 729bd13..3c41a91 100644 --- a/test/unit/obj/test_diskfile.py +++ b/test/unit/obj/test_diskfile.py @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" Tests for gluster.swift.obj.diskfile """ +""" Tests for swiftonfile.swift.obj.diskfile """ import os import stat @@ -26,18 +26,18 @@ from eventlet import tpool from mock import Mock, patch from hashlib import md5 from copy import deepcopy -from gluster.swift.common.exceptions import AlreadyExistsAsDir, \ +from swiftonfile.swift.common.exceptions import AlreadyExistsAsDir, \ AlreadyExistsAsFile from swift.common.exceptions import DiskFileNotExist, DiskFileError, \ DiskFileNoSpace, DiskFileNotOpen from swift.common.utils import ThreadPool -from gluster.swift.common.exceptions import GlusterFileSystemOSError -import gluster.swift.common.utils -from gluster.swift.common.utils import normalize_timestamp -import gluster.swift.obj.diskfile -from gluster.swift.obj.diskfile import DiskFileWriter, DiskFile, DiskFileManager -from gluster.swift.common.utils import DEFAULT_UID, DEFAULT_GID, X_TYPE, \ +from swiftonfile.swift.common.exceptions import GlusterFileSystemOSError +import swiftonfile.swift.common.utils +from swiftonfile.swift.common.utils import normalize_timestamp +import swiftonfile.swift.obj.diskfile +from swiftonfile.swift.obj.diskfile import DiskFileWriter, DiskFile, DiskFileManager +from swiftonfile.swift.common.utils import DEFAULT_UID, DEFAULT_GID, X_TYPE, \ X_OBJECT_TYPE, DIR_OBJECT from test.unit.common.test_utils import _initxattr, _destroyxattr @@ -81,7 +81,7 @@ class MockException(Exception): def _mock_rmobjdir(p): - raise MockException("gluster.swift.obj.diskfile.rmobjdir() called") + raise MockException("swiftonfile.swift.obj.diskfile.rmobjdir() called") def _mock_do_fsync(fd): @@ -96,12 +96,12 @@ def _mock_renamer(a, b): raise MockRenamerCalled() class TestDiskFileWriter(unittest.TestCase): - """ Tests for gluster.swift.obj.diskfile.DiskFileWriter """ + """ Tests for swiftonfile.swift.obj.diskfile.DiskFileWriter """ def test_close(self): dw = DiskFileWriter(100, 'a', None) mock_close = Mock() - with patch("gluster.swift.obj.diskfile.do_close", mock_close): + with patch("swiftonfile.swift.obj.diskfile.do_close", mock_close): # It should call do_close self.assertEqual(100, dw._fd) dw.close() @@ -115,7 +115,7 @@ class TestDiskFileWriter(unittest.TestCase): self.assertEqual(1, mock_close.call_count) class TestDiskFile(unittest.TestCase): - """ Tests for gluster.swift.obj.diskfile """ + """ Tests for swiftonfile.swift.obj.diskfile """ def setUp(self): self._orig_tpool_exc = tpool.execute @@ -123,16 +123,16 @@ class TestDiskFile(unittest.TestCase): self.lg = FakeLogger() _initxattr() _mock_clear_metadata() - self._saved_df_wm = gluster.swift.obj.diskfile.write_metadata - self._saved_df_rm = gluster.swift.obj.diskfile.read_metadata - gluster.swift.obj.diskfile.write_metadata = _mock_write_metadata - gluster.swift.obj.diskfile.read_metadata = _mock_read_metadata - self._saved_ut_wm = gluster.swift.common.utils.write_metadata - self._saved_ut_rm = gluster.swift.common.utils.read_metadata - gluster.swift.common.utils.write_metadata = _mock_write_metadata - gluster.swift.common.utils.read_metadata = _mock_read_metadata - self._saved_do_fsync = gluster.swift.obj.diskfile.do_fsync - gluster.swift.obj.diskfile.do_fsync = _mock_do_fsync + self._saved_df_wm = swiftonfile.swift.obj.diskfile.write_metadata + self._saved_df_rm = swiftonfile.swift.obj.diskfile.read_metadata + swiftonfile.swift.obj.diskfile.write_metadata = _mock_write_metadata + swiftonfile.swift.obj.diskfile.read_metadata = _mock_read_metadata + self._saved_ut_wm = swiftonfile.swift.common.utils.write_metadata + self._saved_ut_rm = swiftonfile.swift.common.utils.read_metadata + swiftonfile.swift.common.utils.write_metadata = _mock_write_metadata + swiftonfile.swift.common.utils.read_metadata = _mock_read_metadata + self._saved_do_fsync = swiftonfile.swift.obj.diskfile.do_fsync + swiftonfile.swift.obj.diskfile.do_fsync = _mock_do_fsync self.td = tempfile.mkdtemp() self.conf = dict(devices=self.td, mb_per_sync=2, keep_cache_size=(1024 * 1024), mount_check=False) @@ -142,11 +142,11 @@ class TestDiskFile(unittest.TestCase): tpool.execute = self._orig_tpool_exc self.lg = None _destroyxattr() - gluster.swift.obj.diskfile.write_metadata = self._saved_df_wm - gluster.swift.obj.diskfile.read_metadata = self._saved_df_rm - gluster.swift.common.utils.write_metadata = self._saved_ut_wm - gluster.swift.common.utils.read_metadata = self._saved_ut_rm - gluster.swift.obj.diskfile.do_fsync = self._saved_do_fsync + swiftonfile.swift.obj.diskfile.write_metadata = self._saved_df_wm + swiftonfile.swift.obj.diskfile.read_metadata = self._saved_df_rm + swiftonfile.swift.common.utils.write_metadata = self._saved_ut_wm + swiftonfile.swift.common.utils.read_metadata = self._saved_ut_rm + swiftonfile.swift.obj.diskfile.do_fsync = self._saved_do_fsync shutil.rmtree(self.td) def _get_diskfile(self, d, p, a, c, o, **kwargs): @@ -207,7 +207,7 @@ class TestDiskFile(unittest.TestCase): def test_open_and_close(self): mock_close = Mock() - with mock.patch("gluster.swift.obj.diskfile.do_close", mock_close): + with mock.patch("swiftonfile.swift.obj.diskfile.do_close", mock_close): gdf = self._create_and_get_diskfile("vol0", "p57", "ufo47", "bar", "z") with gdf.open(): @@ -308,7 +308,7 @@ class TestDiskFile(unittest.TestCase): closed[0] = True os.close(fd[0]) - with mock.patch("gluster.swift.obj.diskfile.do_close", mock_close): + with mock.patch("swiftonfile.swift.obj.diskfile.do_close", mock_close): gdf = self._create_and_get_diskfile("vol0", "p57", "ufo47", "bar", "z") with gdf.open(): assert gdf._fd is not None @@ -361,7 +361,7 @@ class TestDiskFile(unittest.TestCase): closed[0] = True os.close(fd[0]) - with mock.patch("gluster.swift.obj.diskfile.do_close", mock_close): + with mock.patch("swiftonfile.swift.obj.diskfile.do_close", mock_close): gdf = self._create_and_get_diskfile("vol0", "p57", "ufo47", "bar", "z", fsize=1024*1024*2) with gdf.open(): assert gdf._fd is not None @@ -388,7 +388,7 @@ class TestDiskFile(unittest.TestCase): try: chunks = [ck for ck in reader] assert len(chunks) == 0, repr(chunks) - with mock.patch("gluster.swift.obj.diskfile.do_close", + with mock.patch("swiftonfile.swift.obj.diskfile.do_close", our_do_close): reader.close() assert not called[0] @@ -437,11 +437,11 @@ class TestDiskFile(unittest.TestCase): assert u == DEFAULT_UID assert g == DEFAULT_GID - dc = gluster.swift.obj.diskfile.do_chown - gluster.swift.obj.diskfile.do_chown = _mock_do_chown + dc = swiftonfile.swift.obj.diskfile.do_chown + swiftonfile.swift.obj.diskfile.do_chown = _mock_do_chown self.assertRaises( AlreadyExistsAsFile, gdf._create_dir_object, the_dir) - gluster.swift.obj.diskfile.do_chown = dc + swiftonfile.swift.obj.diskfile.do_chown = dc self.assertFalse(os.path.isdir(the_dir)) self.assertFalse(_mapit(the_dir) in _metadata) @@ -459,11 +459,11 @@ class TestDiskFile(unittest.TestCase): assert u == DEFAULT_UID assert g == DEFAULT_GID - dc = gluster.swift.obj.diskfile.do_chown - gluster.swift.obj.diskfile.do_chown = _mock_do_chown + dc = swiftonfile.swift.obj.diskfile.do_chown + swiftonfile.swift.obj.diskfile.do_chown = _mock_do_chown self.assertRaises( AlreadyExistsAsFile, gdf._create_dir_object, the_dir) - gluster.swift.obj.diskfile.do_chown = dc + swiftonfile.swift.obj.diskfile.do_chown = dc self.assertFalse(os.path.isdir(the_dir)) self.assertFalse(_mapit(the_dir) in _metadata) @@ -756,7 +756,7 @@ class TestDiskFile(unittest.TestCase): def mock_rename(*args, **kwargs): raise OSError(errno.ENOENT, os.strerror(errno.ENOENT)) - with mock.patch("gluster.swift.obj.diskfile.sleep", mock_sleep): + with mock.patch("swiftonfile.swift.obj.diskfile.sleep", mock_sleep): with mock.patch("os.rename", mock_rename): try: with gdf.create() as dw: diff --git a/test/unit/obj/test_server.py b/test/unit/obj/test_server.py index cef2074..f9737dd 100644 --- a/test/unit/obj/test_server.py +++ b/test/unit/obj/test_server.py @@ -13,12 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" Tests for gluster.swift.obj.server subclass """ +""" Tests for swiftonfile.swift.obj.server subclass """ import unittest from nose import SkipTest -import gluster.swift.obj.server as server +import swiftonfile.swift.obj.server as server class TestObjServer(unittest.TestCase): diff --git a/test/unit/test_swift.py b/test/unit/test_swift.py index 78c126c..09317ba 100644 --- a/test/unit/test_swift.py +++ b/test/unit/test_swift.py @@ -13,36 +13,36 @@ # See the License for the specific language governing permissions and # limitations under the License. -""" Tests for gluster.swift """ +""" Tests for swiftonfile.swift """ import os import unittest import shutil import tempfile -import gluster.swift as gs +import swiftonfile.swift as sof class TestPkgInfo(unittest.TestCase): """ - Tests for gluster.swift PkgInfo class. + Tests for swiftonfile.swift PkgInfo class. """ def test_constructor(self): - pi = gs.PkgInfo('a', 'b', 'c', 'd') + pi = sof.PkgInfo('a', 'b', 'c', 'd') assert pi.canonical_version == 'a' assert pi.name == 'c' self.assertEqual(pi.release, 'b') assert pi.final == 'd' def test_pretty_version(self): - pi = gs.PkgInfo('a', 'b', 'c', False) + pi = sof.PkgInfo('a', 'b', 'c', False) assert pi.pretty_version == 'a-dev' - pi = gs.PkgInfo('a', 'b', 'c', True) + pi = sof.PkgInfo('a', 'b', 'c', True) assert pi.pretty_version == 'a' def test_save_config(self): - pi = gs.PkgInfo('a', 'b', 'c', 'd') + pi = sof.PkgInfo('a', 'b', 'c', 'd') td = tempfile.mkdtemp() try: sc = os.path.join(td, 'saved_config.txt') diff --git a/tools/functional_tests.sh b/tools/functional_tests.sh index 94d5d9b..3b1b285 100755 --- a/tools/functional_tests.sh +++ b/tools/functional_tests.sh @@ -28,8 +28,8 @@ cleanup() sudo service memcached stop sudo_env swift-init main stop sudo rm -rf /etc/swift > /dev/null 2>&1 - sudo rm -rf /mnt/gluster-object/test{,2}/* > /dev/null 2>&1 - sudo setfattr -x user.swift.metadata /mnt/gluster-object/test{,2} > /dev/null 2>&1 + sudo rm -rf /mnt/swiftonfile/test{,2}/* > /dev/null 2>&1 + sudo setfattr -x user.swift.metadata /mnt/swiftonfile/test{,2} > /dev/null 2>&1 } quit() @@ -53,7 +53,7 @@ if [ -x /etc/swift ] ; then fi # Check the directories exist -DIRS="/mnt/gluster-object /mnt/gluster-object/test /mnt/gluster-object/test2" +DIRS="/mnt/swiftonfile /mnt/swiftonfile/test /mnt/swiftonfile/test2" for d in $DIRS ; do if [ ! -x $d ] ; then quit "$d must exist on an XFS or GlusterFS volume" diff --git a/tox.ini b/tox.ini index 44a4bce..5d56bcb 100644 --- a/tox.ini +++ b/tox.ini @@ -16,7 +16,7 @@ setenv = VIRTUAL_ENV={envdir} NOSE_OPENSTACK_STDOUT=1 NOSE_WITH_COVERAGE=1 NOSE_COVER_BRANCHES=1 - NOSE_COVER_PACKAGE=gluster + NOSE_COVER_PACKAGE=swiftonfile deps = # GitHub's .zip URL won't work! pip supports installing from git repos. # https://pip.pypa.io/en/latest/reference/pip_install.html#git @@ -48,7 +48,7 @@ commands = bash ./.functests -q [testenv:pep8] changedir = {toxinidir} commands = - flake8 gluster test setup.py + flake8 swiftonfile test setup.py [testenv:venv] changedir = {toxinidir}