summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/unit/common/test_Glusterfs.py22
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()