Add consistency test for mcpu dispatch table
authorMichael Hanselmann <hansmi@google.com>
Fri, 19 Nov 2010 20:42:52 +0000 (21:42 +0100)
committerMichael Hanselmann <hansmi@google.com>
Tue, 23 Nov 2010 21:04:15 +0000 (22:04 +0100)
Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

test/ganeti.mcpu_unittest.py

index bdfd3a2..9f56870 100755 (executable)
@@ -25,6 +25,7 @@
 import unittest
 
 from ganeti import mcpu
+from ganeti import opcodes
 
 import testutils
 
@@ -54,5 +55,14 @@ class TestLockAttemptTimeoutStrategy(unittest.TestCase):
       self.assert_(strat.NextAttempt() is None)
 
 
+class TestDispatchTable(unittest.TestCase):
+  def test(self):
+    for opcls in opcodes.OP_MAPPING.values():
+      if opcls is opcodes.OpCode or opcls is opcodes.OpTestDummy:
+        continue
+      self.assert_(opcls in mcpu.Processor.DISPATCH_TABLE,
+                   msg="%s missing handler class" % opcls)
+
+
 if __name__ == "__main__":
   testutils.GanetiTestProgram()