From c9c33a28ee09dc0a7648268ac5ae2a34c0b35ce4 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Wed, 28 Mar 2012 18:11:04 +0200 Subject: [PATCH] Add whitelist for opcodes using BGL Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- test/ganeti.mcpu_unittest.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/test/ganeti.mcpu_unittest.py b/test/ganeti.mcpu_unittest.py index 20707623c..89d588a4b 100755 --- a/test/ganeti.mcpu_unittest.py +++ b/test/ganeti.mcpu_unittest.py @@ -34,6 +34,19 @@ from ganeti.constants import \ import testutils +REQ_BGL_WHITELIST = frozenset([ + opcodes.OpClusterActivateMasterIp, + opcodes.OpClusterDeactivateMasterIp, + opcodes.OpClusterDestroy, + opcodes.OpClusterPostInit, + opcodes.OpClusterRename, + opcodes.OpInstanceRename, + opcodes.OpNodeAdd, + opcodes.OpNodeRemove, + opcodes.OpTestAllocator, + ]) + + class TestLockAttemptTimeoutStrategy(unittest.TestCase): def testConstants(self): tpa = mcpu.LockAttemptTimeoutStrategy._TIMEOUT_PER_ATTEMPT @@ -67,6 +80,16 @@ class TestDispatchTable(unittest.TestCase): self.assertTrue(opcls in mcpu.Processor.DISPATCH_TABLE, msg="%s missing handler class" % opcls) + # Check against BGL whitelist + lucls = mcpu.Processor.DISPATCH_TABLE[opcls] + if lucls.REQ_BGL: + self.assertTrue(opcls in REQ_BGL_WHITELIST, + msg=("%s not whitelisted for BGL" % opcls.OP_ID)) + else: + self.assertFalse(opcls in REQ_BGL_WHITELIST, + msg=("%s whitelisted for BGL, but doesn't use it" % + opcls.OP_ID)) + if __name__ == "__main__": testutils.GanetiTestProgram() -- GitLab