Revision 320b4e2d
b/test/ganeti.utils_unittest.py | ||
---|---|---|
26 | 26 |
import time |
27 | 27 |
import tempfile |
28 | 28 |
import os.path |
29 |
import os |
|
29 | 30 |
import md5 |
30 | 31 |
import socket |
31 | 32 |
import shutil |
... | ... | |
89 | 90 |
|
90 | 91 |
class TestLocking(unittest.TestCase): |
91 | 92 |
"""Testing case for the Lock/Unlock functions""" |
93 |
|
|
94 |
def setUp(self): |
|
95 |
lock_dir = tempfile.mkdtemp(prefix="ganeti.unittest.", |
|
96 |
suffix=".locking") |
|
97 |
self.old_lock_dir = constants.LOCK_DIR |
|
98 |
constants.LOCK_DIR = lock_dir |
|
99 |
|
|
100 |
def tearDown(self): |
|
101 |
try: |
|
102 |
ganeti.utils.Unlock("unittest") |
|
103 |
except LockError: |
|
104 |
pass |
|
105 |
shutil.rmtree(constants.LOCK_DIR, ignore_errors=True) |
|
106 |
constants.LOCK_DIR = self.old_lock_dir |
|
107 |
|
|
92 | 108 |
def clean_lock(self, name): |
93 | 109 |
try: |
94 | 110 |
ganeti.utils.Unlock("unittest") |
... | ... | |
106 | 122 |
ganeti.utils.Lock("unittest") |
107 | 123 |
self.assertEqual(None, Unlock("unittest")) |
108 | 124 |
|
109 |
|
|
110 | 125 |
def testDoubleLock(self): |
111 | 126 |
self.clean_lock("unittest") |
112 | 127 |
ganeti.utils.Lock("unittest") |
Also available in: Unified diff