summaryrefslogtreecommitdiffstats
path: root/test/unit/common
diff options
context:
space:
mode:
authorPrashanth Pai <ppai@redhat.com>2016-04-20 15:10:43 +0530
committerThiago da Silva <thiago@redhat.com>2016-04-20 12:08:03 -0700
commit5a04cede1f5bb44d6c64b186335146dd4e70a6ea (patch)
tree34babe4bcc295562ca3b740c98bc2299669c12f3 /test/unit/common
parent2bd696e392e420a2521dcca0b8613122d8169025 (diff)
Make swift's expirer compatible with gluster-swift
Swift's object expirer in kilo series was incompatible with gluster-swift. This change does the following: * Optimizes crawl in account and container server for listing requests for containers and tracker objects in gsexpiring volume. * Enables container server to delete tracker objects from gsexpiring volume. Swift's expirer sends request directly to container server to remove tracker object entry. * delete_tracker_object() is now a common utility function that is invoked from container server and gluster-swift's object expirer. * Run functional test to be run against both swift's object expirer and gluster-swift's object expirer Change-Id: Ib5b7f7f08fe7dda574f6dd80be2f38bdfaee32bc Signed-off-by: Prashanth Pai <ppai@redhat.com> Reviewed-on: http://review.gluster.org/14038 Reviewed-by: Thiago da Silva <thiago@redhat.com> Tested-by: Thiago da Silva <thiago@redhat.com>
Diffstat (limited to 'test/unit/common')
-rw-r--r--test/unit/common/test_diskdir.py70
1 files changed, 67 insertions, 3 deletions
diff --git a/test/unit/common/test_diskdir.py b/test/unit/common/test_diskdir.py
index 623164c..964bc2f 100644
--- a/test/unit/common/test_diskdir.py
+++ b/test/unit/common/test_diskdir.py
@@ -402,6 +402,37 @@ class TestContainerBroker(unittest.TestCase):
fp.write("file path: %s\n" % fullname)
return fullname
+ def test_gsexpiring_fake_md(self):
+ # Create account
+ account_path = os.path.join(self.path, "gsexpiring")
+ os.makedirs(account_path)
+
+ # Create container
+ cpath = os.path.join(account_path, "container")
+ os.mkdir(cpath)
+
+ # Create 10 objects in container. These should not reflect in
+ # X-Object-Count.
+ for o in xrange(10):
+ os.mkdir(os.path.join(cpath, str(o)))
+
+ orig_stat = os.stat(cpath)
+ expected_metadata = {
+ 'X-Object-Count': (0, 0),
+ 'X-Timestamp': ((normalize_timestamp(orig_stat.st_ctime)), 0),
+ 'X-Type': ('container', 0),
+ 'X-PUT-Timestamp': ((normalize_timestamp(orig_stat.st_mtime)), 0),
+ 'X-Bytes-Used': (0, 0)
+ }
+
+ # Create DiskDir instance
+ disk_dir = dd.DiskDir(self.path, 'gsexpiring', account='gsexpiring',
+ container='container', logger=FakeLogger())
+ self.assertEqual(expected_metadata, disk_dir.metadata)
+ info = disk_dir.get_info()
+ self.assertEqual(info['object_count'], 0)
+ self.assertEqual(info['bytes_used'], 0)
+
def test_creation(self):
# Test swift.common.db.ContainerBroker.__init__
broker = self._get_broker(account='a', container='c')
@@ -814,10 +845,10 @@ class TestContainerBroker(unittest.TestCase):
out_content_type="text/plain")
self.assertEquals(len(listing), 100)
for (name, ts, clen, ctype, etag) in listing:
- self.assertEqual(ts, 0)
+ self.assertEqual(ts, '0')
self.assertEqual(clen, 0)
- self.assertEqual(ctype, 0)
- self.assertEqual(etag, 0)
+ self.assertEqual(ctype, 'text/plain')
+ self.assertEqual(etag, '')
# Check that limit is still honored.
listing = broker.list_objects_iter(25, '', None, None, '',
@@ -1343,6 +1374,39 @@ class TestDiskAccount(unittest.TestCase):
_destroyxattr()
shutil.rmtree(self.td)
+ def test_gsexpiring_fake_md(self):
+ # Create account
+ account_path = os.path.join(self.td, "gsexpiring")
+ os.makedirs(account_path)
+
+ # Create 10 containers - these should not reflect in
+ # X-Container-Count. Also, create 10 objects in each
+ # container. These should not reflect in X-Object-Count.
+ for c in xrange(10):
+ cpath = os.path.join(account_path, str(c))
+ os.mkdir(cpath)
+ for o in xrange(10):
+ os.mkdir(os.path.join(cpath, str(o)))
+
+ orig_stat = os.stat(account_path)
+ expected_metadata = {
+ 'X-Object-Count': (0, 0),
+ 'X-Container-Count': (0, 0),
+ 'X-Timestamp': ((normalize_timestamp(orig_stat.st_ctime)), 0),
+ 'X-Type': ('Account', 0),
+ 'X-PUT-Timestamp': ((normalize_timestamp(orig_stat.st_mtime)), 0),
+ 'X-Bytes-Used': (0, 0)
+ }
+
+ # Create DiskAccount instance
+ da = dd.DiskAccount(self.td, 'gsexpiring', 'gsexpiring',
+ self.fake_logger)
+ self.assertEqual(expected_metadata, da.metadata)
+ info = da.get_info()
+ self.assertEqual(info['container_count'], 0)
+ self.assertEqual(info['object_count'], 0)
+ self.assertEqual(info['bytes_used'], 0)
+
def test_constructor_no_metadata(self):
da = dd.DiskAccount(self.td, self.fake_drives[0],
self.fake_accounts[0], self.fake_logger)