summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorPrashanth Pai <ppai@redhat.com>2016-05-26 15:00:13 +0530
committerThiago da Silva <thiago@redhat.com>2016-11-18 09:48:42 -0800
commit3330c26f199f4a149bf0091259d88534d61f53fa (patch)
treeca9a4cd433c0887a807b5919ea926aa367803cbf /test
parentce0feed60b2077085a66d34021a3c96bbb7f5558 (diff)
Fix redundant stat in account and container server
Multiple stat() calls were made while serving GET requests for container and account. This removes those calls and can be easily verified using strace. There is room for further refactoring of code to simplify it. This will be addressed as a separate change to keep things simple in this patch. Change-Id: Ief457ff869c58519e9dbeb4ef13797185f536673 Signed-off-by: Prashanth Pai <ppai@redhat.com> Reviewed-on: http://review.gluster.org/14543 Reviewed-by: Thiago da Silva <thiago@redhat.com> Tested-by: Thiago da Silva <thiago@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/unit/common/test_diskdir.py3
-rw-r--r--test/unit/common/test_utils.py10
2 files changed, 9 insertions, 4 deletions
diff --git a/test/unit/common/test_diskdir.py b/test/unit/common/test_diskdir.py
index 964bc2f..ae9aa6e 100644
--- a/test/unit/common/test_diskdir.py
+++ b/test/unit/common/test_diskdir.py
@@ -279,7 +279,7 @@ class TestDiskCommon(unittest.TestCase):
assert dc.logger == self.fake_logger
assert dc.account == self.fake_accounts[0]
assert dc.datadir == os.path.join(self.td, self.fake_drives[0])
- assert dc._dir_exists is None
+ assert dc._dir_exists is False
def test__dir_exists_read_metadata_exists(self):
datadir = os.path.join(self.td, self.fake_drives[0])
@@ -315,6 +315,7 @@ class TestDiskCommon(unittest.TestCase):
def test_is_deleted(self):
dc = dd.DiskCommon(self.td, self.fake_drives[0],
self.fake_accounts[0], self.fake_logger)
+ dc._dir_exists_read_metadata()
assert dc.is_deleted() == False
def test_update_metadata(self):
diff --git a/test/unit/common/test_utils.py b/test/unit/common/test_utils.py
index 4790304..136c3a9 100644
--- a/test/unit/common/test_utils.py
+++ b/test/unit/common/test_utils.py
@@ -670,9 +670,13 @@ class TestUtils(unittest.TestCase):
def test_get_account_details_notadir(self):
tf = tempfile.NamedTemporaryFile()
- container_list, container_count = utils.get_account_details(tf.name)
- assert container_count == 0
- assert container_list == []
+ try:
+ utils.get_account_details(tf.name)
+ except OSError as err:
+ if err.errno != errno.ENOTDIR:
+ self.fail("Expecting ENOTDIR")
+ else:
+ self.fail("Expecting ENOTDIR")
def test_get_container_details_notadir(self):
tf = tempfile.NamedTemporaryFile()