diff options
author | Luis Pabon <lpabon@redhat.com> | 2013-06-21 16:41:50 -0400 |
---|---|---|
committer | Peter Portante <pportant@redhat.com> | 2013-06-28 13:17:50 -0700 |
commit | 5cef798f8dcdee0d0512e47b67ac67d5f8d6c14c (patch) | |
tree | 73dce36cbfc970b5a363bd0dbd33ade5ff291ac8 /test/unit/common/test_diskfile.py | |
parent | 92fdc68d6b90f4f7327bdffe542c5e8807a3e6c5 (diff) |
OpenStack Swift Functional Tests for G4S
This commit has the following changes:
* G4S no longer accepts URLs that end in /. A HTTP code
of 400 is returned when a / at the end of the object
is detected.
* Directories can be created as objects setting the
content-type to application/directory and content-length
to 0.
* Functional tests have been adjusted to work with
G4S constraints
Change-Id: I31038a59699a8e3eeaba902db322218c6400093e
Signed-off-by: Luis Pabon <lpabon@redhat.com>
Reviewed-on: http://review.gluster.org/5246
Reviewed-by: Peter Portante <pportant@redhat.com>
Tested-by: Peter Portante <pportant@redhat.com>
Diffstat (limited to 'test/unit/common/test_diskfile.py')
-rw-r--r-- | test/unit/common/test_diskfile.py | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/test/unit/common/test_diskfile.py b/test/unit/common/test_diskfile.py index b8878e8..857ba9d 100644 --- a/test/unit/common/test_diskfile.py +++ b/test/unit/common/test_diskfile.py @@ -23,7 +23,7 @@ import tempfile import shutil from hashlib import md5 from swift.common.utils import normalize_timestamp -from swift.common.exceptions import DiskFileNotExist +from swift.common.exceptions import DiskFileNotExist, DiskFileError import gluster.swift.common.DiskFile import gluster.swift.common.utils from gluster.swift.common.DiskFile import Gluster_DiskFile, \ @@ -54,8 +54,8 @@ class MockException(Exception): pass -def _mock_rmdirs(p): - raise MockException("gluster.swift.common.DiskFile.rmdirs() called") +def _mock_rmobjdir(p): + raise MockException("gluster.swift.common.DiskFile.rmobjdir() called") def _mock_do_fsync(fd): return @@ -348,12 +348,12 @@ class TestDiskFile(unittest.TestCase): assert g == DEFAULT_GID dc = gluster.swift.common.DiskFile.do_chown gluster.swift.common.DiskFile.do_chown = _mock_do_chown - try: - gdf._create_dir_object(the_dir) - finally: - gluster.swift.common.DiskFile.do_chown = dc - assert os.path.isdir(the_dir) - assert the_dir in _metadata + self.assertRaises(DiskFileError, + gdf._create_dir_object, + the_dir) + gluster.swift.common.DiskFile.do_chown = dc + self.assertFalse(os.path.isdir(the_dir)) + self.assertFalse(the_dir in _metadata) finally: shutil.rmtree(td) @@ -571,14 +571,14 @@ class TestDiskFile(unittest.TestCase): gdf = Gluster_DiskFile("/tmp/foo", "vol0", "p57", "ufo47", "bar", "z", self.lg) assert gdf.metadata == {} - _saved_rmdirs = gluster.swift.common.DiskFile.rmdirs - gluster.swift.common.DiskFile.rmdirs = _mock_rmdirs + _saved_rmobjdir = gluster.swift.common.DiskFile.rmobjdir + gluster.swift.common.DiskFile.rmobjdir = _mock_rmobjdir try: gdf.unlinkold(None) except MockException as exp: self.fail(str(exp)) finally: - gluster.swift.common.DiskFile.rmdirs = _saved_rmdirs + gluster.swift.common.DiskFile.rmobjdir = _saved_rmobjdir def test_unlinkold_same_timestamp(self): assert not os.path.exists("/tmp/foo") @@ -586,14 +586,14 @@ class TestDiskFile(unittest.TestCase): "z", self.lg) assert gdf.metadata == {} gdf.metadata['X-Timestamp'] = 1 - _saved_rmdirs = gluster.swift.common.DiskFile.rmdirs - gluster.swift.common.DiskFile.rmdirs = _mock_rmdirs + _saved_rmobjdir = gluster.swift.common.DiskFile.rmobjdir + gluster.swift.common.DiskFile.rmobjdir = _mock_rmobjdir try: gdf.unlinkold(1) except MockException as exp: self.fail(str(exp)) finally: - gluster.swift.common.DiskFile.rmdirs = _saved_rmdirs + gluster.swift.common.DiskFile.rmobjdir = _saved_rmobjdir def test_unlinkold_file(self): td = tempfile.mkdtemp() @@ -717,7 +717,7 @@ class TestDiskFile(unittest.TestCase): os.chmod(gdf.datadir, stats.st_mode) os.rmdir = __os_rmdir assert os.path.isdir(gdf.datadir) - assert os.path.isdir(gdf.data_file) + self.assertTrue(gdf.data_file is None) finally: shutil.rmtree(td) |