diff options
author | Luis Pabon <lpabon@redhat.com> | 2013-05-10 16:17:45 -0400 |
---|---|---|
committer | Peter Portante <pportant@redhat.com> | 2013-05-17 08:38:11 -0700 |
commit | 7f7014862e78bd630afd3b5891d5570b6c674c30 (patch) | |
tree | ba2bc105b99d91a0fb2cd4a173e1acbd9c1e5120 /test/unit/common/test_Glusterfs.py | |
parent | 952a240852c2e8d528a0d73c3fd5a229d396282c (diff) |
object-store: Added busy_wait unit test to Glusterfs.py
Change-Id: Ifee5dccd47a3e301812533851c45b9fe853f9b71
Signed-off-by: Luis Pabon <lpabon@redhat.com>
Reviewed-on: http://review.gluster.org/4983
Reviewed-by: Peter Portante <pportant@redhat.com>
Tested-by: Peter Portante <pportant@redhat.com>
Diffstat (limited to 'test/unit/common/test_Glusterfs.py')
-rw-r--r-- | test/unit/common/test_Glusterfs.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/unit/common/test_Glusterfs.py b/test/unit/common/test_Glusterfs.py index 8f9b9ff..f36f601 100644 --- a/test/unit/common/test_Glusterfs.py +++ b/test/unit/common/test_Glusterfs.py @@ -15,9 +15,13 @@ import unittest import os, fcntl, errno, shutil +import time from tempfile import mkdtemp import gluster.swift.common.Glusterfs as gfs +def mock_os_path_ismount_false(path): + return False + def mock_os_path_ismount(path): return True @@ -30,6 +34,9 @@ def mock_os_system(cmd): def mock_fcntl_lockf(f, *a, **kw): raise IOError(errno.EAGAIN, os.strerror(errno.EAGAIN)) +def mock_time_sleep(secs): + return True + def _init(): global _RUN_DIR, _OS_SYSTEM, _FCNTL_LOCKF global _OS_PATH_ISMOUNT, __GET_EXPORT_LIST @@ -60,6 +67,21 @@ class TestGlusterfs(unittest.TestCase): def setUp(self): _init() + def test_busy_wait_timeout(self): + os.path.ismount = mock_os_path_ismount_false + + # setup time mock + real_time_sleep = time.sleep + time.sleep = mock_time_sleep + + try: + self.assertFalse(gfs._busy_wait("/")) + finally: + time.sleep = real_time_sleep + + def test_busy_wait(self): + self.assertTrue(gfs._busy_wait("/")) + def test_mount(self): try: tmpdir = mkdtemp() |