import/export: Validate remote host/port
[ganeti-local] / test / ganeti.constants_unittest.py
index 2da1ff7..f21c99d 100755 (executable)
@@ -27,6 +27,8 @@ import re
 
 from ganeti import constants
 
+import testutils
+
 
 class TestConstants(unittest.TestCase):
   """Constants tests"""
@@ -58,6 +60,14 @@ class TestConstants(unittest.TestCase):
     self.failUnless(constants.LDS_OKAY < constants.LDS_UNKNOWN)
     self.failUnless(constants.LDS_UNKNOWN < constants.LDS_FAULTY)
 
+  def testClockSkew(self):
+    self.failUnless(constants.NODE_MAX_CLOCK_SKEW <
+                    (0.8 * constants.CONFD_MAX_CLOCK_SKEW))
+
+  def testSslCertExpiration(self):
+    self.failUnless(constants.SSL_CERT_EXPIRATION_ERROR <
+                    constants.SSL_CERT_EXPIRATION_WARN)
+
 
 class TestParameterNames(unittest.TestCase):
   """HV/BE parameter tests"""
@@ -74,5 +84,29 @@ class TestParameterNames(unittest.TestCase):
                         (kind, key))
 
 
+class TestConfdConstants(unittest.TestCase):
+  """Test the confd constants"""
+
+  def testFourCc(self):
+    self.failUnlessEqual(len(constants.CONFD_MAGIC_FOURCC), 4,
+                         "Invalid fourcc len, should be 4")
+
+  def _IsUniqueSequence(self, sequence):
+    seen = set()
+    for member in sequence:
+      if member in seen:
+        return False
+      seen.add(member)
+    return True
+
+  def testReqs(self):
+    self.failUnless(self._IsUniqueSequence(constants.CONFD_REQS),
+                    "Duplicated confd request code")
+
+  def testReplStatuses(self):
+    self.failUnless(self._IsUniqueSequence(constants.CONFD_REPL_STATUSES),
+                    "Duplicated confd reply status code")
+
+
 if __name__ == '__main__':
-  unittest.main()
+  testutils.GanetiTestProgram()