From 0ef4d576dc2fc077b01d727f829ebcc616eb15c9 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Tue, 20 Nov 2012 04:19:12 +0100 Subject: [PATCH] locking: Add test for downgrade without names MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Until now there was no test for calling βLockSet.downgradeβ without specifying any names. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Guido Trotter <ultrotter@google.com> --- test/ganeti.locking_unittest.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/ganeti.locking_unittest.py b/test/ganeti.locking_unittest.py index 85fa0fc66..494994cdb 100755 --- a/test/ganeti.locking_unittest.py +++ b/test/ganeti.locking_unittest.py @@ -1703,6 +1703,21 @@ class TestLockSet(_ThreadedTestCase): self.ls.release() + def testDowngradeEverything(self): + self.assertEqual(self.ls.acquire(locking.ALL_SET, shared=0), + set(["one", "two", "three"])) + + # Ensure all locks are now owned in exclusive mode + for name in self.ls._names(): + self.assertTrue(self.ls.check_owned(name, shared=0)) + + # Downgrade everything + self.assertTrue(self.ls.downgrade()) + + # Ensure all locks are now owned in shared mode + for name in self.ls._names(): + self.assertTrue(self.ls.check_owned(name, shared=1)) + def testPriority(self): def _Acquire(prev, next, name, priority, success_fn): prev.wait() -- GitLab