Revision 04e1bfaf test/ganeti.locking_unittest.py
b/test/ganeti.locking_unittest.py | ||
---|---|---|
621 | 621 |
def testAcquireRelease(self): |
622 | 622 |
self.GL.acquire(locking.LEVEL_CLUSTER, ['BGL'], shared=1) |
623 | 623 |
self.assertEquals(self.GL._list_owned(locking.LEVEL_CLUSTER), set(['BGL'])) |
624 |
self.GL.acquire(locking.LEVEL_INSTANCE, ['i1']) |
|
624 | 625 |
self.GL.acquire(locking.LEVEL_NODE, ['n1', 'n2'], shared=1) |
625 |
self.GL.release(locking.LEVEL_NODE) |
|
626 |
self.GL.acquire(locking.LEVEL_NODE, ['n1']) |
|
626 |
self.GL.release(locking.LEVEL_NODE, ['n2']) |
|
627 | 627 |
self.assertEquals(self.GL._list_owned(locking.LEVEL_NODE), set(['n1'])) |
628 |
self.GL.acquire(locking.LEVEL_INSTANCE, ['i1', 'i2']) |
|
629 |
self.GL.release(locking.LEVEL_INSTANCE, ['i2']) |
|
630 | 628 |
self.assertEquals(self.GL._list_owned(locking.LEVEL_INSTANCE), set(['i1'])) |
631 | 629 |
self.GL.release(locking.LEVEL_NODE) |
630 |
self.assertEquals(self.GL._list_owned(locking.LEVEL_NODE), set()) |
|
631 |
self.assertEquals(self.GL._list_owned(locking.LEVEL_INSTANCE), set(['i1'])) |
|
632 | 632 |
self.GL.release(locking.LEVEL_INSTANCE) |
633 | 633 |
self.assertRaises(errors.LockError, self.GL.acquire, |
634 | 634 |
locking.LEVEL_INSTANCE, ['i5']) |
... | ... | |
656 | 656 |
|
657 | 657 |
def testWrongOrder(self): |
658 | 658 |
self.GL.acquire(locking.LEVEL_CLUSTER, ['BGL'], shared=1) |
659 |
self.GL.acquire(locking.LEVEL_INSTANCE, ['i3'])
|
|
659 |
self.GL.acquire(locking.LEVEL_NODE, ['n2'])
|
|
660 | 660 |
self.assertRaises(AssertionError, self.GL.acquire, |
661 | 661 |
locking.LEVEL_NODE, ['n1']) |
662 | 662 |
self.assertRaises(AssertionError, self.GL.acquire, |
... | ... | |
678 | 678 |
self.GL.acquire(locking.LEVEL_CLUSTER, ['BGL'], shared=1) |
679 | 679 |
Thread(target=self._doLock, args=(locking.LEVEL_INSTANCE, 'i1', 1)).start() |
680 | 680 |
self.assertEqual(self.done.get(True, 1), 'DONE') |
681 |
self.GL.acquire(locking.LEVEL_NODE, ['n1']) |
|
682 | 681 |
self.GL.acquire(locking.LEVEL_INSTANCE, ['i3']) |
683 | 682 |
Thread(target=self._doLock, args=(locking.LEVEL_INSTANCE, 'i1', 1)).start() |
684 | 683 |
self.assertEqual(self.done.get(True, 1), 'DONE') |
Also available in: Unified diff