summaryrefslogtreecommitdiffstats
path: root/swift/1.4.8/test/unit/plugins/test_utils.py
diff options
context:
space:
mode:
authorPeter Portante <peter.portante@redhat.com>2012-10-19 01:35:46 -0400
committerPeter Portante <peter.portante@redhat.com>2013-04-29 16:35:55 -0400
commitea1077a3aeae805586fca9ab8a0849672bec8236 (patch)
treebecbbfa48ff80cde27f98e2a39b61714c710b798 /swift/1.4.8/test/unit/plugins/test_utils.py
parentf82b16c95539a5ad2f3b6fd93d80ea1bc396ab9b (diff)
Reduce the number of stat/fstat system calls made
This address BZ 868086, https://bugzilla.redhat.com/show_bug.cgi?id=868086 This refactoring consolidates the code a bit, and uses os.stat calls to get all the information in one call when gathering the metadata for an object. The five stat system calls (invoked via all the os.path.*() calls) have been reduced to one. We also added a unit test for the one new behavior where get_object_metadata() will now throw an OSError exception if it has a problem stat'ing a file that exists. Change-Id: Iad5410c77938af68a47be757a3170abd201adeb0 BUG: 868086 Signed-off-by: Peter Portante <peter.portante@redhat.com> Reviewed-on: http://review.gluster.org/4112 Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Reviewed-by: Mohammed Junaid <junaid@redhat.com> Tested-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'swift/1.4.8/test/unit/plugins/test_utils.py')
-rw-r--r--swift/1.4.8/test/unit/plugins/test_utils.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/swift/1.4.8/test/unit/plugins/test_utils.py b/swift/1.4.8/test/unit/plugins/test_utils.py
index 944d118..70081a7 100644
--- a/swift/1.4.8/test/unit/plugins/test_utils.py
+++ b/swift/1.4.8/test/unit/plugins/test_utils.py
@@ -312,6 +312,15 @@ class TestUtils(unittest.TestCase):
md = utils.get_object_metadata("/tmp/doesNotEx1st")
assert md == {}
+ def test_get_object_metadata_err(self):
+ tf = tempfile.NamedTemporaryFile()
+ try:
+ md = utils.get_object_metadata(os.path.join(tf.name,"doesNotEx1st"))
+ except OSError as e:
+ assert e.errno != errno.ENOENT
+ else:
+ self.fail("Expected exception")
+
obj_keys = (utils.X_TIMESTAMP, utils.X_CONTENT_TYPE, utils.X_ETAG,
utils.X_CONTENT_LENGTH, utils.X_TYPE, utils.X_OBJECT_TYPE)