from ganeti import constants
+import testutils
+
class TestConstants(unittest.TestCase):
"""Constants tests"""
(constants.CONFIG_MAJOR, constants.CONFIG_MINOR,
constants.CONFIG_REVISION))
+ def testDiskStatus(self):
+ 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"""
"The %s parameter '%s' contains invalid characters" %
(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()