From 50067f9c69572b33f7600e2950669ecbc2294790 Mon Sep 17 00:00:00 2001 From: Prashanth Pai Date: Tue, 24 Jun 2014 14:38:02 +0530 Subject: [PATCH] Support Storage Policy - Rev 7 * Rename references of '/mnt/gluster-object' to '/mnt/swiftonfile'. * Rename swiftonfile SP name from 'sof' to 'swiftonfile'. * Retain reseller_prefix in account dir created. This is to comply with Swift's behavior. * Cleanup mountpoint after running swiftonfile specific tests. Signed-off-by: Prashanth Pai --- .functests | 6 +++--- etc/object-server.conf-gluster | 2 +- etc/swift.conf-gluster | 6 +++--- gluster/swift/obj/diskfile.py | 6 +----- test/functional/conf/swift.conf | 2 +- test/functional/swift_on_file_tests.py | 17 +++++++++++++---- 6 files changed, 22 insertions(+), 17 deletions(-) diff --git a/.functests b/.functests index 7294cf1..93a0d83 100755 --- a/.functests +++ b/.functests @@ -39,8 +39,8 @@ cleanup() print "Stopping swift sevices" sudo_env swift-init main stop print "Cleaning SoF mount point" - sudo rm -rf /mnt/gluster-object/test/* > /dev/null 2>&1 - sudo setfattr -x user.swift.metadata /mnt/gluster-object/test > /dev/null 2>&1 + sudo rm -rf /mnt/swiftonfile/test/* > /dev/null 2>&1 + sudo setfattr -x user.swift.metadata /mnt/swiftonfile/test > /dev/null 2>&1 print "Invoking SAIO's resetswift script" resetswift } @@ -57,7 +57,7 @@ fail() print """ Before proceeding forward, please make sure you already have: 1. SAIO deployment. (with resetswift and remakerings script) -2. XFS/GlusterFS mounted at /mnt/gluster-object/test +2. XFS/GlusterFS mounted at /mnt/swiftonfile/test """ prompt=true diff --git a/etc/object-server.conf-gluster b/etc/object-server.conf-gluster index 00a3103..033a2fb 100644 --- a/etc/object-server.conf-gluster +++ b/etc/object-server.conf-gluster @@ -4,7 +4,7 @@ # setting the following value in {account,container,object}-server.conf files. # It is recommended to keep this value same for all the three services but can # be kept different if environment demands. -devices = /mnt/gluster-object +devices = /mnt/swiftonfile # # Once you are confident that your startup processes will always have your # gluster volumes properly mounted *before* the object-server workers start, diff --git a/etc/swift.conf-gluster b/etc/swift.conf-gluster index 02fa8d3..4bbec24 100644 --- a/etc/swift.conf-gluster +++ b/etc/swift.conf-gluster @@ -40,10 +40,10 @@ default = yes #[storage-policy:1] #name = silver -# The following section defines a policy called 'sof' to be used by swiftonfile -# object-server implementation. +# The following section defines a policy called 'swiftonfile' to be used by +# swiftonfile object-server implementation. [storage-policy:2] -name = sof +name = swiftonfile # The swift-constraints section sets the basic constraints on data # saved in the swift cluster. These constraints are automatically diff --git a/gluster/swift/obj/diskfile.py b/gluster/swift/obj/diskfile.py index 27b2cd0..4a786eb 100644 --- a/gluster/swift/obj/diskfile.py +++ b/gluster/swift/obj/diskfile.py @@ -231,7 +231,7 @@ class DiskFileManager(SwiftDiskFileManager): def __init__(self, conf, logger): super(DiskFileManager, self).__init__(conf, logger) self.reseller_prefix = \ - conf.get('reseller_prefix', 'AUTH_').strip() + conf.get('reseller_prefix', 'AUTH_').strip() # Not used, currently def get_diskfile(self, device, partition, account, container, obj, policy_idx=0, **kwargs): @@ -589,10 +589,6 @@ class DiskFile(object): # Don't store a value for data_file until we know it exists. self._data_file = None - # Is this the right thing to do ? The Swift databases include - # the resller_prefix while storing the account name. - if account.startswith(self._mgr.reseller_prefix): - account = account[len(self._mgr.reseller_prefix):] self._account = account self._container = container diff --git a/test/functional/conf/swift.conf b/test/functional/conf/swift.conf index 604cdb0..31226c1 100644 --- a/test/functional/conf/swift.conf +++ b/test/functional/conf/swift.conf @@ -11,7 +11,7 @@ name = silver # SwiftOnFile [storage-policy:2] -name = sof +name = swiftonfile default = yes [swift-constraints] diff --git a/test/functional/swift_on_file_tests.py b/test/functional/swift_on_file_tests.py index bad7fd6..c864a6a 100644 --- a/test/functional/swift_on_file_tests.py +++ b/test/functional/swift_on_file_tests.py @@ -18,6 +18,7 @@ import os import re import hashlib +from shutil import rmtree from test.functional.tests import Base, Utils from test.functional.swift_test_client import Account, Connection, \ @@ -32,7 +33,7 @@ class TestSwiftOnFileEnv: cls.conn.authenticate() cls.account = Account(cls.conn, tf.config.get('account', tf.config['username'])) - cls.root_dir = os.path.join('/mnt/gluster-object/test') + cls.root_dir = os.path.join('/mnt/swiftonfile/test') cls.account.delete_containers() cls.file_size = 8 @@ -85,6 +86,12 @@ class TestSwiftOnFile(Base): env = TestSwiftOnFileEnv set_up = False + @classmethod + def tearDownClass(self): + self.env.account.delete_containers() + for account_dir in os.listdir(self.env.root_dir): + rmtree(os.path.join(self.env.root_dir, account_dir)) + def testObjectsFromMountPoint(self): found_files = [] found_dirs = [] @@ -99,7 +106,7 @@ class TestSwiftOnFile(Base): found_dirs.append(file) elif os.path.isfile(os.path.join(path, file)): filename = os.path.join(os.path.relpath(path, os.path.join( - self.env.root_dir, self.env.account.name, + self.env.root_dir, 'AUTH_' + self.env.account.name, self.env.container.name)), file) if re.match('^[\.]', filename): filename = filename[2:] @@ -107,7 +114,8 @@ class TestSwiftOnFile(Base): else: pass # Just a Place holder - recurse_path(os.path.join(self.env.root_dir, self.env.account.name, + recurse_path(os.path.join(self.env.root_dir, + 'AUTH_' + self.env.account.name, self.env.container.name)) for file in self.env.stored_files: self.assert_(file in found_files) @@ -120,7 +128,8 @@ class TestSwiftOnFile(Base): self.assert_status(201) file_info = file_item.info() fhOnMountPoint = open(os.path.join(self.env.root_dir, - self.env.account.name, self.env.container.name, + 'AUTH_' + self.env.account.name, + self.env.container.name, file_name), 'r') data_read_from_mountP = fhOnMountPoint.read() md5_returned = hashlib.md5(data_read_from_mountP).hexdigest()