Commit 320b4e2d authored by Alexander Schreiber's avatar Alexander Schreiber
Browse files

Fix the unittest for locking.

Reviewed-by: imsnah
parent f4bc1f2c
......@@ -26,6 +26,7 @@ import os
import time
import tempfile
import os.path
import os
import md5
import socket
import shutil
......@@ -89,6 +90,21 @@ class TestIsProcessAlive(unittest.TestCase):
class TestLocking(unittest.TestCase):
"""Testing case for the Lock/Unlock functions"""
def setUp(self):
lock_dir = tempfile.mkdtemp(prefix="ganeti.unittest.",
suffix=".locking")
self.old_lock_dir = constants.LOCK_DIR
constants.LOCK_DIR = lock_dir
def tearDown(self):
try:
ganeti.utils.Unlock("unittest")
except LockError:
pass
shutil.rmtree(constants.LOCK_DIR, ignore_errors=True)
constants.LOCK_DIR = self.old_lock_dir
def clean_lock(self, name):
try:
ganeti.utils.Unlock("unittest")
......@@ -106,7 +122,6 @@ class TestLocking(unittest.TestCase):
ganeti.utils.Lock("unittest")
self.assertEqual(None, Unlock("unittest"))
def testDoubleLock(self):
self.clean_lock("unittest")
ganeti.utils.Lock("unittest")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment