Skip to content
Snippets Groups Projects
Commit d4f6a91c authored by Guido Trotter's avatar Guido Trotter
Browse files

A few more locking unit tests

A few more tests written while bug-hunting. One of them shows a real
issue, at last. :)

Reviewed-by: imsnah
parent 90c942d1
No related branches found
No related tags found
No related merge requests found
......@@ -403,6 +403,12 @@ class TestLockSet(unittest.TestCase):
self.assertRaises(AssertionError, self.ls.add, 'five')
self.ls.release()
def testAcquireWithRepetitions(self):
self.assertEquals(self.ls.acquire(['two', 'two', 'three'], shared=1),
set(['two', 'two', 'three']))
self.ls.release(['two', 'two'])
self.assertEquals(self.ls._list_owned(), set(['three']))
def testEmptyAcquire(self):
# Acquire an empty list of locks...
self.assertEquals(self.ls.acquire([]), set())
......@@ -649,6 +655,20 @@ class TestGanetiLockManager(unittest.TestCase):
self.GL.release(locking.LEVEL_INSTANCE)
self.GL.release(locking.LEVEL_CLUSTER)
def testAcquireWholeAndPartial(self):
self.GL.acquire(locking.LEVEL_CLUSTER, ['BGL'], shared=1)
self.assertEquals(self.GL.acquire(locking.LEVEL_INSTANCE, None),
set(self.instances))
self.assertEquals(self.GL._list_owned(locking.LEVEL_INSTANCE),
set(self.instances))
self.assertEquals(self.GL.acquire(locking.LEVEL_NODE, ['n2'], shared=1),
set(['n2']))
self.assertEquals(self.GL._list_owned(locking.LEVEL_NODE),
set(['n2']))
self.GL.release(locking.LEVEL_NODE)
self.GL.release(locking.LEVEL_INSTANCE)
self.GL.release(locking.LEVEL_CLUSTER)
def testBGLDependency(self):
self.assertRaises(AssertionError, self.GL.acquire,
locking.LEVEL_NODE, ['n1', 'n2'])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment